-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Improve our approach for testing auth (part 2) - basicAuth #9983
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
Conversation
Change auth tests to include all shields of the base class. The code is formated to be used in more general cases and increases code reuseability.
We already test all existing classes, no need for a dummy
Add getBadgeExampleCall to extract the first OpenAPI example then reformat it for service invoke function.
Add the testAuth function which tests auth of a service (badge) using a provided dummy response.
Add all auth methods used to testAuth to be generic and used by all services. Add helper functions to make testAuth more readable
Use apiHeaderKey & bearerHeaderKey as function params rather then extracting them with regex from function strings. Those options are now part of an options object param joined with the contentType that replaces header. header was originaly added for setting content type of the reply, so it makes more sense to directly set the content type
Before this commit the QueryStringAuth would only work for the key of stackexchange. This commit makes the testAuth function generic and allows passing user and pass keys.
Might set wrong header for jwt login request. This commit fixes that.
Some services might have more then one authOrigin. This commit makes sure we test for redundent authOrigins as well as support requests to them if needed.
Prior to this change, JwtAuth testing would lead to erros due to the absence of a specified login endpoint, Nock would be dumplicated for both login and non login hosts and indicate a missing request. This commit enforces the requirement for a new jwtLoginEndpoint argument when testing JwtAuth. The argument seperates the endpoint nock scope from the behavior of the request nock.
Example changed at 62ed7c3 The new example schema differ from old one This caused test to fail Update example response to fit new schema
remove for adding these changes in a later PR. this test adds the authOverride we try to get rid of. This blocks testAuth development and is planned for a later time.
part of Improve our approach for testing auth badges#9493 seperated from PR badges#9983 for work in a later time
|
I've been working 12-hour days recently, making it hard to complete tasks. With the holidays, I found time to finish this work. Future PRs will be smaller to avoid bottlenecks. I've removed Bitbucket as suggested and moved those changes to a separate branch. Although |
|
@jNullj shall we try to land this one? If so, could you please update it with latest revision, and I'll give it a look in the coming weeks. Worth noting that I added auth support for Reddit in #10790, and maybe other services were updated as well. This PR may require some additional changes.
In general, my philosophy is to keep things simple until we really need something. Especially in a world where so few people can dedicate time to the project. But up to you :) |
|
I prefer to cut the work into smaller chunks. |
|
Works for me. Will give this a proper review in the coming days. |
PyvesB
left a comment
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.
This is starting to shape up nicely! Noticed a few minor issues whilst reading through the changes.
Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
|
wops, sorry for the ping guys, i will fix that in a bit |
506e93b to
ed23542
Compare
Was outdated after merging with master. This commit fixes origin test to openapi example.
Avoid exact body match requirement. We are only intrested in username and password values to match, not exact one to one object.
|
Thank you for the review, i fixed all comments, also found some additional things to fix. |
This PR is follow-up for #9681 and helps to reach the goal of #9493
This PR will include refactor of all basicAuth services:
Additional changes to authTest:
4d57607 - Add exampleOverride
f156762 - Add authOverride
cd6c65b - Add configOverrid
cf34fae - Split invoke params into path and query
a713669 - Improve error handling, Throw error when service auth key is missing
99a01e1 - Handle case of userKey without passKey
74554d7 - Add option to ignore openApi example in testAuth
8c38355 - Handle auth.defaultToEmptyStringForUser
57163eb - Add support for multiple requests in service