Skip to content

Commit 8035781

Browse files
committed
Add constants for tests
1 parent 946ef73 commit 8035781

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/auth/src/core/auth/auth_impl.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,10 @@ describe('core/auth/auth_impl', () => {
796796
const TEST_SCHEMA_VERSION = 1;
797797
const TEST_UNSUPPORTED_SCHEMA_VERSION = 0;
798798

799+
const TEST_TENANT_ID = 'tenant-id';
800+
const TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION =
801+
'tenant-id-with-unsupported-policy-version';
802+
799803
const passwordPolicyResponse: GetPasswordPolicyResponse = {
800804
customStrengthOptions: {
801805
minPasswordLength: TEST_MIN_PASSWORD_LENGTH,
@@ -842,14 +846,14 @@ describe('core/auth/auth_impl', () => {
842846
mockEndpointWithParams(
843847
Endpoint.GET_PASSWORD_POLICY,
844848
{
845-
tenantId: 'tenant-id'
849+
tenantId: TEST_TENANT_ID
846850
},
847851
passwordPolicyResponseRequireNumeric
848852
);
849853
mockEndpointWithParams(
850854
Endpoint.GET_PASSWORD_POLICY,
851855
{
852-
tenantId: 'tenant-id-with-unsupported-policy-version'
856+
tenantId: TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION
853857
},
854858
passwordPolicyResponseUnsupportedVersion
855859
);
@@ -869,7 +873,7 @@ describe('core/auth/auth_impl', () => {
869873

870874
it('password policy should be set for tenant if tenant ID is not null', async () => {
871875
auth = await testAuth();
872-
auth.tenantId = 'tenant-id';
876+
auth.tenantId = TEST_TENANT_ID;
873877
await auth._updatePasswordPolicy();
874878

875879
expect(auth._getPasswordPolicy()).to.eql(
@@ -882,12 +886,12 @@ describe('core/auth/auth_impl', () => {
882886
auth.tenantId = null;
883887
await auth._updatePasswordPolicy();
884888

885-
auth.tenantId = 'tenant-id';
889+
auth.tenantId = TEST_TENANT_ID;
886890
await auth._updatePasswordPolicy();
887891

888892
auth.tenantId = null;
889893
expect(auth._getPasswordPolicy()).to.eql(cachedPasswordPolicy);
890-
auth.tenantId = 'tenant-id';
894+
auth.tenantId = TEST_TENANT_ID;
891895
expect(auth._getPasswordPolicy()).to.eql(
892896
cachedPasswordPolicyRequireNumeric
893897
);
@@ -897,7 +901,7 @@ describe('core/auth/auth_impl', () => {
897901

898902
it('password policy should still be set when the schema version is not supported', async () => {
899903
auth = await testAuth();
900-
auth.tenantId = 'tenant-id-with-unsupported-policy-version';
904+
auth.tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION;
901905
await auth._updatePasswordPolicy();
902906

903907
expect(auth._getPasswordPolicy()).to.eql(
@@ -948,7 +952,7 @@ describe('core/auth/auth_impl', () => {
948952
};
949953

950954
auth = await testAuth();
951-
auth.tenantId = 'tenant-id';
955+
auth.tenantId = TEST_TENANT_ID;
952956
const status = await auth.validatePassword('passw0rd!');
953957
expect(status).to.eql(expectedValidationStatus);
954958
});
@@ -965,7 +969,7 @@ describe('core/auth/auth_impl', () => {
965969
};
966970

967971
auth = await testAuth();
968-
auth.tenantId = 'tenant-id';
972+
auth.tenantId = TEST_TENANT_ID;
969973
const status = await auth.validatePassword('password01234');
970974
expect(status).to.eql(expectedValidationStatus);
971975
});
@@ -995,22 +999,22 @@ describe('core/auth/auth_impl', () => {
995999
passwordPolicy: cachedPasswordPolicyRequireNumeric
9961000
};
9971001

998-
auth.tenantId = 'tenant-id';
1002+
auth.tenantId = TEST_TENANT_ID;
9991003
status = await auth.validatePassword('password!');
10001004
expect(status).to.eql(expectedValidationStatus);
10011005
});
10021006

10031007
it('should throw an error when a password policy with an unsupported schema version is received', async () => {
10041008
auth = await testAuth();
1005-
auth.tenantId = 'tenant-id-with-unsupported-policy-version';
1009+
auth.tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION;
10061010
await expect(auth.validatePassword('password')).to.be.rejectedWith(
10071011
AuthErrorCode.UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION
10081012
);
10091013
});
10101014

10111015
it('should throw an error when a password policy with an unsupported schema version is already cached', async () => {
10121016
auth = await testAuth();
1013-
auth.tenantId = 'tenant-id-with-unsupported-policy-version';
1017+
auth.tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION;
10141018
await auth._updatePasswordPolicy();
10151019
await expect(auth.validatePassword('password')).to.be.rejectedWith(
10161020
AuthErrorCode.UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION

0 commit comments

Comments
 (0)