-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix oauth2 mock #5522
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
Merged
Merged
Fix oauth2 mock #5522
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ee18451
chore(mock-oauth2-provider): publish the package to npm
raymondfeng 3cdd83d
fix(mock-oauth2-provider): add main/types entries in package.json
raymondfeng a9c2c98
feat(mock-oauth2-provider): improve the app with tests and scripts
raymondfeng 5f16eba
test: clean up tests that use mock-auth2-provider
raymondfeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
fixtures/mock-oauth2-provider/src/__tests__/acceptance/mock-oauth2.acceptance.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright IBM Corp. 2020. All Rights Reserved. | ||
| // Node module: @loopback/mock-oauth2-provider | ||
| // This file is licensed under the MIT License. | ||
| // License text available at https://opensource.org/licenses/MIT | ||
|
|
||
| import {supertest} from '@loopback/testlab'; | ||
| import {Server} from 'http'; | ||
| import {MockTestOauth2SocialApp} from '../..'; | ||
|
|
||
| /* eslint-disable @typescript-eslint/camelcase */ | ||
| describe('mock-oauth2-provider', () => { | ||
| let server: Server; | ||
| before(() => (server = MockTestOauth2SocialApp.startMock(0))); | ||
| after(MockTestOauth2SocialApp.stopMock); | ||
|
|
||
| it('exposes GET /login', () => { | ||
| return supertest(server).get('/login').expect(200); | ||
| }); | ||
|
|
||
| it('exposes GET /verify', () => { | ||
| return supertest(server) | ||
| .get('/verify?access_token=123') | ||
| .expect(401, {error: 'invalid token'}); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/dialog', () => { | ||
| return supertest(server) | ||
| .get('/oauth/dialog') | ||
| .query({ | ||
| redirect_uri: 'http://localhost:3000/callback', | ||
| client_id: '1111', | ||
| }) | ||
| .expect(302) | ||
| .expect( | ||
| 'location', | ||
| '/login?client_id=1111&redirect_uri=http://localhost:3000/callback', | ||
| ); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/dialog with scope', () => { | ||
| return supertest(server) | ||
| .get('/oauth/dialog') | ||
| .query({ | ||
| redirect_uri: 'http://localhost:3000/callback', | ||
| client_id: '1111', | ||
| scope: 'email', | ||
| }) | ||
| .expect(302) | ||
| .expect( | ||
| 'location', | ||
| '/login?client_id=1111&redirect_uri=http://localhost:3000/callback&scope=email', | ||
| ); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/dialog - missing redirect_uri', () => { | ||
| return supertest(server) | ||
| .get('/oauth/dialog') | ||
| .expect(400, {error: 'missing redirect_uri'}); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/dialog - missing client_id', () => { | ||
| return supertest(server) | ||
| .get('/oauth/dialog') | ||
| .query({redirect_uri: 'http://localhost:3000/callback'}) | ||
| .expect(400, {error: 'missing client_id'}); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/token - invalid client id', () => { | ||
| return supertest(server) | ||
| .get('/oauth/token?client_id=123') | ||
| .expect(401, {error: 'invalid client id'}); | ||
| }); | ||
|
|
||
| it('exposes GET /oauth/token', () => { | ||
| return supertest(server) | ||
| .get('/oauth/token?client_id=1111') | ||
| .expect(401, {error: 'invalid code'}); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thought we were intentionally keeping this package private ?
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.
Per #5520, when the
example-passport-loginis cloned withlb4 example,npm ifails as this package is devDep ofexample-passport-login.