Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/shared_examples/views/vuln_api.rb
485 views
1
# frozen_string_literal: true
2
3
shared_examples 'App::Views::VulnApi' do
4
let(:controller) { WPScan::Controller::VulnApi.new }
5
let(:tpl_vars) { { url: target_url } }
6
7
describe 'status' do
8
let(:view) { 'status' }
9
10
context 'when no api token is given' do
11
let(:expected_view) { 'no_token' }
12
13
it 'outputs the expected string' do
14
@tpl_vars = tpl_vars.merge(status: {})
15
end
16
end
17
18
context 'when http error' do
19
let(:expected_view) { 'http_error' }
20
21
it 'outputs the expected string' do
22
@tpl_vars = tpl_vars.merge(
23
status: {
24
'http_error' => WPScan::Error::HTTP.new(Typhoeus::Response.new(effective_url: 'url', return_code: 28))
25
}
26
)
27
end
28
end
29
30
context 'when no more remaining requests' do
31
let(:expected_view) { 'no_more_requests' }
32
33
it 'outputs the expected string' do
34
@tpl_vars = tpl_vars.merge(
35
status: { 'success' => true, 'plan' => 'free', 'requests_remaining' => 0 },
36
api_requests: 3
37
)
38
end
39
end
40
41
context 'when everything is fine' do
42
let(:expected_view) { 'all_ok' }
43
44
it 'outputs the expected string' do
45
@tpl_vars = tpl_vars.merge(
46
status: { 'success' => true, 'plan' => 'paid', 'requests_remaining' => 120 },
47
api_requests: 3
48
)
49
end
50
end
51
52
context 'when unlimited requests' do
53
let(:expected_view) { 'unlimited_requests' }
54
55
it 'outputs the expected string' do
56
@tpl_vars = tpl_vars.merge(
57
status: { 'success' => true, 'plan' => 'enterprise', 'requests_remaining' => 'Unlimited' },
58
api_requests: 3
59
)
60
end
61
end
62
end
63
end
64
65