site-inspector 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.rubocop.yml +18 -10
- data/.rubocop_todo.yml +139 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -0
- data/Guardfile +2 -0
- data/Rakefile +2 -0
- data/bin/site-inspector +7 -6
- data/lib/cliver/dependency_ext.rb +6 -3
- data/lib/site-inspector.rb +18 -11
- data/lib/site-inspector/cache.rb +2 -0
- data/lib/site-inspector/checks/accessibility.rb +30 -22
- data/lib/site-inspector/checks/check.rb +4 -2
- data/lib/site-inspector/checks/content.rb +15 -4
- data/lib/site-inspector/checks/cookies.rb +5 -3
- data/lib/site-inspector/checks/dns.rb +13 -11
- data/lib/site-inspector/checks/headers.rb +8 -6
- data/lib/site-inspector/checks/hsts.rb +16 -12
- data/lib/site-inspector/checks/https.rb +3 -1
- data/lib/site-inspector/checks/sniffer.rb +10 -7
- data/lib/site-inspector/checks/wappalyzer.rb +62 -0
- data/lib/site-inspector/checks/whois.rb +36 -0
- data/lib/site-inspector/disk_cache.rb +2 -0
- data/lib/site-inspector/domain.rb +36 -30
- data/lib/site-inspector/endpoint.rb +22 -23
- data/lib/site-inspector/rails_cache.rb +2 -0
- data/lib/site-inspector/version.rb +3 -1
- data/package-lock.json +505 -0
- data/package.json +1 -1
- data/script/pa11y-version +1 -0
- data/site-inspector.gemspec +24 -17
- data/spec/checks/site_inspector_endpoint_accessibility_spec.rb +15 -13
- data/spec/checks/site_inspector_endpoint_check_spec.rb +9 -7
- data/spec/checks/site_inspector_endpoint_content_spec.rb +30 -21
- data/spec/checks/site_inspector_endpoint_cookies_spec.rb +17 -15
- data/spec/checks/site_inspector_endpoint_dns_spec.rb +42 -40
- data/spec/checks/site_inspector_endpoint_headers_spec.rb +12 -10
- data/spec/checks/site_inspector_endpoint_hsts_spec.rb +27 -25
- data/spec/checks/site_inspector_endpoint_https_spec.rb +12 -10
- data/spec/checks/site_inspector_endpoint_sniffer_spec.rb +33 -31
- data/spec/checks/site_inspector_endpoint_wappalyzer_spec.rb +34 -0
- data/spec/checks/site_inspector_endpoint_whois_spec.rb +26 -0
- data/spec/fixtures/wappalyzer.json +125 -0
- data/spec/site_inspector_cache_spec.rb +2 -0
- data/spec/site_inspector_disk_cache_spec.rb +8 -6
- data/spec/site_inspector_domain_spec.rb +34 -34
- data/spec/site_inspector_endpoint_spec.rb +44 -43
- data/spec/site_inspector_spec.rb +15 -13
- data/spec/spec_helper.rb +2 -0
- metadata +125 -55
data/package.json
CHANGED
data/script/pa11y-version
CHANGED
data/site-inspector.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path './lib/site-inspector/version', File.dirname(__FILE__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
@@ -15,21 +17,26 @@ Gem::Specification.new do |s|
|
|
15
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
18
|
s.require_paths = ['lib']
|
17
19
|
|
18
|
-
s.add_dependency('
|
19
|
-
s.add_dependency('
|
20
|
-
s.add_dependency('
|
21
|
-
s.add_dependency('
|
22
|
-
s.add_dependency('
|
23
|
-
s.add_dependency('
|
24
|
-
s.add_dependency('
|
25
|
-
s.add_dependency('
|
26
|
-
s.add_dependency('
|
27
|
-
s.add_dependency('
|
28
|
-
s.add_dependency('
|
29
|
-
s.
|
30
|
-
s.
|
31
|
-
s.
|
32
|
-
|
33
|
-
s.add_development_dependency('
|
34
|
-
s.add_development_dependency('
|
20
|
+
s.add_dependency('cliver', '~> 0.0')
|
21
|
+
s.add_dependency('colorator', '~> 1.1')
|
22
|
+
s.add_dependency('dnsruby', '~> 1.0')
|
23
|
+
s.add_dependency('dotenv', '~> 2.0')
|
24
|
+
s.add_dependency('gman', '~> 7.0', '>= 7.0.4')
|
25
|
+
s.add_dependency('mercenary', '~> 0.0')
|
26
|
+
s.add_dependency('nokogiri', '~> 1.0')
|
27
|
+
s.add_dependency('oj', '~> 3.0')
|
28
|
+
s.add_dependency('parallel', '~> 1.0')
|
29
|
+
s.add_dependency('public_suffix', '~> 4.0')
|
30
|
+
s.add_dependency('sniffles', '~> 0.0')
|
31
|
+
s.add_dependency('typhoeus', '~> 1.0')
|
32
|
+
s.add_dependency('urlscan', '~> 0.6')
|
33
|
+
s.add_dependency('whois', '~> 5.0')
|
34
|
+
|
35
|
+
s.add_development_dependency('pry', '~> 0.0')
|
36
|
+
s.add_development_dependency('rake', '~> 13.0')
|
37
|
+
s.add_development_dependency('rspec', '~> 3.0')
|
38
|
+
s.add_development_dependency('rubocop', '~> 1.0')
|
39
|
+
s.add_development_dependency('rubocop-performance', '~> 1.5')
|
40
|
+
s.add_development_dependency('rubocop-rspec', '~> 2.0')
|
41
|
+
s.add_development_dependency('webmock', '~> 3.0')
|
35
42
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Endpoint::Accessibility do
|
4
6
|
subject do
|
5
7
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
6
|
-
|
8
|
+
described_class.new(endpoint)
|
7
9
|
end
|
8
10
|
|
9
11
|
it "retrieve's pa11y's version" do
|
10
|
-
pending('Pa11y not installed') unless
|
12
|
+
pending('Pa11y not installed') unless described_class.pa11y?
|
11
13
|
expect(subject.class.pa11y_version).to match(/\d\.\d\.\d/)
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'responds to valid standards' do
|
15
|
-
expect(subject.respond_to?(:section508)).to
|
17
|
+
expect(subject.respond_to?(:section508)).to be(true)
|
16
18
|
end
|
17
19
|
|
18
20
|
it 'knows the level' do
|
19
|
-
expect(subject.level).to
|
21
|
+
expect(subject.level).to be(:error)
|
20
22
|
end
|
21
23
|
|
22
24
|
it 'allows the user to set the level' do
|
23
25
|
subject.level = :warning
|
24
|
-
expect(subject.level).to
|
26
|
+
expect(subject.level).to be(:warning)
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'errors on invalid levels' do
|
@@ -29,12 +31,12 @@ describe SiteInspector::Endpoint::Accessibility do
|
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'knows the standard' do
|
32
|
-
expect(subject.standard).to
|
34
|
+
expect(subject.standard).to be(:wcag2a)
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'allows the user to set the standard' do
|
36
38
|
subject.standard = :wcag2a
|
37
|
-
expect(subject.standard).to
|
39
|
+
expect(subject.standard).to be(:wcag2a)
|
38
40
|
end
|
39
41
|
|
40
42
|
it 'errors on invalid standards' do
|
@@ -55,27 +57,27 @@ describe SiteInspector::Endpoint::Accessibility do
|
|
55
57
|
|
56
58
|
it 'knows if a site is valid' do
|
57
59
|
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
58
|
-
expect(subject.valid?).to
|
60
|
+
expect(subject.valid?).to be(false)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'counts the errors' do
|
63
65
|
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
64
|
-
expect(subject.errors).to
|
66
|
+
expect(subject.errors).to be(1)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
70
|
it 'runs the check' do
|
69
71
|
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
70
|
-
expect(subject.check[:valid]).to
|
71
|
-
expect(subject.check[:results].first['code']).to eql('
|
72
|
+
expect(subject.check[:valid]).to be(false)
|
73
|
+
expect(subject.check[:results].first['code']).to eql('WCAG2A.Principle3.Guideline3_1.3_1_1.H57.2')
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
it 'runs a named check' do
|
76
78
|
with_env 'SKIP_PA11Y_CHECK', 'true' do
|
77
|
-
expect(subject.check[:valid]).to
|
78
|
-
expect(subject.check[:results].first['code']).to eql('
|
79
|
+
expect(subject.check[:valid]).to be(false)
|
80
|
+
expect(subject.check[:results].first['code']).to eql('WCAG2A.Principle3.Guideline3_1.3_1_1.H57.2')
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Endpoint::Check do
|
4
6
|
subject do
|
5
7
|
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
6
8
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
7
|
-
|
9
|
+
described_class.new(endpoint)
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'returns the endpoint' do
|
@@ -24,17 +26,17 @@ describe SiteInspector::Endpoint::Check do
|
|
24
26
|
end
|
25
27
|
|
26
28
|
it 'returns its name' do
|
27
|
-
expect(subject.name).to
|
29
|
+
expect(subject.name).to be(:check)
|
28
30
|
end
|
29
31
|
|
30
32
|
it 'returns the instance name' do
|
31
|
-
expect(
|
33
|
+
expect(described_class.name).to be(:check)
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'enables and disables the check' do
|
35
|
-
expect(
|
36
|
-
|
37
|
-
expect(
|
38
|
-
|
37
|
+
expect(described_class.enabled?).to be(true)
|
38
|
+
described_class.enabled = false
|
39
|
+
expect(described_class.enabled?).to be(false)
|
40
|
+
described_class.enabled = true
|
39
41
|
end
|
40
42
|
end
|
@@ -1,22 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Endpoint::Content do
|
4
6
|
subject do
|
5
|
-
body = <<-
|
7
|
+
body = <<-BODY
|
6
8
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
7
9
|
<html>
|
10
|
+
<head>
|
11
|
+
<meta name="generator" content="Jekyll v3.8.5" />
|
12
|
+
</head>
|
8
13
|
<body>
|
9
14
|
<h1>Some page</h1>
|
10
15
|
</body>
|
11
16
|
</html>
|
12
|
-
|
17
|
+
BODY
|
13
18
|
|
14
19
|
stub_request(:get, 'http://example.com/')
|
15
20
|
.to_return(status: 200, body: body)
|
16
21
|
stub_request(:head, 'http://example.com/')
|
17
22
|
.to_return(status: 200)
|
18
23
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
19
|
-
|
24
|
+
described_class.new(endpoint)
|
20
25
|
end
|
21
26
|
|
22
27
|
it 'returns the doc' do
|
@@ -33,64 +38,68 @@ describe SiteInspector::Endpoint::Content do
|
|
33
38
|
end
|
34
39
|
|
35
40
|
it 'knows when robots.txt exists' do
|
36
|
-
stub_request(:head, %r{http
|
41
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
37
42
|
|
38
43
|
stub_request(:head, 'http://example.com/robots.txt')
|
39
44
|
.to_return(status: 200)
|
40
|
-
expect(subject.robots_txt?).to
|
45
|
+
expect(subject.robots_txt?).to be(true)
|
41
46
|
end
|
42
47
|
|
43
48
|
it "knows when robots.txt doesn't exist" do
|
44
|
-
stub_request(:head, %r{http
|
49
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
45
50
|
|
46
51
|
stub_request(:head, 'http://example.com/robots.txt')
|
47
52
|
.to_return(status: 404)
|
48
|
-
expect(subject.robots_txt?).to
|
53
|
+
expect(subject.robots_txt?).to be(false)
|
49
54
|
end
|
50
55
|
|
51
56
|
it 'knows when sitemap.xml exists' do
|
52
|
-
stub_request(:head, %r{http
|
57
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
53
58
|
|
54
59
|
stub_request(:head, 'http://example.com/sitemap.xml')
|
55
60
|
.to_return(status: 200)
|
56
|
-
expect(subject.sitemap_xml?).to
|
61
|
+
expect(subject.sitemap_xml?).to be(true)
|
57
62
|
end
|
58
63
|
|
59
64
|
it 'knows when sitemap.xml exists' do
|
60
|
-
stub_request(:head, %r{http
|
65
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
61
66
|
|
62
67
|
stub_request(:head, 'http://example.com/sitemap.xml')
|
63
68
|
.to_return(status: 404)
|
64
|
-
expect(subject.sitemap_xml?).to
|
69
|
+
expect(subject.sitemap_xml?).to be(false)
|
65
70
|
end
|
66
71
|
|
67
72
|
it 'knows when humans.txt exists' do
|
68
|
-
stub_request(:head, %r{http
|
73
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
69
74
|
|
70
75
|
stub_request(:head, 'http://example.com/humans.txt')
|
71
76
|
.to_return(status: 200)
|
72
|
-
expect(subject.humans_txt?).to
|
77
|
+
expect(subject.humans_txt?).to be(true)
|
73
78
|
end
|
74
79
|
|
75
80
|
it "knows when humans.txt doesn't exist" do
|
76
|
-
stub_request(:head, %r{http
|
81
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 404)
|
77
82
|
|
78
83
|
stub_request(:head, 'http://example.com/humans.txt')
|
79
84
|
.to_return(status: 200)
|
80
|
-
expect(subject.humans_txt?).to
|
85
|
+
expect(subject.humans_txt?).to be(true)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns the generator' do
|
89
|
+
expect(subject.generator).to eql('Jekyll v3.8.5')
|
81
90
|
end
|
82
91
|
|
83
92
|
context '404s' do
|
84
93
|
it 'knows when an endpoint returns a proper 404' do
|
85
|
-
stub_request(:head, %r{http
|
94
|
+
stub_request(:head, %r{http://example.com/.*})
|
86
95
|
.to_return(status: 404)
|
87
|
-
expect(subject.proper_404s?).to
|
96
|
+
expect(subject.proper_404s?).to be(true)
|
88
97
|
end
|
89
98
|
|
90
99
|
it "knows when an endpoint doesn't return a proper 404" do
|
91
|
-
stub_request(:head, %r{http
|
100
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i)
|
92
101
|
.to_return(status: 200)
|
93
|
-
expect(subject.proper_404s?).to
|
102
|
+
expect(subject.proper_404s?).to be(false)
|
94
103
|
end
|
95
104
|
|
96
105
|
it 'generates a random path' do
|
@@ -100,9 +109,9 @@ describe SiteInspector::Endpoint::Content do
|
|
100
109
|
end
|
101
110
|
|
102
111
|
it "doesn't say something exists when there are no 404s" do
|
103
|
-
stub_request(:head, %r{http
|
112
|
+
stub_request(:head, %r{http://example.com/[a-z0-9]{32}}i).to_return(status: 200)
|
104
113
|
stub_request(:head, 'http://example.com/humans.txt').to_return(status: 200)
|
105
|
-
expect(subject.humans_txt?).to
|
114
|
+
expect(subject.humans_txt?).to be(nil)
|
106
115
|
end
|
107
116
|
end
|
108
117
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Endpoint::Cookies do
|
@@ -6,12 +8,12 @@ describe SiteInspector::Endpoint::Cookies do
|
|
6
8
|
stub_request(:head, 'http://example.com/')
|
7
9
|
.to_return(status: 200, body: '')
|
8
10
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
9
|
-
|
11
|
+
described_class.new(endpoint)
|
10
12
|
end
|
11
13
|
|
12
14
|
it 'knows when there are no cookies' do
|
13
|
-
expect(subject.cookies?).to
|
14
|
-
expect(subject.all).to
|
15
|
+
expect(subject.cookies?).to be(false)
|
16
|
+
expect(subject.all).to be(nil)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -19,28 +21,28 @@ describe SiteInspector::Endpoint::Cookies do
|
|
19
21
|
subject do
|
20
22
|
cookies = [
|
21
23
|
CGI::Cookie.new(
|
22
|
-
'name'
|
23
|
-
'value'
|
24
|
+
'name' => 'foo',
|
25
|
+
'value' => 'bar',
|
24
26
|
'domain' => 'example.com',
|
25
|
-
'path'
|
27
|
+
'path' => '/'
|
26
28
|
),
|
27
29
|
CGI::Cookie.new(
|
28
|
-
'name'
|
29
|
-
'value'
|
30
|
+
'name' => 'foo2',
|
31
|
+
'value' => 'bar2',
|
30
32
|
'domain' => 'example.com',
|
31
|
-
'path'
|
33
|
+
'path' => '/'
|
32
34
|
)
|
33
35
|
].map(&:to_s)
|
34
36
|
|
35
37
|
stub_request(:head, 'http://example.com/')
|
36
38
|
.to_return(status: 200, body: '', headers: { 'set-cookie' => cookies })
|
37
39
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
38
|
-
|
40
|
+
described_class.new(endpoint)
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'knows when there are cookies' do
|
42
|
-
expect(subject.cookies?).to
|
43
|
-
expect(subject.all.count).to
|
44
|
+
expect(subject.cookies?).to be(true)
|
45
|
+
expect(subject.all.count).to be(2)
|
44
46
|
end
|
45
47
|
|
46
48
|
it 'returns a cookie by name' do
|
@@ -48,7 +50,7 @@ describe SiteInspector::Endpoint::Cookies do
|
|
48
50
|
end
|
49
51
|
|
50
52
|
it "knows cookies aren't secure" do
|
51
|
-
expect(subject.secure?).to
|
53
|
+
expect(subject.secure?).to be(false)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -61,11 +63,11 @@ describe SiteInspector::Endpoint::Cookies do
|
|
61
63
|
stub_request(:head, 'http://example.com/')
|
62
64
|
.to_return(status: 200, body: '', headers: { 'set-cookie' => cookies })
|
63
65
|
endpoint = SiteInspector::Endpoint.new('http://example.com')
|
64
|
-
|
66
|
+
described_class.new(endpoint)
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'knows cookies are secure' do
|
68
|
-
expect(subject.secure?).to
|
70
|
+
expect(subject.secure?).to be(true)
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'dnsruby'
|
3
5
|
|
@@ -5,22 +7,22 @@ describe SiteInspector::Endpoint::Dns do
|
|
5
7
|
subject do
|
6
8
|
stub_request(:head, 'http://github.com/').to_return(status: 200)
|
7
9
|
endpoint = SiteInspector::Endpoint.new('http://github.com')
|
8
|
-
|
10
|
+
described_class.new(endpoint)
|
9
11
|
end
|
10
12
|
|
11
13
|
it 'inits the resolver' do
|
12
|
-
expect(
|
14
|
+
expect(described_class.resolver.class).to eql(Dnsruby::Resolver)
|
13
15
|
end
|
14
16
|
|
15
|
-
#
|
17
|
+
# NOTE: these tests makes external calls
|
16
18
|
context 'live tests' do
|
17
|
-
it '
|
19
|
+
it 'runs the query' do
|
18
20
|
expect(subject.query).not_to be_empty
|
19
21
|
end
|
20
22
|
|
21
23
|
context 'resolv' do
|
22
24
|
it 'returns the IP' do
|
23
|
-
expect(subject.ip).to include('
|
25
|
+
expect(subject.ip).to include('140.82.')
|
24
26
|
end
|
25
27
|
|
26
28
|
it 'returns the hostname' do
|
@@ -33,21 +35,21 @@ describe SiteInspector::Endpoint::Dns do
|
|
33
35
|
before do
|
34
36
|
record = Dnsruby::RR.create type: 'A', address: '1.2.3.4', name: 'test'
|
35
37
|
allow(subject).to receive(:records) { [record] }
|
36
|
-
allow(subject).to receive(:query)
|
38
|
+
allow(subject).to receive(:query).and_return([])
|
37
39
|
end
|
38
40
|
|
39
41
|
it 'returns the records' do
|
40
|
-
expect(subject.records.count).to
|
42
|
+
expect(subject.records.count).to be(1)
|
41
43
|
expect(subject.records.first.class).to eql(Dnsruby::RR::IN::A)
|
42
44
|
end
|
43
45
|
|
44
46
|
it 'knows if a record exists' do
|
45
|
-
expect(subject.has_record?('A')).to
|
46
|
-
expect(subject.has_record?('CNAME')).to
|
47
|
+
expect(subject.has_record?('A')).to be(true)
|
48
|
+
expect(subject.has_record?('CNAME')).to be(false)
|
47
49
|
end
|
48
50
|
|
49
51
|
it 'knows if a domain supports dnssec' do
|
50
|
-
expect(subject.dnssec?).to
|
52
|
+
expect(subject.dnssec?).to be(false)
|
51
53
|
|
52
54
|
# via https://github.com/alexdalitz/dnsruby/blob/master/test/tc_dnskey.rb
|
53
55
|
input = 'example.com. 86400 IN DNSKEY 256 3 5 ( AQPSKmynfzW4kyBv015MUG2DeIQ3' \
|
@@ -61,25 +63,25 @@ describe SiteInspector::Endpoint::Dns do
|
|
61
63
|
record = Dnsruby::RR.create input
|
62
64
|
allow(subject).to receive(:records) { [record] }
|
63
65
|
|
64
|
-
expect(subject.dnssec?).to
|
66
|
+
expect(subject.dnssec?).to be(true)
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'knows if a domain supports ipv6' do
|
68
|
-
expect(subject.ipv6?).to
|
70
|
+
expect(subject.ipv6?).to be(false)
|
69
71
|
|
70
72
|
input = {
|
71
|
-
type:
|
72
|
-
name:
|
73
|
+
type: 'AAAA',
|
74
|
+
name: 'test',
|
73
75
|
address: '102:304:506:708:90a:b0c:d0e:ff10'
|
74
76
|
}
|
75
77
|
record = Dnsruby::RR.create input
|
76
78
|
allow(subject).to receive(:records) { [record] }
|
77
79
|
|
78
|
-
expect(subject.ipv6?).to
|
80
|
+
expect(subject.ipv6?).to be(true)
|
79
81
|
end
|
80
82
|
|
81
83
|
it "knows it's not a localhost address" do
|
82
|
-
expect(subject.localhost?).to
|
84
|
+
expect(subject.localhost?).to be(false)
|
83
85
|
end
|
84
86
|
|
85
87
|
context 'hostname detection' do
|
@@ -87,38 +89,38 @@ describe SiteInspector::Endpoint::Dns do
|
|
87
89
|
records = []
|
88
90
|
|
89
91
|
records.push Dnsruby::RR.create(
|
90
|
-
type:
|
92
|
+
type: 'CNAME',
|
91
93
|
domainname: 'example.com',
|
92
|
-
name:
|
94
|
+
name: 'example'
|
93
95
|
)
|
94
96
|
|
95
97
|
records.push Dnsruby::RR.create(
|
96
|
-
type:
|
98
|
+
type: 'CNAME',
|
97
99
|
domainname: 'github.com',
|
98
|
-
name:
|
100
|
+
name: 'github'
|
99
101
|
)
|
100
102
|
|
101
103
|
allow(subject).to receive(:records) { records }
|
102
104
|
|
103
|
-
expect(subject.cnames.count).to
|
105
|
+
expect(subject.cnames.count).to be(2)
|
104
106
|
expect(subject.cnames.first.sld).to eql('example')
|
105
107
|
end
|
106
108
|
|
107
109
|
it "knows when a domain doesn't have a cdn" do
|
108
|
-
expect(subject.cdn?).to
|
110
|
+
expect(subject.cdn?).to be(false)
|
109
111
|
end
|
110
112
|
|
111
113
|
it 'detects CDNs' do
|
112
114
|
records = [Dnsruby::RR.create(
|
113
|
-
type:
|
115
|
+
type: 'CNAME',
|
114
116
|
domainname: 'foo.cloudfront.net',
|
115
|
-
name:
|
117
|
+
name: 'example'
|
116
118
|
)]
|
117
119
|
allow(subject).to receive(:records) { records }
|
118
120
|
|
119
|
-
expect(subject.send(:detect_by_hostname, 'cdn')).to
|
120
|
-
expect(subject.cdn).to
|
121
|
-
expect(subject.cdn?).to
|
121
|
+
expect(subject.send(:detect_by_hostname, 'cdn')).to be(:cloudfront)
|
122
|
+
expect(subject.cdn).to be(:cloudfront)
|
123
|
+
expect(subject.cdn?).to be(true)
|
122
124
|
end
|
123
125
|
|
124
126
|
it 'builds that path to a data file' do
|
@@ -133,46 +135,46 @@ describe SiteInspector::Endpoint::Dns do
|
|
133
135
|
end
|
134
136
|
|
135
137
|
it "knows when a domain isn't cloud" do
|
136
|
-
expect(subject.cloud?).to
|
138
|
+
expect(subject.cloud?).to be(false)
|
137
139
|
end
|
138
140
|
|
139
141
|
it 'detects cloud providers' do
|
140
142
|
records = [Dnsruby::RR.create(
|
141
|
-
type:
|
143
|
+
type: 'CNAME',
|
142
144
|
domainname: 'foo.herokuapp.com',
|
143
|
-
name:
|
145
|
+
name: 'example'
|
144
146
|
)]
|
145
147
|
allow(subject).to receive(:records) { records }
|
146
148
|
|
147
|
-
expect(subject.send(:detect_by_hostname, 'cloud')).to
|
148
|
-
expect(subject.cloud_provider).to
|
149
|
-
expect(subject.cloud?).to
|
149
|
+
expect(subject.send(:detect_by_hostname, 'cloud')).to be(:heroku)
|
150
|
+
expect(subject.cloud_provider).to be(:heroku)
|
151
|
+
expect(subject.cloud?).to be(true)
|
150
152
|
end
|
151
153
|
|
152
154
|
it "knows when a domain doesn't have google apps" do
|
153
|
-
expect(subject.google_apps?).to
|
155
|
+
expect(subject.google_apps?).to be(false)
|
154
156
|
end
|
155
157
|
|
156
158
|
it 'knows when a domain is using google apps' do
|
157
159
|
records = [Dnsruby::RR.create(
|
158
|
-
type:
|
159
|
-
exchange:
|
160
|
-
name:
|
160
|
+
type: 'MX',
|
161
|
+
exchange: 'mx1.google.com',
|
162
|
+
name: 'example',
|
161
163
|
preference: 10
|
162
164
|
)]
|
163
165
|
allow(subject).to receive(:records) { records }
|
164
|
-
expect(subject.google_apps?).to
|
166
|
+
expect(subject.google_apps?).to be(true)
|
165
167
|
end
|
166
168
|
end
|
167
169
|
end
|
168
170
|
|
169
171
|
context 'localhost' do
|
170
172
|
before do
|
171
|
-
allow(subject).to receive(:ip)
|
173
|
+
allow(subject).to receive(:ip).and_return('127.0.0.1')
|
172
174
|
end
|
173
175
|
|
174
176
|
it "knows it's a localhost address" do
|
175
|
-
expect(subject.localhost?).to
|
177
|
+
expect(subject.localhost?).to be(true)
|
176
178
|
end
|
177
179
|
|
178
180
|
it 'returns a LocalhostError' do
|