-
Notifications
You must be signed in to change notification settings - Fork 1
/
web-test-runner.config.mjs
59 lines (56 loc) · 1.89 KB
/
web-test-runner.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// import { CodeServerMock } from './test/oauth2/ServerMock.js';
import pkg from './test/oauth2/ServerMock.js';
const { CodeServerMock } = pkg;
export default {
files: 'test/**/*.test.js',
nodeResolve: true,
plugins: [
{
name: 'mock-api',
serve(context) {
if (context.path === '/oauth2/auth-code') {
return CodeServerMock.authRequest(context.request);
}
if (context.path === '/oauth2/token') {
return CodeServerMock.tokenRequest(context);
}
if (context.path === '/oauth2/auth-code-custom') {
return CodeServerMock.authRequestCustom(context.request);
}
if (context.path === '/oauth2/token-custom') {
return CodeServerMock.tokenRequestCustom(context);
}
if (context.path === '/oauth2/password') {
return CodeServerMock.tokenPassword(context);
}
if (context.path === '/oauth2/client-credentials') {
return CodeServerMock.tokenClientCredentials(context);
}
if (context.path === '/oauth2/client-credentials-header') {
return CodeServerMock.tokenClientCredentialsHeader(context);
}
if (context.path === '/oauth2/custom-grant') {
return CodeServerMock.tokenCustomGrant(context);
}
if (context.path === '/empty-response') {
return '';
}
return undefined;
},
},
],
middleware: [
function implicitAuth(context, next) {
if (context.path === '/oauth2/auth-implicit') {
return CodeServerMock.authRequestImplicit(context);
}
if (context.path === '/oauth2/auth-implicit-custom') {
return CodeServerMock.authRequestImplicitCustom(context);
}
if (context.path === '/oauth2/auth-implicit-invalid-state') {
return CodeServerMock.authRequestImplicitStateError(context);
}
return next();
}
]
};