-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Allow set user mapped from JWT directly on request #6411
Conversation
Could you please add some tests cases? @dplewis what do you think about it? |
About tests, I had a look at https://github.com/parse-community/parse-server/blob/master/spec/Middlewares.spec.js . It seems to me that a lot of the existing code branch and logic are not covered. I cannot find a good test example that I can copy paste then modify for the code I just added. |
I think you could inspire the tests in the session token tests of the following file: https://github.com/parse-community/parse-server/blob/fd0b535159877fa9bc74fb645169f56814c67c60/spec/ParseUser.spec.js |
Thank you @davimacedo . I see the tests in that file mimic a request to test. For example with sessionToken in the headers to get proper access. But I'm not sure how should I write this test. If I have the JWT token on the header it won't work because the step of map from JWT to a Parse user is done by the user themselves before they set the user onto the request. It's a middleware before the Parse middleware. I considered if the mapping should be part of Parse but as I said in the original issue, I'm not sure #6390 (comment)
|
Maybe it can be part of Parse Server. Do you want to suggest how it could be included? Anyways, in the case of the tests, you can create an express app and add the middleware then Parse (just like you are doing in your application) in the beginning of your test case. |
Codecov Report
@@ Coverage Diff @@
## master #6411 +/- ##
==========================================
- Coverage 93.95% 93.93% -0.03%
==========================================
Files 169 169
Lines 11687 11812 +125
==========================================
+ Hits 10981 11096 +115
- Misses 706 716 +10
Continue to review full report at Codecov.
|
@davimacedo and @dplewis , I've added a test. I've no clue how the code coverage could drop that much. Probably something wrong with the CI system |
@acinader Thoughts? |
I think we are good with this coverage and we can merge. |
Thank you @davimacedo ! Could someone please merge it? |
A not ideal workaround for people really need it
#6390 (comment)