-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use OcsController and routes instead of API::register and static methods #37272
Conversation
7f6cf8e
to
a00def3
Compare
Codecov Report
@@ Coverage Diff @@
## master #37272 +/- ##
============================================
- Coverage 65.22% 64.74% -0.48%
+ Complexity 19445 19405 -40
============================================
Files 1286 1282 -4
Lines 76031 75793 -238
Branches 1336 1336
============================================
- Hits 49590 49072 -518
+ Misses 26441 26327 -114
- Partials 0 394 +394
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
aa2be47
to
e1e87a5
Compare
3b243e5
to
4b4102b
Compare
f69da89
to
3e29f25
Compare
It's difficult for me to justify having sql statements in a controller. I'd rather split the responsibilities in order to have one class focused on storing the info and the controller to build the response. Having an easy interface with the DB will also help to test the controller very intensively. |
bf70b74
to
04fc3e9
Compare
IMO Working with DB in a controller that is declared as controller explicitly is less critical than using classes in lib/private/OCS/ as controllers. Currently lib/private/OCS/PrivateData.php and all other classes under lib/private/OCS/ are directly hooked up to API endpoints. So they are used as controllers de facto. |
1928eb5
to
bb14b4c
Compare
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.
Acceptance test changes look good. Hopefully CI will agree.
@DeepDiver1975 or some dev, please review the code again.
In addition to Corby's comment, I think we should include a comment somewhere stating that the code in the controller has been moved from a different place. Honestly, if I hadn't any context, I'd say the code is quite bad to the point of make me wonder why this code exists. A comment in the controller would help to understand that we've just moved the code (barely touching it) and we opted to keep the backwards-compatibility. This hint should be enough to check the history if someone is interested. |
This will fail existing acceptance tests as none of these endpoints checked CSRF token in past |
602e659
to
47df8c9
Compare
@C0rby @DeepDiver1975 I've got your concerns after the checking API auth flow. |
I just saw in the description that there is a CORS header issue. So is there still work to do? @DeepDiver1975
The |
not completely ;) Here I'm migrating multiple legacy API endpoints into a single controller (and remove their dependence on prehistoric OC_API class) |
47df8c9
to
71758a7
Compare
Anything left to do here? I'm ok approving the current changes |
71758a7
to
01609e3
Compare
These endpoints don't need HTTP_OCS_APIREQUEST header anymore but require CSRF token instead. I guess some acceptance tests will fail with the last commit. |
The CSRF token is only checked on requests using cookie authorization. |
This comment has been minimized.
This comment has been minimized.
Let's merge it finally |
Kudos, SonarCloud Quality Gate passed! |
Description
$application->registerRoutes
instead ofAPI::register
Related Issue
Fixes #34664
Partially covers
#12454
How Has This Been Tested?
with curl
Case 2:
should contain
Access-Control-Allow-Origin: http://abcd.com
Types of changes
Checklist: