@@ -796,6 +796,10 @@ describe('core/auth/auth_impl', () => {
796
796
const TEST_SCHEMA_VERSION = 1 ;
797
797
const TEST_UNSUPPORTED_SCHEMA_VERSION = 0 ;
798
798
799
+ const TEST_TENANT_ID = 'tenant-id' ;
800
+ const TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION =
801
+ 'tenant-id-with-unsupported-policy-version' ;
802
+
799
803
const passwordPolicyResponse : GetPasswordPolicyResponse = {
800
804
customStrengthOptions : {
801
805
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
@@ -842,14 +846,14 @@ describe('core/auth/auth_impl', () => {
842
846
mockEndpointWithParams (
843
847
Endpoint . GET_PASSWORD_POLICY ,
844
848
{
845
- tenantId : 'tenant-id'
849
+ tenantId : TEST_TENANT_ID
846
850
} ,
847
851
passwordPolicyResponseRequireNumeric
848
852
) ;
849
853
mockEndpointWithParams (
850
854
Endpoint . GET_PASSWORD_POLICY ,
851
855
{
852
- tenantId : 'tenant-id-with-unsupported-policy-version'
856
+ tenantId : TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION
853
857
} ,
854
858
passwordPolicyResponseUnsupportedVersion
855
859
) ;
@@ -869,7 +873,7 @@ describe('core/auth/auth_impl', () => {
869
873
870
874
it ( 'password policy should be set for tenant if tenant ID is not null' , async ( ) => {
871
875
auth = await testAuth ( ) ;
872
- auth . tenantId = 'tenant-id' ;
876
+ auth . tenantId = TEST_TENANT_ID ;
873
877
await auth . _updatePasswordPolicy ( ) ;
874
878
875
879
expect ( auth . _getPasswordPolicy ( ) ) . to . eql (
@@ -882,12 +886,12 @@ describe('core/auth/auth_impl', () => {
882
886
auth . tenantId = null ;
883
887
await auth . _updatePasswordPolicy ( ) ;
884
888
885
- auth . tenantId = 'tenant-id' ;
889
+ auth . tenantId = TEST_TENANT_ID ;
886
890
await auth . _updatePasswordPolicy ( ) ;
887
891
888
892
auth . tenantId = null ;
889
893
expect ( auth . _getPasswordPolicy ( ) ) . to . eql ( cachedPasswordPolicy ) ;
890
- auth . tenantId = 'tenant-id' ;
894
+ auth . tenantId = TEST_TENANT_ID ;
891
895
expect ( auth . _getPasswordPolicy ( ) ) . to . eql (
892
896
cachedPasswordPolicyRequireNumeric
893
897
) ;
@@ -897,7 +901,7 @@ describe('core/auth/auth_impl', () => {
897
901
898
902
it ( 'password policy should still be set when the schema version is not supported' , async ( ) => {
899
903
auth = await testAuth ( ) ;
900
- auth . tenantId = 'tenant-id-with-unsupported-policy-version' ;
904
+ auth . tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION ;
901
905
await auth . _updatePasswordPolicy ( ) ;
902
906
903
907
expect ( auth . _getPasswordPolicy ( ) ) . to . eql (
@@ -948,7 +952,7 @@ describe('core/auth/auth_impl', () => {
948
952
} ;
949
953
950
954
auth = await testAuth ( ) ;
951
- auth . tenantId = 'tenant-id' ;
955
+ auth . tenantId = TEST_TENANT_ID ;
952
956
const status = await auth . validatePassword ( 'passw0rd!' ) ;
953
957
expect ( status ) . to . eql ( expectedValidationStatus ) ;
954
958
} ) ;
@@ -965,7 +969,7 @@ describe('core/auth/auth_impl', () => {
965
969
} ;
966
970
967
971
auth = await testAuth ( ) ;
968
- auth . tenantId = 'tenant-id' ;
972
+ auth . tenantId = TEST_TENANT_ID ;
969
973
const status = await auth . validatePassword ( 'password01234' ) ;
970
974
expect ( status ) . to . eql ( expectedValidationStatus ) ;
971
975
} ) ;
@@ -995,22 +999,22 @@ describe('core/auth/auth_impl', () => {
995
999
passwordPolicy : cachedPasswordPolicyRequireNumeric
996
1000
} ;
997
1001
998
- auth . tenantId = 'tenant-id' ;
1002
+ auth . tenantId = TEST_TENANT_ID ;
999
1003
status = await auth . validatePassword ( 'password!' ) ;
1000
1004
expect ( status ) . to . eql ( expectedValidationStatus ) ;
1001
1005
} ) ;
1002
1006
1003
1007
it ( 'should throw an error when a password policy with an unsupported schema version is received' , async ( ) => {
1004
1008
auth = await testAuth ( ) ;
1005
- auth . tenantId = 'tenant-id-with-unsupported-policy-version' ;
1009
+ auth . tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION ;
1006
1010
await expect ( auth . validatePassword ( 'password' ) ) . to . be . rejectedWith (
1007
1011
AuthErrorCode . UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION
1008
1012
) ;
1009
1013
} ) ;
1010
1014
1011
1015
it ( 'should throw an error when a password policy with an unsupported schema version is already cached' , async ( ) => {
1012
1016
auth = await testAuth ( ) ;
1013
- auth . tenantId = 'tenant-id-with-unsupported-policy-version' ;
1017
+ auth . tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION ;
1014
1018
await auth . _updatePasswordPolicy ( ) ;
1015
1019
await expect ( auth . validatePassword ( 'password' ) ) . to . be . rejectedWith (
1016
1020
AuthErrorCode . UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION
0 commit comments