@whook/oauth2 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +384 -0
  3. package/dist/handlers/getOAuth2Authorize.d.ts +26 -0
  4. package/dist/handlers/getOAuth2Authorize.js +192 -0
  5. package/dist/handlers/getOAuth2Authorize.js.map +1 -0
  6. package/dist/handlers/getOAuth2Authorize.mjs +169 -0
  7. package/dist/handlers/getOAuth2Authorize.mjs.map +1 -0
  8. package/dist/handlers/getOAuth2Authorize.test.d.ts +1 -0
  9. package/dist/handlers/getOAuth2Authorize.test.js +122 -0
  10. package/dist/handlers/getOAuth2Authorize.test.js.map +1 -0
  11. package/dist/handlers/getOAuth2Authorize.test.mjs +114 -0
  12. package/dist/handlers/getOAuth2Authorize.test.mjs.map +1 -0
  13. package/dist/handlers/postAuthLogin.d.ts +45 -0
  14. package/dist/handlers/postAuthLogin.js +125 -0
  15. package/dist/handlers/postAuthLogin.js.map +1 -0
  16. package/dist/handlers/postAuthLogin.mjs +108 -0
  17. package/dist/handlers/postAuthLogin.mjs.map +1 -0
  18. package/dist/handlers/postAuthLogin.test.d.ts +1 -0
  19. package/dist/handlers/postAuthLogin.test.js +90 -0
  20. package/dist/handlers/postAuthLogin.test.js.map +1 -0
  21. package/dist/handlers/postAuthLogin.test.mjs +85 -0
  22. package/dist/handlers/postAuthLogin.test.mjs.map +1 -0
  23. package/dist/handlers/postAuthLogout.d.ts +12 -0
  24. package/dist/handlers/postAuthLogout.js +46 -0
  25. package/dist/handlers/postAuthLogout.js.map +1 -0
  26. package/dist/handlers/postAuthLogout.mjs +33 -0
  27. package/dist/handlers/postAuthLogout.mjs.map +1 -0
  28. package/dist/handlers/postAuthLogout.test.d.ts +1 -0
  29. package/dist/handlers/postAuthLogout.test.js +35 -0
  30. package/dist/handlers/postAuthLogout.test.js.map +1 -0
  31. package/dist/handlers/postAuthLogout.test.mjs +30 -0
  32. package/dist/handlers/postAuthLogout.test.mjs.map +1 -0
  33. package/dist/handlers/postAuthRefresh.d.ts +45 -0
  34. package/dist/handlers/postAuthRefresh.js +140 -0
  35. package/dist/handlers/postAuthRefresh.js.map +1 -0
  36. package/dist/handlers/postAuthRefresh.mjs +122 -0
  37. package/dist/handlers/postAuthRefresh.mjs.map +1 -0
  38. package/dist/handlers/postAuthRefresh.test.d.ts +1 -0
  39. package/dist/handlers/postAuthRefresh.test.js +99 -0
  40. package/dist/handlers/postAuthRefresh.test.js.map +1 -0
  41. package/dist/handlers/postAuthRefresh.test.mjs +94 -0
  42. package/dist/handlers/postAuthRefresh.test.mjs.map +1 -0
  43. package/dist/handlers/postOAuth2Acknowledge.d.ts +28 -0
  44. package/dist/handlers/postOAuth2Acknowledge.js +165 -0
  45. package/dist/handlers/postOAuth2Acknowledge.js.map +1 -0
  46. package/dist/handlers/postOAuth2Acknowledge.mjs +150 -0
  47. package/dist/handlers/postOAuth2Acknowledge.mjs.map +1 -0
  48. package/dist/handlers/postOAuth2Acknowledge.test.d.ts +1 -0
  49. package/dist/handlers/postOAuth2Acknowledge.test.js +148 -0
  50. package/dist/handlers/postOAuth2Acknowledge.test.js.map +1 -0
  51. package/dist/handlers/postOAuth2Acknowledge.test.mjs +140 -0
  52. package/dist/handlers/postOAuth2Acknowledge.test.mjs.map +1 -0
  53. package/dist/handlers/postOAuth2Token.d.ts +36 -0
  54. package/dist/handlers/postOAuth2Token.js +263 -0
  55. package/dist/handlers/postOAuth2Token.js.map +1 -0
  56. package/dist/handlers/postOAuth2Token.mjs +242 -0
  57. package/dist/handlers/postOAuth2Token.mjs.map +1 -0
  58. package/dist/handlers/postOAuth2Token.test.d.ts +1 -0
  59. package/dist/handlers/postOAuth2Token.test.js +166 -0
  60. package/dist/handlers/postOAuth2Token.test.js.map +1 -0
  61. package/dist/handlers/postOAuth2Token.test.mjs +160 -0
  62. package/dist/handlers/postOAuth2Token.test.mjs.map +1 -0
  63. package/dist/index.d.ts +17 -0
  64. package/dist/index.js +230 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/index.mjs +15 -0
  67. package/dist/index.mjs.map +1 -0
  68. package/dist/index.test.d.ts +1 -0
  69. package/dist/index.test.js +759 -0
  70. package/dist/index.test.js.map +1 -0
  71. package/dist/index.test.mjs +748 -0
  72. package/dist/index.test.mjs.map +1 -0
  73. package/dist/services/authCookies.d.ts +26 -0
  74. package/dist/services/authCookies.js +74 -0
  75. package/dist/services/authCookies.js.map +1 -0
  76. package/dist/services/authCookies.mjs +58 -0
  77. package/dist/services/authCookies.mjs.map +1 -0
  78. package/dist/services/authCookies.test.d.ts +1 -0
  79. package/dist/services/authCookies.test.js +82 -0
  80. package/dist/services/authCookies.test.js.map +1 -0
  81. package/dist/services/authCookies.test.mjs +77 -0
  82. package/dist/services/authCookies.test.mjs.map +1 -0
  83. package/dist/services/oAuth2ClientCredentialsGranter.d.ts +17 -0
  84. package/dist/services/oAuth2ClientCredentialsGranter.js +56 -0
  85. package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -0
  86. package/dist/services/oAuth2ClientCredentialsGranter.mjs +41 -0
  87. package/dist/services/oAuth2ClientCredentialsGranter.mjs.map +1 -0
  88. package/dist/services/oAuth2CodeGranter.d.ts +17 -0
  89. package/dist/services/oAuth2CodeGranter.js +115 -0
  90. package/dist/services/oAuth2CodeGranter.js.map +1 -0
  91. package/dist/services/oAuth2CodeGranter.mjs +98 -0
  92. package/dist/services/oAuth2CodeGranter.mjs.map +1 -0
  93. package/dist/services/oAuth2CodeGranter.test.d.ts +1 -0
  94. package/dist/services/oAuth2CodeGranter.test.js +86 -0
  95. package/dist/services/oAuth2CodeGranter.test.js.map +1 -0
  96. package/dist/services/oAuth2CodeGranter.test.mjs +81 -0
  97. package/dist/services/oAuth2CodeGranter.test.mjs.map +1 -0
  98. package/dist/services/oAuth2Granters.d.ts +79 -0
  99. package/dist/services/oAuth2Granters.js +140 -0
  100. package/dist/services/oAuth2Granters.js.map +1 -0
  101. package/dist/services/oAuth2Granters.mjs +127 -0
  102. package/dist/services/oAuth2Granters.mjs.map +1 -0
  103. package/dist/services/oAuth2PasswordGranter.d.ts +16 -0
  104. package/dist/services/oAuth2PasswordGranter.js +55 -0
  105. package/dist/services/oAuth2PasswordGranter.js.map +1 -0
  106. package/dist/services/oAuth2PasswordGranter.mjs +40 -0
  107. package/dist/services/oAuth2PasswordGranter.mjs.map +1 -0
  108. package/dist/services/oAuth2RefreshTokenGranter.d.ts +15 -0
  109. package/dist/services/oAuth2RefreshTokenGranter.js +62 -0
  110. package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -0
  111. package/dist/services/oAuth2RefreshTokenGranter.mjs +47 -0
  112. package/dist/services/oAuth2RefreshTokenGranter.mjs.map +1 -0
  113. package/dist/services/oAuth2TokenGranter.d.ts +15 -0
  114. package/dist/services/oAuth2TokenGranter.js +92 -0
  115. package/dist/services/oAuth2TokenGranter.js.map +1 -0
  116. package/dist/services/oAuth2TokenGranter.mjs +78 -0
  117. package/dist/services/oAuth2TokenGranter.mjs.map +1 -0
  118. package/package.json +205 -0
  119. package/src/__snapshots__/index.test.ts.snap +396 -0
  120. package/src/handlers/__snapshots__/getOAuth2Authorize.test.ts.snap +38 -0
  121. package/src/handlers/__snapshots__/postOAuth2Acknowledge.test.ts.snap +61 -0
  122. package/src/handlers/__snapshots__/postOAuth2Token.test.ts.snap +52 -0
  123. package/src/handlers/getOAuth2Authorize.test.ts +142 -0
  124. package/src/handlers/getOAuth2Authorize.ts +222 -0
  125. package/src/handlers/postAuthLogin.test.ts +88 -0
  126. package/src/handlers/postAuthLogin.ts +123 -0
  127. package/src/handlers/postAuthLogout.test.ts +33 -0
  128. package/src/handlers/postAuthLogout.ts +38 -0
  129. package/src/handlers/postAuthRefresh.test.ts +97 -0
  130. package/src/handlers/postAuthRefresh.ts +146 -0
  131. package/src/handlers/postOAuth2Acknowledge.test.ts +175 -0
  132. package/src/handlers/postOAuth2Acknowledge.ts +209 -0
  133. package/src/handlers/postOAuth2Token.test.ts +153 -0
  134. package/src/handlers/postOAuth2Token.ts +302 -0
  135. package/src/index.test.ts +936 -0
  136. package/src/index.ts +105 -0
  137. package/src/services/__snapshots__/oAuth2CodeGranter.test.ts.snap +49 -0
  138. package/src/services/authCookies.test.ts +93 -0
  139. package/src/services/authCookies.ts +82 -0
  140. package/src/services/oAuth2ClientCredentialsGranter.ts +76 -0
  141. package/src/services/oAuth2CodeGranter.test.ts +94 -0
  142. package/src/services/oAuth2CodeGranter.ts +133 -0
  143. package/src/services/oAuth2Granters.ts +274 -0
  144. package/src/services/oAuth2PasswordGranter.ts +75 -0
  145. package/src/services/oAuth2RefreshTokenGranter.ts +77 -0
  146. package/src/services/oAuth2TokenGranter.ts +105 -0
