Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/app/finders/passwords/wp_login_spec.rb
1483 views
1
# frozen_string_literal: true
2
3
describe WPScan::Finders::Passwords::WpLogin do
4
subject(:finder) { described_class.new(target) }
5
let(:target) { WPScan::Target.new(url) }
6
let(:url) { 'http://ex.lo/' }
7
8
describe '#valid_credentials?' do
9
context 'when a non 302' do
10
it 'returns false' do
11
expect(finder.valid_credentials?(Typhoeus::Response.new(code: 200, headers: {}))).to be_falsey
12
end
13
end
14
15
context 'when a 302' do
16
let(:response) { Typhoeus::Response.new(code: 302, headers: headers) }
17
18
context 'when no cookies set' do
19
let(:headers) { {} }
20
21
it 'returns false' do
22
expect(finder.valid_credentials?(response)).to be_falsey
23
end
24
end
25
26
context 'when no logged_in cookie set' do
27
context 'when only one cookie set' do
28
let(:headers) { 'Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/' }
29
30
it 'returns false' do
31
expect(finder.valid_credentials?(response)).to be_falsey
32
end
33
end
34
35
context 'when multiple cookies set' do
36
let(:headers) do
37
"Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/\r\n" \
38
'Set-Cookie: something=value; path=/'
39
end
40
41
it 'returns false' do
42
expect(finder.valid_credentials?(response)).to be_falsey
43
end
44
end
45
end
46
47
context 'when logged_in cookie set' do
48
let(:headers) do
49
"Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/\r\r" \
50
"Set-Cookie: wordpress_xxx=yyy; path=/wp-content/plugins; httponly\r\n" \
51
"Set-Cookie: wordpress_xxx=yyy; path=/wp-admin; httponly\r\n" \
52
'Set-Cookie: wordpress_logged_in_xxx=yyy; path=/; httponly'
53
end
54
55
it 'returns false' do
56
expect(finder.valid_credentials?(response)).to eql true
57
end
58
end
59
end
60
end
61
end
62
63