Skip to content

Commit 0643e9e

Browse files
committed
fix: errors in mock oauth2 app export from test folder
fixes #5380
1 parent f5c9ddd commit 0643e9e

26 files changed

Lines changed: 1228 additions & 26 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm-debug.log
55
coverage
66
.nyc_output
77
**/*.tgz
8+
fixtures/*/dist
89
acceptance/*/dist
910
packages/*/dist
1011
extensions/*/dist

docs/site/migration/auth/oauth2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ We have a simplified OAuth 2.0 server implementation in extension
2323
[authentication-passport](https://github.com/strongloop/loopback-next/blob/master/extensions/authentication-passport)'s
2424
test fixtures, which sets up an Express application as an OAuth 2.0 provider.
2525
You can find the code in file
26-
[mock-oauth2-social-app.ts](https://github.com/strongloop/loopback-next/blob/master/extensions/authentication-passport/src/__tests__/acceptance/fixtures/mock-oauth2-social-app.ts).
26+
[mock-oauth2-provider](https://github.com/strongloop/loopback-next/blob/master/fixtures/mock-oauth2-provider).
2727
At this moment people who are interested to create such a provider can use it as
2828
a reference.

examples/access-control-migration/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"src/**/*.json"
1212
],
1313
"references": [
14+
{
15+
"path": "../../packages/core/tsconfig.json"
16+
},
17+
{
18+
"path": "../../packages/http-caching-proxy/tsconfig.json"
19+
},
1420
{
1521
"path": "../../packages/authentication/tsconfig.json"
1622
},
@@ -24,7 +30,7 @@
2430
"path": "../../packages/context/tsconfig.json"
2531
},
2632
{
27-
"path": "../../packages/core/tsconfig.json"
33+
"path": "../../packages/testlab/tsconfig.json"
2834
},
2935
{
3036
"path": "../../packages/http-caching-proxy/tsconfig.json"

examples/passport-login/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"tslib": "^1.12.0"
7777
},
7878
"devDependencies": {
79+
"@loopback/mock-oauth2-provider": "^0.0.1",
7980
"@loopback/build": "^5.3.1",
8081
"@loopback/eslint-config": "^6.0.6",
8182
"@loopback/http-caching-proxy": "^2.1.3",

examples/passport-login/src/__tests__/acceptance/passport-login.acceptance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {Client, supertest, expect} from '@loopback/testlab';
7-
import {MockTestOauth2SocialApp} from '@loopback/authentication-passport';
7+
import {MockTestOauth2SocialApp} from '@loopback/mock-oauth2-provider';
88
import {ExpressServer} from '../../server';
99
import {User, UserIdentity} from '../../models';
1010
import {startApplication} from '../../';

examples/passport-login/tsconfig.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@
1212
"src/**/*.json"
1313
],
1414
"references": [
15+
{
16+
"path": "../../packages/express/tsconfig.json"
17+
},
1518
{
1619
"path": "../../extensions/authentication-passport/tsconfig.json"
1720
},
21+
{
22+
"path": "../../fixtures/mock-oauth2-provider/tsconfig.json"
23+
},
24+
{
25+
"path": "../../packages/testlab/tsconfig.json"
26+
},
1827
{
1928
"path": "../../packages/authentication/tsconfig.json"
2029
},
@@ -28,7 +37,7 @@
2837
"path": "../../packages/core/tsconfig.json"
2938
},
3039
{
31-
"path": "../../packages/express/tsconfig.json"
40+
"path": "../../packages/http-caching-proxy/tsconfig.json"
3241
},
3342
{
3443
"path": "../../packages/http-caching-proxy/tsconfig.json"

extensions/authentication-passport/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"util-promisifyall": "^1.0.6"
5353
},
5454
"devDependencies": {
55+
"@loopback/mock-oauth2-provider": "^0.0.1",
5556
"@loopback/build": "^5.3.1",
5657
"@loopback/eslint-config": "^6.0.6",
5758
"@loopback/openapi-spec-builder": "^2.1.3",

extensions/authentication-passport/src/__tests__/acceptance/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
A. the Supertest client
1010

11-
B. a LoopBack app (fixtures/simple-rest-app.ts) - has a simple app with no
11+
B. a LoopBack app (./fixtures/simple-rest-app.ts) - has a simple app with no
1212
controller, Oauth2Controller is added during the test run
1313

14-
C. Mock Authorization Server (fixtures/mock-oauth2-social-app.ts) - mocks the
14+
C. Mock Authorization Server (@loopback/mock-oauth2-provider) - mocks the
1515
authorization flow login with a social app like facebook, google, etc
1616

1717
### Test steps:

extensions/authentication-passport/src/__tests__/acceptance/authentication-with-passport-strategy-oauth2-adapter.acceptance.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
VerifyFunction,
1111
VerifyCallback,
1212
} from 'passport-oauth2';
13-
import {MyUser, userRepository} from './fixtures/user-repository';
13+
import {MyUser, userRepository} from '@loopback/mock-oauth2-provider';
1414
import {
1515
simpleRestApplication,
1616
configureApplication,
@@ -25,10 +25,7 @@ import {
2525
supertest,
2626
} from '@loopback/testlab';
2727
import {RestApplication, RestBindings, Response} from '@loopback/rest';
28-
import {
29-
startApp as startMockOauth2Server,
30-
stopApp as stopMockOauth2Server,
31-
} from './fixtures/mock-oauth2-social-app';
28+
import {MockTestOauth2SocialApp} from '@loopback/mock-oauth2-provider';
3229
import * as url from 'url';
3330
import {inject} from '@loopback/core';
3431
import axios from 'axios';
@@ -160,8 +157,8 @@ describe('Oauth2 authorization flow', () => {
160157
let oauth2Strategy: StrategyAdapter<MyUser>;
161158
let client: Client;
162159

163-
before(startMockOauth2Server);
164-
after(stopMockOauth2Server);
160+
before(MockTestOauth2SocialApp.startMock);
161+
after(MockTestOauth2SocialApp.stopMock);
165162

166163
before(givenLoopBackApp);
167164
before(givenOauth2Strategy);

extensions/authentication-passport/src/__tests__/acceptance/fixtures/simple-rest-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
Send,
2222
SequenceHandler,
2323
} from '@loopback/rest';
24-
import {MyUser} from './user-repository';
24+
import {MyUser} from '@loopback/mock-oauth2-provider';
2525
import {StrategyAdapter} from '../../../strategy-adapter';
2626
import {extensionFor} from '@loopback/core';
2727

0 commit comments

Comments
 (0)