-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathauthorize.spec.ts
38 lines (35 loc) · 1.42 KB
/
authorize.spec.ts
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
import { describe, expect, test } from "vitest";
import ReusableRestClient from "./reusable-rest-client";
describe("authorize", () => {
test("password flow", async () => {
// because password flow is deprecated, we don't test it
// const rc = new RingCentral({
// clientId: process.env.RINGCENTRAL_CLIENT_ID!,
// clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET!,
// server: process.env.RINGCENTRAL_SERVER_URL!,
// });
// const tokenInfo = await rc.login({
// username: process.env.RINGCENTRAL_USERNAME!,
// extension: process.env.RINGCENTRAL_EXTENSION!,
// password: process.env.RINGCENTRAL_PASSWORD!,
// });
// expect(tokenInfo).not.toBeUndefined();
// expect(tokenInfo.access_token).not.toBeUndefined();
// await rc.revoke();
});
test("refresh", async () => {
const rc = await ReusableRestClient.getInstance();
const tokenInfo = rc.token!;
const newTokenInfo = await rc.refresh();
expect(newTokenInfo).not.toBeUndefined();
expect(newTokenInfo.access_token).not.toBeUndefined();
expect(newTokenInfo.access_token).not.toEqual(tokenInfo.access_token);
});
// we don't test it any more becaue we need the token for other tests
// test('revoke', async () => {
// const rc = await ReusableRestClient.getInstance();
// expect(rc.token).not.toBeUndefined();
// await rc.revoke();
// expect(rc.token).toBeUndefined();
// });
});