forked from mhlabs/aws-sdk-sso
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-ts.test.ts
33 lines (31 loc) · 1.31 KB
/
test-ts.test.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
import AWS from "aws-sdk";
import "./index";
import { SingleSignOnCredentials } from "aws-sdk";
describe("TypeScript Test with SingleSignOnCredentials", () => {
test("TypeScript Static Definitions", async () => {
expect(AWS).toHaveProperty("SingleSignOnCredentials");
const sso = new AWS.SingleSignOnCredentials();
expect(sso).toBeDefined();
expect(sso).toHaveProperty("expired");
expect(sso).toHaveProperty("accessKeyId");
expect(sso.accessKeyId).toBeUndefined();
expect(sso).toHaveProperty("sessionToken");
expect(sso.sessionToken).toBeUndefined();
await sso.refreshPromise();
expect(sso).toHaveProperty("accessKeyId");
expect(sso.accessKeyId).toBeDefined();
expect(sso).toHaveProperty("sessionToken");
expect(sso.sessionToken).toBeDefined();
});
test("STS GetCallerIdentity", async () => {
AWS.config.update({ credentials: new AWS.SingleSignOnCredentials() });
const sts = new AWS.STS();
const callerIdentity = await sts.getCallerIdentity().promise();
expect(callerIdentity).toBeDefined();
expect(callerIdentity).toHaveProperty("Arn");
expect(callerIdentity.Arn).toBeDefined();
expect(callerIdentity).toHaveProperty("Account");
expect(callerIdentity.Account).toBeDefined();
expect(/^arn:aws:sts::/.test(callerIdentity.Arn)).toBe(true);
});
});