@@ -0,0 +1,759 @@
1
+ "use strict";
2
+
3
+ var _whook = require("@whook/whook");
4
+
5
+ var _authorization = require("@whook/authorization");
6
+
7
+ var _knifecycle = require("knifecycle");
8
+
9
+ var _axios = _interopRequireDefault(require("axios"));
10
+
11
+ var _yerror = _interopRequireDefault(require("yerror"));
12
+
13
+ var _httpAuthUtils = require("http-auth-utils");
14
+
15
+ var _ = require(".");
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ describe('OAuth2 server', () => {
20
+ const BASE_PATH = '/v1';
21
+ const PORT = 4444;
22
+ const HOST = 'localhost';
23
+ const logger = {
24
+ info: jest.fn(),
25
+ error: jest.fn()
26
+ };
27
+ const debug = jest.fn();
28
+ const time = jest.fn();
29
+ const $autoload = jest.fn();
30
+ const API = {
31
+ openapi: '3.0.2',
32
+ info: {
33
+ version: '1.0.0',
34
+ title: 'Sample OpenAPI',
35
+ description: 'A sample OpenAPI file for testing purpose.'
36
+ },
37
+ paths: {
38
+ [_.getOAuth2AuthorizeDefinition.path]: {
39
+ [_.getOAuth2AuthorizeDefinition.method]: _.getOAuth2AuthorizeDefinition.operation
40
+ },
41
+ [_.postOAuth2AcknowledgeDefinition.path]: {
42
+ [_.postOAuth2AcknowledgeDefinition.method]: { ..._.postOAuth2AcknowledgeDefinition.operation,
43
+ security: [{
44
+ bearerAuth: ['user']
45
+ }]
46
+ }
47
+ },
48
+ [_.postOAuth2TokenDefinition.path]: {
49
+ [_.postOAuth2TokenDefinition.method]: { ..._.postOAuth2TokenDefinition.operation,
50
+ security: [{
51
+ basicAuth: ['oauth']
52
+ }]
53
+ }
54
+ }
55
+ },
56
+ components: {
57
+ securitySchemes: {
58
+ bearerAuth: {
59
+ type: 'http',
60
+ description: 'Bearer authentication with a user API token',
61
+ scheme: 'bearer'
62
+ },
63
+ basicAuth: {
64
+ type: 'http',
65
+ description: 'Basic authentication of an API client',
66
+ scheme: 'basic'
67
+ }
68
+ },
69
+ parameters: [_.getOAuth2AuthorizeResponseTypeParameter, _.getOAuth2AuthorizeClientIdParameter, _.getOAuth2AuthorizeRedirectURIParameter, _.getOAuth2AuthorizeScopeParameter, _.getOAuth2AuthorizeStateParameter].reduce((parametersHash, {
70
+ name,
71
+ parameter
72
+ }) => ({ ...parametersHash,
73
+ [name]: parameter
74
+ }), {}),
75
+ schemas: [_.postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, _.postOAuth2TokenPasswordTokenRequestBodySchema, _.postOAuth2TokenClientCredentialsTokenRequestBodySchema, _.postOAuth2TokenRefreshTokenRequestBodySchema, _.postOAuth2TokenTokenBodySchema].reduce((schemasHash, {
76
+ name,
77
+ schema
78
+ }) => ({ ...schemasHash,
79
+ [name]: schema
80
+ }), {})
81
+ }
82
+ };
83
+ const OAUTH2 = {
84
+ authenticateURL: 'https://auth.example.com/sign_in'
85
+ };
86
+ const authentication = {
87
+ check: jest.fn()
88
+ };
89
+ const checkApplication = jest.fn();
90
+ const oAuth2AccessToken = {
91
+ create: jest.fn(),
92
+ check: jest.fn()
93
+ };
94
+ const oAuth2RefreshToken = {
95
+ create: jest.fn(),
96
+ check: jest.fn()
97
+ };
98
+ const oAuth2ClientCredentials = {
99
+ check: jest.fn()
100
+ };
101
+ const oAuth2Code = {
102
+ create: jest.fn(),
103
+ check: jest.fn()
104
+ };
105
+ const oAuth2Password = {
106
+ check: jest.fn()
107
+ };
108
+ let $instance;
109
+
110
+ async function prepareEnvironment() {
111
+ const $ = await (0, _whook.prepareEnvironment)();
112
+ $.register((0, _knifecycle.initializer)({
113
+ name: '$autoload',
114
+ type: 'service',
115
+ singleton: true
116
+ }, async () => $autoload));
117
+ $.register((0, _knifecycle.constant)('BASE_PATH', BASE_PATH));
118
+ $.register((0, _knifecycle.constant)('API', API));
119
+ $.register((0, _knifecycle.constant)('ENV', {}));
120
+ $.register((0, _knifecycle.constant)('NODE_ENV', 'test'));
121
+ $.register((0, _knifecycle.constant)('PORT', PORT));
122
+ $.register((0, _knifecycle.constant)('HOST', HOST));
123
+ $.register((0, _knifecycle.constant)('DEBUG_NODE_ENVS', []));
124
+ $.register((0, _knifecycle.constant)('NODE_ENVS', ['test']));
125
+ $.register((0, _knifecycle.constant)('MECHANISMS', [_httpAuthUtils.BEARER, _httpAuthUtils.BASIC]));
126
+ $.register((0, _knifecycle.constant)('logger', logger));
127
+ $.register((0, _knifecycle.constant)('time', time));
128
+ $.register((0, _knifecycle.constant)('debug', debug)); // OAuth2 Specifics
129
+
130
+ $.register((0, _knifecycle.constant)('OAUTH2', OAUTH2));
131
+ $.register((0, _knifecycle.constant)('ERRORS_DESCRIPTORS', { ..._whook.DEFAULT_ERRORS_DESCRIPTORS,
132
+ ..._authorization.AUTHORIZATION_ERRORS_DESCRIPTORS,
133
+ ..._.OAUTH2_ERRORS_DESCRIPTORS
134
+ }));
135
+ $.register((0, _knifecycle.initializer)({
136
+ name: 'HANDLERS',
137
+ type: 'service',
138
+ inject: ['getOAuth2Authorize', 'postOAuth2Acknowledge', 'postOAuth2Token'],
139
+ singleton: true
140
+ }, async services => services));
141
+ $.register((0, _knifecycle.constant)('authentication', authentication));
142
+ $.register((0, _knifecycle.constant)('checkApplication', checkApplication));
143
+ $.register((0, _knifecycle.constant)('oAuth2AccessToken', oAuth2AccessToken));
144
+ $.register((0, _knifecycle.constant)('oAuth2RefreshToken', oAuth2RefreshToken));
145
+ $.register((0, _knifecycle.constant)('oAuth2ClientCredentials', oAuth2ClientCredentials));
146
+ $.register((0, _knifecycle.constant)('oAuth2Code', oAuth2Code));
147
+ $.register((0, _knifecycle.constant)('oAuth2Password', oAuth2Password));
148
+ [_.initGetOAuth2Authorize, (0, _authorization.wrapHandlerWithAuthorization)(_.initPostOAuth2Acknowledge), (0, _authorization.wrapHandlerWithAuthorization)(_.initPostOAuth2Token), _.initOAuth2Granters, _.initOAuth2ClientCredentialsGranter, _.initOAuth2CodeGranter, _.initOAuth2PasswordGranter, _.initOAuth2RefreshTokenGranter, _.initOAuth2TokenGranter].forEach(handlerInitializer => $.register(handlerInitializer));
149
+ return $;
150
+ }
151
+
152
+ $autoload.mockImplementation(async serviceName => {
153
+ throw new _yerror.default('E_UNMATCHED_DEPENDENCY', serviceName);
154
+ });
155
+ process.env.ISOLATED_ENV = '1';
156
+ beforeAll(async () => {
157
+ const {
158
+ $instance: _instance
159
+ } = await (0, _whook.runServer)(prepareEnvironment, _whook.prepareServer, ['$instance', 'httpServer', 'process']);
160
+ $instance = _instance;
161
+ });
162
+ afterAll(async () => {
163
+ await $instance.destroy();
164
+ });
165
+ beforeEach(() => {
166
+ logger.info.mockReset();
167
+ logger.error.mockReset();
168
+ debug.mockReset();
169
+ time.mockReset();
170
+ $autoload.mockClear();
171
+ [oAuth2AccessToken.create, oAuth2AccessToken.check, oAuth2RefreshToken.create, oAuth2RefreshToken.check, oAuth2ClientCredentials.check, oAuth2Code.check, oAuth2Code.create, oAuth2Password.check, checkApplication, authentication.check].forEach(mock => mock.mockReset());
172
+ });
173
+ describe('with the password flow', () => {
174
+ it('should produce new tokens', async () => {
175
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
176
+ [oAuth2AccessToken.check, oAuth2RefreshToken.check, oAuth2ClientCredentials.check, oAuth2Code.check, oAuth2Code.create, oAuth2RefreshToken.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
177
+ authentication.check.mockResolvedValueOnce({
178
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
179
+ scope: 'user,oauth'
180
+ });
181
+ checkApplication.mockResolvedValueOnce(undefined);
182
+ oAuth2Password.check.mockResolvedValueOnce({
183
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
184
+ scope: 'user,auth',
185
+ authentication: {
186
+ userId: 1
187
+ }
188
+ });
189
+ oAuth2AccessToken.create.mockResolvedValueOnce({
190
+ token: 'an_access_token',
191
+ expiresAt: Date.parse('2010-03-07T00:00:00Z')
192
+ });
193
+ oAuth2RefreshToken.create.mockResolvedValueOnce({
194
+ token: 'a_refresh_token',
195
+ expiresAt: Date.parse('2180-03-06T00:00:00Z')
196
+ });
197
+ const {
198
+ status,
199
+ headers,
200
+ data
201
+ } = await (0, _axios.default)({
202
+ method: 'post',
203
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2TokenDefinition.path}`,
204
+ headers: {
205
+ authorization: `basic ${Buffer.from('ali:open_sesame').toString('base64')}`
206
+ },
207
+ data: {
208
+ grant_type: 'password',
209
+ username: 'me@example.com',
210
+ password: 'udelawli',
211
+ scope: 'user'
212
+ },
213
+ validateStatus: () => true
214
+ });
215
+ expect({
216
+ status,
217
+ headers: { ...headers,
218
+ // Erasing the Date header that may be added by Axios :/
219
+ date: undefined
220
+ },
221
+ data
222
+ }).toMatchInlineSnapshot(`
223
+ Object {
224
+ "data": Object {
225
+ "access_token": "an_access_token",
226
+ "expiration_date": "2010-03-07T00:00:00.000Z",
227
+ "expires_in": 86400,
228
+ "refresh_token": "a_refresh_token",
229
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
230
+ "refresh_token_expires_in": 5364748800,
231
+ "token_type": "bearer",
232
+ },
233
+ "headers": Object {
234
+ "connection": "close",
235
+ "content-type": "application/json",
236
+ "date": undefined,
237
+ "transaction-id": "0",
238
+ "transfer-encoding": "chunked",
239
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
240
+ },
241
+ "status": 200,
242
+ }
243
+ `);
244
+ expect({
245
+ checkApplicationCalls: checkApplication.mock.calls,
246
+ authenticationCheckCalls: authentication.check.mock.calls,
247
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
248
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
249
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
250
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
251
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
252
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
253
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
254
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
255
+ }).toMatchSnapshot();
256
+ });
257
+ });
258
+ describe('with the refresh token flow', () => {
259
+ it('should produce new tokens', async () => {
260
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
261
+ [oAuth2AccessToken.check, oAuth2ClientCredentials.check, oAuth2Code.check, oAuth2Code.create, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
262
+ authentication.check.mockResolvedValueOnce({
263
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
264
+ scope: 'user,oauth'
265
+ });
266
+ checkApplication.mockResolvedValueOnce(undefined);
267
+ oAuth2RefreshToken.check.mockResolvedValueOnce({
268
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
269
+ scope: 'user,auth',
270
+ authentication: {
271
+ userId: 1
272
+ }
273
+ });
274
+ oAuth2AccessToken.create.mockResolvedValueOnce({
275
+ token: 'an_access_token',
276
+ expiresAt: Date.parse('2010-03-07T00:00:00Z')
277
+ });
278
+ oAuth2RefreshToken.create.mockResolvedValueOnce({
279
+ token: 'a_refresh_token',
280
+ expiresAt: Date.parse('2180-03-06T00:00:00Z')
281
+ });
282
+ const {
283
+ status,
284
+ headers,
285
+ data
286
+ } = await (0, _axios.default)({
287
+ method: 'post',
288
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2TokenDefinition.path}`,
289
+ headers: {
290
+ authorization: `basic ${Buffer.from('ali:open_sesame').toString('base64')}`
291
+ },
292
+ data: {
293
+ grant_type: 'refresh_token',
294
+ refresh_token: 'a_refresh_token',
295
+ scope: 'user'
296
+ },
297
+ validateStatus: () => true
298
+ });
299
+ expect({
300
+ status,
301
+ headers: { ...headers,
302
+ // Erasing the Date header that may be added by Axios :/
303
+ date: undefined
304
+ },
305
+ data
306
+ }).toMatchInlineSnapshot(`
307
+ Object {
308
+ "data": Object {
309
+ "access_token": "an_access_token",
310
+ "expiration_date": "2010-03-07T00:00:00.000Z",
311
+ "expires_in": 86400,
312
+ "refresh_token": "a_refresh_token",
313
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
314
+ "refresh_token_expires_in": 5364748800,
315
+ "token_type": "bearer",
316
+ },
317
+ "headers": Object {
318
+ "connection": "close",
319
+ "content-type": "application/json",
320
+ "date": undefined,
321
+ "transaction-id": "1",
322
+ "transfer-encoding": "chunked",
323
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
324
+ },
325
+ "status": 200,
326
+ }
327
+ `);
328
+ expect({
329
+ checkApplicationCalls: checkApplication.mock.calls,
330
+ authenticationCheckCalls: authentication.check.mock.calls,
331
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
332
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
333
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
334
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
335
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
336
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
337
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
338
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
339
+ }).toMatchSnapshot();
340
+ });
341
+ });
342
+ describe('with the client credentials flow', () => {
343
+ it('should produce new tokens', async () => {
344
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
345
+ [oAuth2AccessToken.check, oAuth2RefreshToken.check, oAuth2Code.check, oAuth2Code.create, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
346
+ authentication.check.mockResolvedValueOnce({
347
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
348
+ scope: 'user,oauth'
349
+ });
350
+ checkApplication.mockResolvedValueOnce(undefined);
351
+ oAuth2ClientCredentials.check.mockResolvedValueOnce({
352
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
353
+ scope: 'user,auth',
354
+ authentication: {
355
+ userId: 1
356
+ }
357
+ });
358
+ oAuth2AccessToken.create.mockResolvedValueOnce({
359
+ token: 'an_access_token',
360
+ expiresAt: Date.parse('2010-03-07T00:00:00Z')
361
+ });
362
+ oAuth2RefreshToken.create.mockResolvedValueOnce({
363
+ token: 'a_refresh_token',
364
+ expiresAt: Date.parse('2180-03-06T00:00:00Z')
365
+ });
366
+ const {
367
+ status,
368
+ headers,
369
+ data
370
+ } = await (0, _axios.default)({
371
+ method: 'post',
372
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2TokenDefinition.path}`,
373
+ headers: {
374
+ authorization: `basic ${Buffer.from('ali:open_sesame').toString('base64')}`
375
+ },
376
+ data: {
377
+ grant_type: 'client_credentials',
378
+ scope: 'user'
379
+ },
380
+ validateStatus: () => true
381
+ });
382
+ expect({
383
+ status,
384
+ headers: { ...headers,
385
+ // Erasing the Date header that may be added by Axios :/
386
+ date: undefined
387
+ },
388
+ data
389
+ }).toMatchInlineSnapshot(`
390
+ Object {
391
+ "data": Object {
392
+ "access_token": "an_access_token",
393
+ "expiration_date": "2010-03-07T00:00:00.000Z",
394
+ "expires_in": 86400,
395
+ "refresh_token": "a_refresh_token",
396
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
397
+ "refresh_token_expires_in": 5364748800,
398
+ "token_type": "bearer",
399
+ },
400
+ "headers": Object {
401
+ "connection": "close",
402
+ "content-type": "application/json",
403
+ "date": undefined,
404
+ "transaction-id": "2",
405
+ "transfer-encoding": "chunked",
406
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
407
+ },
408
+ "status": 200,
409
+ }
410
+ `);
411
+ expect({
412
+ checkApplicationCalls: checkApplication.mock.calls,
413
+ authenticationCheckCalls: authentication.check.mock.calls,
414
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
415
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
416
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
417
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
418
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
419
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
420
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
421
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
422
+ }).toMatchSnapshot();
423
+ });
424
+ });
425
+ describe('with the code flow', () => {
426
+ it('should build the authorization redirection', async () => {
427
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
428
+ [authentication.check, oAuth2AccessToken.check, oAuth2AccessToken.create, oAuth2RefreshToken.check, oAuth2RefreshToken.create, oAuth2Code.check, oAuth2Code.create, oAuth2ClientCredentials.check, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
429
+ checkApplication.mockResolvedValueOnce({
430
+ redirectURI: 'https://example.com/oauth2/callback?a_param=a_param_value'
431
+ });
432
+ const {
433
+ status,
434
+ headers,
435
+ data
436
+ } = await (0, _axios.default)({
437
+ method: 'get',
438
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.getOAuth2AuthorizeDefinition.path}`,
439
+ params: {
440
+ response_type: 'code',
441
+ client_id: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
442
+ redirect_uri: 'https://example.com/oauth2/callback?a_param=a_param_value',
443
+ scope: 'user',
444
+ state: 'xyz'
445
+ },
446
+ maxRedirects: 0,
447
+ validateStatus: () => true
448
+ });
449
+ expect({
450
+ status,
451
+ headers: { ...headers,
452
+ // Erasing the Date header that may be added by Axios :/
453
+ date: undefined
454
+ },
455
+ data
456
+ }).toMatchInlineSnapshot(`
457
+ Object {
458
+ "data": "",
459
+ "headers": Object {
460
+ "connection": "close",
461
+ "date": undefined,
462
+ "location": "https://auth.example.com/sign_in?type=code&redirect_uri=https%3A%2F%2Fexample.com%2Foauth2%2Fcallback%3Fa_param%3Da_param_value&scope=user&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&state=xyz",
463
+ "transaction-id": "3",
464
+ "transfer-encoding": "chunked",
465
+ },
466
+ "status": 302,
467
+ }
468
+ `);
469
+ expect({
470
+ checkApplicationCalls: checkApplication.mock.calls,
471
+ authenticationCheckCalls: authentication.check.mock.calls,
472
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
473
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
474
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
475
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
476
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
477
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
478
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
479
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
480
+ }).toMatchSnapshot();
481
+ });
482
+ it('should redirect with a code', async () => {
483
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
484
+ [oAuth2AccessToken.check, oAuth2AccessToken.create, oAuth2RefreshToken.check, oAuth2RefreshToken.create, oAuth2Code.check, oAuth2ClientCredentials.check, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
485
+ authentication.check.mockResolvedValueOnce({
486
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
487
+ scope: 'user,oauth'
488
+ });
489
+ oAuth2Code.create.mockResolvedValueOnce('a_code');
490
+ checkApplication.mockResolvedValueOnce(undefined);
491
+ checkApplication.mockResolvedValueOnce({
492
+ redirectURI: 'http://redirect.example.com/yolo'
493
+ });
494
+ const {
495
+ status,
496
+ headers,
497
+ data
498
+ } = await (0, _axios.default)({
499
+ method: 'post',
500
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2AcknowledgeDefinition.path}`,
501
+ headers: {
502
+ authorization: 'Bearer yolo'
503
+ },
504
+ data: {
505
+ responseType: 'code',
506
+ clientId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
507
+ redirectURI: 'http://redirect.example.com/yolo?a_param=a_value',
508
+ scope: 'user',
509
+ state: 'xyz',
510
+ acknowledged: true
511
+ },
512
+ maxRedirects: 0,
513
+ validateStatus: () => true
514
+ });
515
+ expect({
516
+ status,
517
+ headers: { ...headers,
518
+ // Erasing the Date header that may be added by Axios :/
519
+ date: undefined
520
+ },
521
+ data
522
+ }).toMatchInlineSnapshot(`
523
+ Object {
524
+ "data": "",
525
+ "headers": Object {
526
+ "connection": "close",
527
+ "date": undefined,
528
+ "location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo%3Fa_param%3Da_value&code=a_code",
529
+ "transaction-id": "4",
530
+ "transfer-encoding": "chunked",
531
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
532
+ },
533
+ "status": 302,
534
+ }
535
+ `);
536
+ expect({
537
+ checkApplicationCalls: checkApplication.mock.calls,
538
+ authenticationCheckCalls: authentication.check.mock.calls,
539
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
540
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
541
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
542
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
543
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
544
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
545
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
546
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
547
+ }).toMatchSnapshot();
548
+ });
549
+ it('should produce new tokens', async () => {
550
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
551
+ [oAuth2AccessToken.check, oAuth2RefreshToken.check, oAuth2ClientCredentials.check, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
552
+ authentication.check.mockResolvedValueOnce({
553
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
554
+ scope: 'user,oauth'
555
+ });
556
+ checkApplication.mockResolvedValueOnce(undefined);
557
+ oAuth2Code.check.mockResolvedValueOnce({
558
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
559
+ scope: 'user,auth',
560
+ userId: 1
561
+ });
562
+ oAuth2AccessToken.create.mockResolvedValueOnce({
563
+ token: 'an_access_token',
564
+ expiresAt: Date.parse('2010-03-07T00:00:00Z')
565
+ });
566
+ oAuth2RefreshToken.create.mockResolvedValueOnce({
567
+ token: 'a_refresh_token',
568
+ expiresAt: Date.parse('2180-03-06T00:00:00Z')
569
+ });
570
+ const {
571
+ status,
572
+ headers,
573
+ data
574
+ } = await (0, _axios.default)({
575
+ method: 'post',
576
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2TokenDefinition.path}`,
577
+ headers: {
578
+ authorization: `basic ${Buffer.from('ali:open_sesame').toString('base64')}`
579
+ },
580
+ data: {
581
+ grant_type: 'authorization_code',
582
+ code: 'a_grant_code',
583
+ redirect_uri: 'http://redirect.example.com/yolo'
584
+ },
585
+ validateStatus: () => true
586
+ });
587
+ expect({
588
+ status,
589
+ headers: { ...headers,
590
+ // Erasing the Date header that may be added by Axios :/
591
+ date: undefined
592
+ },
593
+ data
594
+ }).toMatchInlineSnapshot(`
595
+ Object {
596
+ "data": Object {
597
+ "access_token": "an_access_token",
598
+ "expiration_date": "2010-03-07T00:00:00.000Z",
599
+ "expires_in": 86400,
600
+ "refresh_token": "a_refresh_token",
601
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
602
+ "refresh_token_expires_in": 5364748800,
603
+ "token_type": "bearer",
604
+ },
605
+ "headers": Object {
606
+ "connection": "close",
607
+ "content-type": "application/json",
608
+ "date": undefined,
609
+ "transaction-id": "5",
610
+ "transfer-encoding": "chunked",
611
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
612
+ },
613
+ "status": 200,
614
+ }
615
+ `);
616
+ expect({
617
+ checkApplicationCalls: checkApplication.mock.calls,
618
+ authenticationCheckCalls: authentication.check.mock.calls,
619
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
620
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
621
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
622
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
623
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
624
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
625
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
626
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
627
+ }).toMatchSnapshot();
628
+ });
629
+ });
630
+ describe('with the implicit flow', () => {
631
+ it('should build the authorization redirection', async () => {
632
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
633
+ [authentication.check, oAuth2AccessToken.check, oAuth2AccessToken.create, oAuth2RefreshToken.check, oAuth2RefreshToken.create, oAuth2Code.check, oAuth2Code.create, oAuth2ClientCredentials.check, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
634
+ checkApplication.mockResolvedValueOnce({
635
+ redirectURI: 'http://redirect.example.com/yolo'
636
+ });
637
+ const {
638
+ status,
639
+ headers,
640
+ data
641
+ } = await (0, _axios.default)({
642
+ method: 'get',
643
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.getOAuth2AuthorizeDefinition.path}`,
644
+ params: {
645
+ response_type: 'token',
646
+ client_id: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
647
+ redirect_uri: 'http://redirect.example.com/yolo',
648
+ scope: 'user',
649
+ state: 'xyz'
650
+ },
651
+ maxRedirects: 0,
652
+ validateStatus: () => true
653
+ });
654
+ expect({
655
+ status,
656
+ headers: { ...headers,
657
+ // Erasing the Date header that may be added by Axios :/
658
+ date: undefined
659
+ },
660
+ data
661
+ }).toMatchInlineSnapshot(`
662
+ Object {
663
+ "data": "",
664
+ "headers": Object {
665
+ "connection": "close",
666
+ "date": undefined,
667
+ "location": "https://auth.example.com/sign_in?type=token&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo&scope=user&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&state=xyz",
668
+ "transaction-id": "6",
669
+ "transfer-encoding": "chunked",
670
+ },
671
+ "status": 302,
672
+ }
673
+ `);
674
+ expect({
675
+ checkApplicationCalls: checkApplication.mock.calls,
676
+ authenticationCheckCalls: authentication.check.mock.calls,
677
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
678
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
679
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
680
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
681
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
682
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
683
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
684
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
685
+ }).toMatchSnapshot();
686
+ });
687
+ it('should redirect with a token', async () => {
688
+ time.mockReturnValue(Date.parse('2010-03-06T00:00:00Z'));
689
+ [oAuth2AccessToken.check, oAuth2RefreshToken.check, oAuth2RefreshToken.create, oAuth2Code.check, oAuth2Code.create, oAuth2ClientCredentials.check, oAuth2Password.check].forEach(mock => mock.mockRejectedValueOnce(new _yerror.default('E_NOT_SUPPOSED_TO_BE_HERE')));
690
+ authentication.check.mockResolvedValueOnce({
691
+ applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
692
+ scope: 'user,oauth'
693
+ });
694
+ oAuth2AccessToken.create.mockResolvedValueOnce({
695
+ token: 'an_access_token',
696
+ expiresAt: Date.parse('2010-03-07T00:00:00Z')
697
+ });
698
+ checkApplication.mockResolvedValueOnce(undefined);
699
+ checkApplication.mockResolvedValueOnce({
700
+ redirectURI: 'http://redirect.example.com/yolo'
701
+ });
702
+ const {
703
+ status,
704
+ headers,
705
+ data
706
+ } = await (0, _axios.default)({
707
+ method: 'post',
708
+ url: `http://${HOST}:${PORT}${BASE_PATH}${_.postOAuth2AcknowledgeDefinition.path}`,
709
+ headers: {
710
+ authorization: 'Bearer yolo'
711
+ },
712
+ data: {
713
+ responseType: 'token',
714
+ clientId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
715
+ redirectURI: 'http://redirect.example.com/yolo?a_param=a_value',
716
+ scope: 'user',
717
+ state: 'xyz',
718
+ acknowledged: true
719
+ },
720
+ maxRedirects: 0,
721
+ validateStatus: () => true
722
+ });
723
+ expect({
724
+ status,
725
+ headers: { ...headers,
726
+ // Erasing the Date header that may be added by Axios :/
727
+ date: undefined
728
+ },
729
+ data
730
+ }).toMatchInlineSnapshot(`
731
+ Object {
732
+ "data": "",
733
+ "headers": Object {
734
+ "connection": "close",
735
+ "date": undefined,
736
+ "location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo&access_token=an_access_token&token_type=bearer&expires_in=86400",
737
+ "transaction-id": "7",
738
+ "transfer-encoding": "chunked",
739
+ "x-authenticated": "{\\"applicationId\\":\\"acdc41ce-acdc-41ce-acdc-41ceacdc41ce\\",\\"scope\\":\\"user,oauth\\"}",
740
+ },
741
+ "status": 302,
742
+ }
743
+ `);
744
+ expect({
745
+ checkApplicationCalls: checkApplication.mock.calls,
746
+ authenticationCheckCalls: authentication.check.mock.calls,
747
+ oAuth2AccessTokenCreateCalls: oAuth2AccessToken.create.mock.calls,
748
+ oAuth2AccessTokenCheckCalls: oAuth2AccessToken.check.mock.calls,
749
+ oAuth2RefreshTokenCreateCalls: oAuth2RefreshToken.create.mock.calls,
750
+ oAuth2RefreshTokenCheckCalls: oAuth2RefreshToken.check.mock.calls,
751
+ oAuth2ClientCredentialsCheckCalls: oAuth2ClientCredentials.check.mock.calls,
752
+ oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,
753
+ oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,
754
+ oAuth2PasswordCheckCalls: oAuth2Password.check.mock.calls
755
+ }).toMatchSnapshot();
756
+ });
757
+ });
758
+ });
759
+ //# sourceMappingURL=index.test.js.map