@@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(AuthConfigValidation) {
1919 std::vector<TString> error;
2020 EValidationResult result = ValidateAuthConfig (authConfig, error);
2121 UNIT_ASSERT_EQUAL (result, EValidationResult::Ok);
22- UNIT_ASSERT_C (error.empty (), " Should not be errors " );
22+ UNIT_ASSERT_C (error.empty (), error. front () );
2323 }
2424
2525 Y_UNIT_TEST (CannotAcceptInvalidPasswordComplexity) {
@@ -40,4 +40,71 @@ Y_UNIT_TEST_SUITE(AuthConfigValidation) {
4040 UNIT_ASSERT_STRINGS_EQUAL (error.front (), " password_complexity: Min length of password cannot be less than "
4141 " total min counts of lower case chars, upper case chars, numbers and special chars" );
4242 }
43+
44+ Y_UNIT_TEST (AcceptValidAccountLockoutConfig) {
45+ NKikimrProto::TAuthConfig authConfig;
46+ NKikimrProto::TAccountLockout* validAccountLockoutConfig = authConfig.MutableAccountLockout ();
47+
48+ {
49+ validAccountLockoutConfig->SetAttemptResetDuration (" 12h" );
50+
51+ std::vector<TString> error;
52+ EValidationResult result = ValidateAuthConfig (authConfig, error);
53+ UNIT_ASSERT_EQUAL (result, EValidationResult::Ok);
54+ UNIT_ASSERT_C (error.empty (), error.front ());
55+ }
56+
57+ {
58+ validAccountLockoutConfig->SetAttemptResetDuration (" 5m" );
59+
60+ std::vector<TString> error;
61+ EValidationResult result = ValidateAuthConfig (authConfig, error);
62+ UNIT_ASSERT_EQUAL (result, EValidationResult::Ok);
63+ UNIT_ASSERT_C (error.empty (), error.front ());
64+ }
65+
66+ {
67+ validAccountLockoutConfig->SetAttemptResetDuration (" 5s" );
68+
69+ std::vector<TString> error;
70+ EValidationResult result = ValidateAuthConfig (authConfig, error);
71+ UNIT_ASSERT_EQUAL (result, EValidationResult::Ok);
72+ UNIT_ASSERT_C (error.empty (), error.front ());
73+ }
74+ }
75+
76+ Y_UNIT_TEST (CannotAcceptInvalidAccountLockoutConfig) {
77+ NKikimrProto::TAuthConfig authConfig;
78+ NKikimrProto::TAccountLockout* invalidAccountLockoutConfig = authConfig.MutableAccountLockout ();
79+
80+ {
81+ invalidAccountLockoutConfig->SetAttemptResetDuration (" h" );
82+
83+ std::vector<TString> error;
84+ EValidationResult result = ValidateAuthConfig (authConfig, error);
85+ UNIT_ASSERT_EQUAL (result, EValidationResult::Error);
86+ UNIT_ASSERT_VALUES_EQUAL (error.size (), 1 );
87+ UNIT_ASSERT_STRINGS_EQUAL (error.front (), " account_lockout: Cannot parse attempt reset duration" );
88+ }
89+
90+ {
91+ invalidAccountLockoutConfig->SetAttemptResetDuration (" " );
92+
93+ std::vector<TString> error;
94+ EValidationResult result = ValidateAuthConfig (authConfig, error);
95+ UNIT_ASSERT_EQUAL (result, EValidationResult::Error);
96+ UNIT_ASSERT_VALUES_EQUAL (error.size (), 1 );
97+ UNIT_ASSERT_STRINGS_EQUAL (error.front (), " account_lockout: Cannot parse attempt reset duration" );
98+ }
99+
100+ {
101+ invalidAccountLockoutConfig->SetAttemptResetDuration (" 12hhh" );
102+
103+ std::vector<TString> error;
104+ EValidationResult result = ValidateAuthConfig (authConfig, error);
105+ UNIT_ASSERT_EQUAL (result, EValidationResult::Error);
106+ UNIT_ASSERT_VALUES_EQUAL (error.size (), 1 );
107+ UNIT_ASSERT_STRINGS_EQUAL (error.front (), " account_lockout: Cannot parse attempt reset duration" );
108+ }
109+ }
43110}
0 commit comments