-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve our approach for testing auth #9493
Comments
@jNullj wanted to flag your attention in case this was something you'd be interested in working on (definitely no pressure though!) |
I gave this a quick look and i think i am up to the task. |
Bingo
First off: I think probably the best way to tackle this will be to pick one service. Lets say Beyond that, I think that's a couple of ways to approach it: One option would be the example I gave in the top post. So that one would probably look like a single test file (in this case Another way would be to define a re-usable helper in a I think either of those could work. I think we probably want to optimise for:
|
It seems like #9681 is pretty close to merging which gives us a good starting point for a shared helper and pattern we can apply. Once we merge that, the next steps of this will be to make use of those and make a series of follow up PRs gradually bringing other services into line with the convention. The following services have got some kind of tests in place. Some of them are testing just the base class, some test one concrete implementation or all concrete implementations. They're a bit of a mixed bag:
These ones all have no tests at all covering the auth:
..and then these three are complicated and messy. I'm going to suggest we ignore these as they are unlikely to fit into any generic pattern.
One thing we could do next is pick off all the services that use query string auth first. Another one could be to concentrate on making the test helper more generic. If we've got a test helper (or 3 helpers) that work for services that implement auth using query string, basic auth, and authorization header, that would cover most cases. |
#9681 implements the necessary test helpers an applies the pattern to:
|
Will add other services today or tomorrow |
Awesome 👍 Thanks When you do this, can you split them down into chunks somehow. Doesn't necessarily have to be as fine grained as one PR per service, but maybe one per auth method: All the Basic Auth services in one PR, all the Query String services in another. Something like that. If I've got a bunch of small PRs to review, its easier to make time for them. One huge PR will end up sitting around for ages because it is harder to find the time to review it. Ta |
part of Improve our approach for testing auth badges#9493 seperated from PR badges#9983 for work in a later time
Our auth tests tend to fall into one of two categories
Either we implement auth on a base class, then test the auth is handed correctly in the base class using a dummy
https://github.com/badges/shields/blob/master/services/stackexchange/stackexchange-base.spec.js
Or we pick one concrete implementation and test that
https://github.com/badges/shields/blob/master/services/gitlab/gitlab-tag.spec.js
This is not water-tight.
As @calebcartwright suggests in #9387 (comment)
it would be good if we could be a bit more robust about this and make sure we cover all the concrete service classes that are supposed to use auth.
I've not tried it yet, but one possible solution might be to encapsulate the test boilerplate once in a function, then loop over all the relevant classes and call it
something like
The text was updated successfully, but these errors were encountered: