-
Notifications
You must be signed in to change notification settings - Fork 13
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
[OGUI-1604] Add middleware to 'edit layout' requests #2734
base: dev
Are you sure you want to change the base?
[OGUI-1604] Add middleware to 'edit layout' requests #2734
Conversation
…ure/OGUI-1604/add-layout-edit-middleware
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.
Hi @mariscalromeroalejandro ,
The PR is in the right direction, good job!
Given that we move these checks to middleware function, and cleaning the tests for controller on such criteria, it means we are left exposed on API being tested against these scenarios.
Please have a look at the API tests from Control https://github.com/AliceO2Group/WebUi/tree/dev/Control/test/api and add some API tests for the PUT and PATCH layout:id
paths as well
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.
Direction of the PullRequest is good. There are a few comments I have added plus, please add also API tests for PATCH
…ure/OGUI-1604/add-layout-edit-middleware
|
||
test('should return a 404 error if the layout id is not provided', async () => { | ||
await request(`${URL_ADDRESS}/api/layout/`) | ||
.put(`?id=${null}&token=${OWNER_TEST_TOKEN}`) |
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.
Where is the query parameter id
used? As far as I can tell the id/name of the layout is taken from the req url param list
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.
Yes. The id and token are included in the URL as query parameters, not in the request body. They are still part of the query string in the URL
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.
But the API PUT route is not expecting a query parameter (the ones after ?
)
It is expecting a URL parameters (the one after api/layout/
…ure/OGUI-1604/add-layout-edit-middleware
This PR adds checks when editing layouts using
PATCH
andPUT
requests:PUT
requests, ensures that only the owner can update their layout.