-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathauthorization_code_test.ts
More file actions
55 lines (51 loc) · 1.41 KB
/
authorization_code_test.ts
File metadata and controls
55 lines (51 loc) · 1.41 KB
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
import {
assert,
assertEquals,
assertStrictEquals,
describe,
FakeTime,
it,
v4,
} from "../test_deps.ts";
import {
AuthorizationCodeService,
client,
scope,
user,
} from "./test_services.ts";
const authorizationCodeService = new AuthorizationCodeService();
const authorizationCodeServiceTests = describe("AuthorizationCodeService");
it(authorizationCodeServiceTests, "generateAuthorizationCode", async () => {
const result = authorizationCodeService.generateCode(
client,
user,
scope,
);
assertStrictEquals(Promise.resolve(result), result);
assert(v4.validate(await result));
assert(
v4.validate(
await authorizationCodeService.generateCode(client, user, scope),
),
);
});
it(authorizationCodeServiceTests, "accessTokenExpiresAt", async () => {
const time: FakeTime = new FakeTime();
try {
const fiveMinutes: number = 5 * 60 * 1000;
const result = authorizationCodeService.expiresAt(client, user, scope);
assertStrictEquals(Promise.resolve(result), result);
assertEquals(await result, new Date(Date.now() + fiveMinutes));
assertEquals(
await authorizationCodeService.expiresAt(client, user, scope),
new Date(Date.now() + fiveMinutes),
);
time.tick(1234);
assertEquals(
await authorizationCodeService.expiresAt(client, user, scope),
new Date(Date.now() + fiveMinutes),
);
} finally {
time.restore();
}
});