@@ -34,7 +34,7 @@ describe('core/auth/password_policy_impl', () => {
34
34
const TEST_CONTAINS_NON_ALPHANUMERIC = true ;
35
35
const TEST_ALLOWED_NON_ALPHANUMERIC_CHARS = [ '!' , '(' , ')' ] ;
36
36
const TEST_SCHEMA_VERSION = 1 ;
37
- const passwordPolicyResponseRequireAll : GetPasswordPolicyResponse = {
37
+ const PASSWORD_POLICY_RESPONSE_REQUIRE_ALL : GetPasswordPolicyResponse = {
38
38
customStrengthOptions : {
39
39
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
40
40
maxPasswordLength : TEST_MAX_PASSWORD_LENGTH ,
@@ -46,15 +46,15 @@ describe('core/auth/password_policy_impl', () => {
46
46
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS ,
47
47
schemaVersion : TEST_SCHEMA_VERSION
48
48
} ;
49
- const passwordPolicyResponseRequireLength : GetPasswordPolicyResponse = {
49
+ const PASSWORD_POLICY_RESPONSE_REQUIRE_LENGTH : GetPasswordPolicyResponse = {
50
50
customStrengthOptions : {
51
51
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
52
52
maxPasswordLength : TEST_MAX_PASSWORD_LENGTH
53
53
} ,
54
54
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS ,
55
55
schemaVersion : TEST_SCHEMA_VERSION
56
56
} ;
57
- const passwordPolicyRequireAll : PasswordPolicy = {
57
+ const PASSWORD_POLICY_REQUIRE_ALL : PasswordPolicy = {
58
58
customStrengthOptions : {
59
59
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
60
60
maxPasswordLength : TEST_MAX_PASSWORD_LENGTH ,
@@ -65,7 +65,7 @@ describe('core/auth/password_policy_impl', () => {
65
65
} ,
66
66
allowedNonAlphanumericCharacters : TEST_ALLOWED_NON_ALPHANUMERIC_CHARS
67
67
} ;
68
- const passwordPolicyRequireLength : PasswordPolicy = {
68
+ const PASSWORD_POLICY_REQUIRE_LENGTH : PasswordPolicy = {
69
69
customStrengthOptions : {
70
70
minPasswordLength : TEST_MIN_PASSWORD_LENGTH ,
71
71
maxPasswordLength : TEST_MAX_PASSWORD_LENGTH
@@ -76,28 +76,37 @@ describe('core/auth/password_policy_impl', () => {
76
76
context ( '#PasswordPolicyImpl' , ( ) => {
77
77
it ( 'can construct the password policy from the backend response' , ( ) => {
78
78
const policy : PasswordPolicy = new PasswordPolicyImpl (
79
- passwordPolicyResponseRequireAll
79
+ PASSWORD_POLICY_RESPONSE_REQUIRE_ALL
80
80
) ;
81
81
// The password policy contains the schema version internally, but the public typing does not.
82
82
// Only check the fields that are publicly exposed.
83
83
expect ( policy . customStrengthOptions ) . to . eql (
84
- passwordPolicyRequireAll . customStrengthOptions
84
+ PASSWORD_POLICY_REQUIRE_ALL . customStrengthOptions
85
85
) ;
86
86
expect ( policy . allowedNonAlphanumericCharacters ) . to . eql (
87
- passwordPolicyRequireAll . allowedNonAlphanumericCharacters
87
+ PASSWORD_POLICY_REQUIRE_ALL . allowedNonAlphanumericCharacters
88
88
) ;
89
89
} ) ;
90
90
91
91
it ( 'only includes requirements defined in the response' , ( ) => {
92
92
const policy : PasswordPolicy = new PasswordPolicyImpl (
93
- passwordPolicyResponseRequireLength
93
+ PASSWORD_POLICY_RESPONSE_REQUIRE_LENGTH
94
94
) ;
95
95
expect ( policy . customStrengthOptions ) . to . eql (
96
- passwordPolicyRequireLength . customStrengthOptions
96
+ PASSWORD_POLICY_REQUIRE_LENGTH . customStrengthOptions
97
97
) ;
98
98
expect ( policy . allowedNonAlphanumericCharacters ) . to . eql (
99
- passwordPolicyRequireLength . allowedNonAlphanumericCharacters
99
+ PASSWORD_POLICY_REQUIRE_LENGTH . allowedNonAlphanumericCharacters
100
100
) ;
101
+ // Requirements that are not in the response should be undefined.
102
+ expect ( policy . customStrengthOptions . containsLowercaseLetter ) . to . be
103
+ . undefined ;
104
+ expect ( policy . customStrengthOptions . containsUppercaseLetter ) . to . be
105
+ . undefined ;
106
+ expect ( policy . customStrengthOptions . containsNumericCharacter ) . to . be
107
+ . undefined ;
108
+ expect ( policy . customStrengthOptions . containsNonAlphanumericCharacter ) . to
109
+ . be . undefined ;
101
110
} ) ;
102
111
} ) ;
103
112
} ) ;
0 commit comments