-
Notifications
You must be signed in to change notification settings - Fork 1.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
refactor: recover tests for auth action #2859
Conversation
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.
I have two comments, otherwise LGTM overall.
@@ -1,208 +0,0 @@ | |||
// Copyright IBM Corp. 2019. All Rights Reserved. |
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.
Are we removing these tests because they are already covered/moved to some other place (Perhaps @emonddr's PR had them)?
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.
@b-admike These tests are written using a passport based strategy + passport adapter. While the old adapter will be deprecated and replaced by a new one to be created in a new module, so acceptance test for the passport strategy should be rewritten in that coming new module.
The new auth sysmte that Dom created is built with the extension point, so that the new acceptance tests also reflect that change:
see https://github.com/strongloop/loopback-next/blob/master/packages/authentication/src/__tests__/acceptance/jwt-auth-extension.acceptance.ts
and https://github.com/strongloop/loopback-next/blob/master/packages/authentication/src/__tests__/acceptance/basic-auth-extension.acceptance.ts
Are we removing these tests because they are already covered/moved to some other place
So to answer your question, yes or no, the acceptance tests for the new auth system is covered. The new adapter and its corresponding acceptance tests haven't created. The file you are looking at is removed because of the old adapter doesn't work with the new system anymore.
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.
Makes sense, thanks for the in-depth explanation @jannyHou :-).
packages/authentication/src/__tests__/unit/fixtures/mock-strategy-passport.ts
Show resolved
Hide resolved
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.
Thanks for answering my questions, LGTM 👍
// override authenticate method to set calledFlag | ||
async authenticate(req: Request, options?: AuthenticateOptions) { | ||
calledFlag = true; | ||
await MockStrategy.prototype.authenticate.call(this, req, options); | ||
await MockPassportStrategy.prototype.authenticate.call( |
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.
Please use await super.authenticate(...)
instead.
411821e
to
2ff383b
Compare
// override authenticate method to set calledFlag | ||
async authenticate(req: Request, options?: AuthenticateOptions) { | ||
calledFlag = true; | ||
await MockStrategy.prototype.authenticate.call(this, req, options); | ||
await super.authenticate.call(this, req, options); |
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.
Just super.authenticate(req, options);
.
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.
I was dumm 😞
8988474
to
4758034
Compare
4758034
to
4031220
Compare
Great job, @jannyHou |
Description
Fixes #2467
See discussion in the draft PR #2822.
And since a new package will be created for the new adapter(s), I will work on the spike #2676 (comment) first, then create the adapter's package in
loopback-labs
.