-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support ApiServer to enforce POST requests for state changing APIs and requests with timestamps #10899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ApiServer to enforce POST requests for state changing APIs and requests with timestamps #10899
Conversation
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13472 |
@blueorangutan test |
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13373)
|
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10899 +/- ##
=========================================
Coverage 16.58% 16.58%
Complexity 13989 13989
=========================================
Files 5743 5743
Lines 510706 510764 +58
Branches 62119 62124 +5
=========================================
+ Hits 84689 84699 +10
- Misses 416543 416591 +48
Partials 9474 9474
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13492 |
c1a31a9
to
d5bde7c
Compare
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13493 |
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13498 |
@blueorangutan test |
@borisstoyanov a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13412)
|
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enforces POST requests (with timestamps) for state-changing APIs in ApiServer when the enforce.post.requests.and.timestamps
setting is enabled, and updates both tests and UI components accordingly.
- Replace all
api(…)
calls withgetAPI(…)
for read-only, andpostAPI(…)
for state-changing operations - Update unit tests to use
common.createDataParams
and POST methods instead ofURLSearchParams
+ GET - Introduce
createDataParams
helper inui/tests/common/index.js
to build request bodies
Reviewed Changes
Copilot reviewed 261 out of 261 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
ui/tests/common/index.js | Added createDataParams helper for building POST body params |
ui/tests/unit/views/compute/MigrateWizard.spec.js | Updated tests to expect POST + common.createDataParams |
ui/tests/unit/views/AutogenView.spec.js | Updated tests to expect POST + common.createDataParams |
ui/tests/unit/components/view/ActionButton.spec.js | Updated tests to expect POST + common.createDataParams |
(many) ui/src/views/.../*.vue |
Switched imports from api to getAPI /postAPI and updated calls |
Comments suppressed due to low confidence (3)
ui/tests/unit/components/view/ActionButton.spec.js:154
- The test references
common.createDataParams
butcommon
is not imported at the top of this spec file. Add an import, e.g.import common from '@/tests/common'
.
data: common.createDataParams({
ui/tests/unit/views/compute/MigrateWizard.spec.js:349
- This spec uses
common.createDataParams
but there is nocommon
import shown. Ensurecommon
is imported (e.g.import common from '@/tests/common'
).
data: common.createDataParams({
ui/tests/unit/views/AutogenView.spec.js:578
- Make sure
common
is imported in this spec file socommon.createDataParams
is defined.
data: common.createDataParams({
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For UI it could be smaller, simpler change
@@ -23,18 +23,10 @@ import { | |||
ACCESS_TOKEN | |||
} from '@/store/mutation-types' | |||
|
|||
export function api (command, args = {}, method = 'GET', data = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti wouldn't it be easier to refactor this method itself to enforce use of POST/GET based on configuration/API type? We won't have to modify each caller in that case. Current change will cause merge conflicts for almost all UI related active PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will check it @shwstppr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shwstppr As discussed offline, the api method is refactored to smaller, separate functions to handle GET & POST calls. These new calls also indicate the underlying method (GET / POST) used for the API call. Also, it's better to have POST method calls for all non-listing, state changing APIs from UI, so keeping these changes as it is. Any merge conflicts / issues, we(or the authors)'ll resolve them.
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
…changing APIs Co-authored-by: Kevin Li <[email protected]>
Co-authored-by: Kevin Li <[email protected]>
75107b7
to
a1f2604
Compare
@blueorangutan package |
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code lgtm
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14026 |
@blueorangutan test |
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13677)
|
Description
This PR enables ApiServer to support enforcing POST requests with timestamps for state changing APIs, thought the setting 'enforce.post.requests.and.timestamps' (default: false).
Other related sub-project PRs supporting POST requests:
Need to update the cloudstack-go sdk version in the below sub-projects once the changes in apache/cloudstack-go#107 are merged and the sdk is released.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Tested some VM, Volume operations with setting 'enforce.post.requests.and.timestamps' false and true.
How did you try to break this feature and the system with this change?