@@ -790,64 +790,58 @@ describe('core/auth/auth_impl', () => {
790
790
context ( 'passwordPolicy' , ( ) => {
791
791
const TEST_ALLOWED_NON_ALPHANUMERIC_CHARS = [ '!' , '(' , ')' ] ;
792
792
const TEST_MIN_PASSWORD_LENGTH = 6 ;
793
+ const TEST_SCHEMA_VERSION = 1 ;
794
+ const TEST_TENANT_ID = 'tenant-id' ;
795
+ const TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION =
796
+ 'tenant-id-unsupported-policy-version' ;
793
797
794
- const passwordPolicyResponse = {
798
+ const PASSWORD_POLICY_RESPONSE = {
795
799
customStrengthOptions : {
796
800
minPasswordLength : TEST_MIN_PASSWORD_LENGTH
797
801
} ,
798
802
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS ,
799
- schemaVersion : 1
803
+ schemaVersion : TEST_SCHEMA_VERSION
800
804
} ;
801
- const passwordPolicyResponseRequireNumeric = {
805
+ const PASSWORD_POLICY_RESPONSE_REQUIRE_NUMERIC = {
802
806
customStrengthOptions : {
803
807
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
804
808
containsNumericCharacter : true
805
809
} ,
806
810
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS ,
807
- schemaVersion : 1
811
+ schemaVersion : TEST_SCHEMA_VERSION
808
812
} ;
809
- const passwordPolicyResponseUnsupportedVersion = {
813
+ const PASSWORD_POLICY_RESPONSE_UNSUPPORTED_VERSION = {
810
814
customStrengthOptions : {
811
815
maxPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
812
816
unsupportedPasswordPolicyProperty : 10
813
817
} ,
814
818
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS ,
815
819
schemaVersion : 0
816
820
} ;
817
- const cachedPasswordPolicy = {
818
- customStrengthOptions : {
819
- minPasswordLength : TEST_MIN_PASSWORD_LENGTH
820
- } ,
821
- allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS
822
- } ;
823
- const cachedPasswordPolicyRequireNumeric = {
824
- customStrengthOptions : {
825
- minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
826
- containsNumericCharacter : true
827
- } ,
828
- allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS
829
- } ;
821
+ const CACHED_PASSWORD_POLICY = PASSWORD_POLICY_RESPONSE ;
822
+ const CACHED_PASSWORD_POLICY_REQUIRE_NUMERIC =
823
+ PASSWORD_POLICY_RESPONSE_REQUIRE_NUMERIC ;
830
824
831
825
beforeEach ( async ( ) => {
832
826
mockFetch . setUp ( ) ;
833
827
mockEndpointWithParams (
834
828
Endpoint . GET_PASSWORD_POLICY ,
835
829
{ } ,
836
- passwordPolicyResponse
830
+ PASSWORD_POLICY_RESPONSE
837
831
) ;
838
832
mockEndpointWithParams (
839
833
Endpoint . GET_PASSWORD_POLICY ,
840
834
{
841
- tenantId : 'tenant-id'
835
+ tenantId : TEST_TENANT_ID
842
836
} ,
843
- passwordPolicyResponseRequireNumeric
837
+ PASSWORD_POLICY_RESPONSE_REQUIRE_NUMERIC
844
838
) ;
845
839
mockEndpointWithParams (
846
840
Endpoint . GET_PASSWORD_POLICY ,
847
841
{
848
- tenantId : 'tenant-id-with-unsupported-policy-version'
842
+ tenantId : TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION
849
843
} ,
850
- passwordPolicyResponseUnsupportedVersion
844
+ PASSWORD_POLICY_RESPONSE_UNSUPPORTED_VERSION
851
845
) ;
852
846
} ) ;
853
847
@@ -860,16 +854,16 @@ describe('core/auth/auth_impl', () => {
860
854
auth . tenantId = null ;
861
855
await auth . _updatePasswordPolicy ( ) ;
862
856
863
- expect ( auth . _getPasswordPolicy ( ) ) . to . eql ( cachedPasswordPolicy ) ;
857
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . eql ( CACHED_PASSWORD_POLICY ) ;
864
858
} ) ;
865
859
866
860
it ( 'password policy should be set for tenant if tenant ID is not null' , async ( ) => {
867
861
auth = await testAuth ( ) ;
868
- auth . tenantId = 'tenant-id' ;
862
+ auth . tenantId = TEST_TENANT_ID ;
869
863
await auth . _updatePasswordPolicy ( ) ;
870
864
871
- expect ( auth . _getPasswordPolicy ( ) ) . to . eql (
872
- cachedPasswordPolicyRequireNumeric
865
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . eql (
866
+ CACHED_PASSWORD_POLICY_REQUIRE_NUMERIC
873
867
) ;
874
868
} ) ;
875
869
@@ -878,27 +872,27 @@ describe('core/auth/auth_impl', () => {
878
872
auth . tenantId = null ;
879
873
await auth . _updatePasswordPolicy ( ) ;
880
874
881
- auth . tenantId = 'tenant-id' ;
875
+ auth . tenantId = TEST_TENANT_ID ;
882
876
await auth . _updatePasswordPolicy ( ) ;
883
877
884
878
auth . tenantId = null ;
885
- expect ( auth . _getPasswordPolicy ( ) ) . to . eql ( cachedPasswordPolicy ) ;
886
- auth . tenantId = 'tenant-id' ;
887
- expect ( auth . _getPasswordPolicy ( ) ) . to . eql (
888
- cachedPasswordPolicyRequireNumeric
879
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . eql ( CACHED_PASSWORD_POLICY ) ;
880
+ auth . tenantId = TEST_TENANT_ID ;
881
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . eql (
882
+ CACHED_PASSWORD_POLICY_REQUIRE_NUMERIC
889
883
) ;
890
884
auth . tenantId = 'other-tenant-id' ;
891
- expect ( auth . _getPasswordPolicy ( ) ) . to . be . undefined ;
885
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . be . undefined ;
892
886
} ) ;
893
887
894
888
it ( 'password policy should not be set when the schema version is not supported' , async ( ) => {
895
889
auth = await testAuth ( ) ;
896
- auth . tenantId = 'tenant-id-with-unsupported-policy-version' ;
890
+ auth . tenantId = TEST_TENANT_ID_UNSUPPORTED_POLICY_VERSION ;
897
891
await expect ( auth . _updatePasswordPolicy ( ) ) . to . be . rejectedWith (
898
892
AuthErrorCode . UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION
899
893
) ;
900
894
901
- expect ( auth . _getPasswordPolicy ( ) ) . to . be . undefined ;
895
+ expect ( auth . _getPasswordPolicyInternal ( ) ) . to . be . undefined ;
902
896
} ) ;
903
897
} ) ;
904
898
} ) ;
0 commit comments