Skip to content
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

Merged
merged 1 commit into from
May 15, 2019
Merged

Conversation

jannyHou
Copy link
Contributor

@jannyHou jannyHou commented May 9, 2019

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.

Copy link
Contributor

@b-admike b-admike left a 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.
Copy link
Contributor

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)?

Copy link
Contributor Author

@jannyHou jannyHou May 13, 2019

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.

Copy link
Contributor

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 :-).

Copy link
Contributor

@b-admike b-admike left a 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(
Copy link
Contributor

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.

@jannyHou jannyHou force-pushed the refactor/passport-adapter branch 3 times, most recently from 411821e to 2ff383b Compare May 14, 2019 01:47
// 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);
Copy link
Contributor

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);.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was dumm 😞

@jannyHou jannyHou force-pushed the refactor/passport-adapter branch 2 times, most recently from 8988474 to 4758034 Compare May 14, 2019 16:07
@jannyHou jannyHou force-pushed the refactor/passport-adapter branch from 4758034 to 4031220 Compare May 15, 2019 14:09
@jannyHou jannyHou merged commit fe22f82 into master May 15, 2019
@b-admike b-admike deleted the refactor/passport-adapter branch May 15, 2019 15:21
@emonddr
Copy link
Contributor

emonddr commented May 15, 2019

Great job, @jannyHou

@jannyHou jannyHou mentioned this pull request May 16, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor the authentication action to be a common one.
5 participants