Skip to content

Commit e6f7b35

Browse files
committed
Use context to describe #attempt_login
1 parent f266ca9 commit e6f7b35

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,34 @@
201201
end
202202

203203
context '#attempt_login' do
204-
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
205-
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Rex::ConnectionError)
206-
207-
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
204+
context 'when Rex::Proto::Http::Client#connect raises a Rex::ConnectionError' do
205+
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
206+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Rex::ConnectionError)
207+
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
208+
end
208209
end
209210

210-
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
211-
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Timeout::Error)
212-
213-
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
211+
context 'when Rex::Proto::Http::Client#connect raises a Timeout::Error' do
212+
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
213+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Timeout::Error)
214+
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
215+
end
214216
end
215217

216-
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
217-
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(EOFError)
218-
219-
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
218+
context 'when Rex::Proto::Http::Client#connect raises a EOFError' do
219+
it 'returns status Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do
220+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(EOFError)
221+
expect(http_scanner.attempt_login(cred).status).to eq(Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
222+
end
220223
end
221224

222-
it 'raises a GlassfishError exception due to an unsupported Glassfish version' do
223-
http_scanner.version = bad_version
224-
expect { http_scanner.attempt_login(cred) }.to raise_exception(Metasploit::Framework::LoginScanner::GlassfishError)
225+
context 'when unsupported Glassfish version' do
226+
it 'raises a GlassfishError exception' do
227+
http_scanner.version = bad_version
228+
expect { http_scanner.attempt_login(cred) }.to raise_exception(Metasploit::Framework::LoginScanner::GlassfishError)
229+
end
225230
end
231+
226232
end
227233

228234
end

0 commit comments

Comments
 (0)