|
201 | 201 | end
|
202 | 202 |
|
203 | 203 | 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 |
208 | 209 | end
|
209 | 210 |
|
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 |
214 | 216 | end
|
215 | 217 |
|
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 |
220 | 223 | end
|
221 | 224 |
|
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 |
225 | 230 | end
|
| 231 | + |
226 | 232 | end
|
227 | 233 |
|
228 | 234 | end
|
|
0 commit comments