Skip to content

Commit aa1ca18

Browse files
committed
test: validateSsoProfile.spec.ts
1 parent 528a104 commit aa1ca18

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { CredentialsProviderError } from "@aws-sdk/property-provider";
2+
3+
import { validateSsoProfile } from "./validateSsoProfile";
4+
5+
describe(validateSsoProfile.name, () => {
6+
const getMockSsoProfile = () => ({
7+
sso_start_url: "mock_sso_start_url",
8+
sso_account_id: "mock_sso_account_id",
9+
sso_region: "mock_sso_region",
10+
sso_role_name: "mock_sso_role_name",
11+
});
12+
13+
it("returns if values all required sso values are available", () => {
14+
const profileToVerify = getMockSsoProfile();
15+
const profileVerified = validateSsoProfile(profileToVerify);
16+
expect(profileVerified).toStrictEqual(profileToVerify);
17+
});
18+
19+
it.each(["sso_start_url", "sso_account_id", "sso_region", "sso_role_name"])(
20+
"throws is '%s' is missing from profile",
21+
(key) => {
22+
const profileToVerify = getMockSsoProfile();
23+
delete profileToVerify[key];
24+
25+
expect(() => {
26+
validateSsoProfile(profileToVerify);
27+
}).toThrowError(
28+
new CredentialsProviderError(
29+
`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", ` +
30+
`"sso_role_name", "sso_start_url". Got ${Object.keys(profileToVerify).join(
31+
", "
32+
)}\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,
33+
false
34+
)
35+
);
36+
}
37+
);
38+
});

0 commit comments

Comments
 (0)