File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
logstash-core/spec/logstash Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 299
299
expect ( LogStash ::Setting ::ValidatedPassword . new ( "test.validated.password" , password , password_policies ) ) . to_not be_nil
300
300
end
301
301
end
302
+
303
+ context "containing a mode WARN policy" do
304
+ before :each do
305
+ # Needs to mock the logger method at LogStash::Settings instead of LogStash::Setting::ValidatedPassword
306
+ # else the LOGGABLE_PROXY hide the mock itself.
307
+ allow ( LogStash ::Settings ) . to receive ( :logger ) . at_least ( :once ) . and_return ( mock_logger )
308
+ allow ( mock_logger ) . to receive ( :warn )
309
+ end
310
+ let ( :mock_logger ) { double ( "logger" ) }
311
+ let ( :password_policies ) { super ( ) . merge ( { "mode" : "WARN" } ) }
312
+
313
+ it "logs a warning on validation failure" do
314
+ password = LogStash ::Util ::Password . new ( "Password!" )
315
+ expect {
316
+ LogStash ::Setting ::ValidatedPassword . new ( "test.validated.password" , password , password_policies )
317
+ } . not_to raise_error
318
+ expect ( mock_logger ) . to have_received ( :warn ) . with ( a_string_including ( "Password must contain at least one digit between 0 and 9." ) )
319
+ end
320
+ end
302
321
end
303
322
304
323
context "placeholders in nested logstash.yml" do
You can’t perform that action at this time.
0 commit comments