rspec-webservice_matchers 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/rspec/webservice_matchers/version.rb +1 -1
- data/lib/rspec/webservice_matchers.rb +15 -0
- data/rspec-webservice_matchers.gemspec +4 -3
- data/spec/rspec/webservice_matchers/redirect_spec.rb +7 -0
- data/spec/rspec/webservice_matchers/ssl_spec.rb +0 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c472ef9e63465a7b9f7bd04737b416ff434f006
|
4
|
+
data.tar.gz: 58e532ddd0b191bd9e847507d338dad1def28889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1afbddc25dd973f0c9e9fc5408ecaa2eb0abe0f3a3e6a61d8f783aabb5421fdf9ab73465440b46bd1bc7ebde44ac04bb12c691737fd93ee5d0ee1d0764e86e27
|
7
|
+
data.tar.gz: 91dd16db14d9b0c71bae672fc02a97f726b16fde994e8b7919648777f6ccf5015fa3489be1e2a17811240ac7b1375d2065b71b22e3349fed3ec229f063a45e73
|
data/README.md
CHANGED
@@ -12,7 +12,11 @@ $ gem install rspec-webservice_matchers
|
|
12
12
|
Example
|
13
13
|
-------
|
14
14
|
|
15
|
-
Currently,
|
15
|
+
Currently, three matchers are implemented:
|
16
|
+
|
17
|
+
* `have_a_valid_cert`
|
18
|
+
* `redirect_permanently_to`
|
19
|
+
* `enforce_https_everywhere` (See the [EFF site](https://www.eff.org/https-everywhere) for more info)
|
16
20
|
|
17
21
|
```Ruby
|
18
22
|
require 'rspec/webservice_matchers'
|
@@ -25,6 +29,10 @@ describe 'My app' do
|
|
25
29
|
it 'redirects to www' do
|
26
30
|
expect('http://myapp.com').to redirect_permanently_to 'http://www.myapp.com/'
|
27
31
|
end
|
32
|
+
|
33
|
+
it 'forces visitors to use https' do
|
34
|
+
expect('myapp.com').to enforce_https_everywhere
|
35
|
+
end
|
28
36
|
end
|
29
37
|
```
|
30
38
|
|
@@ -57,5 +57,20 @@ module RSpec
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
RSpec::Matchers.define :enforce_https_everywhere do
|
61
|
+
match do |domain_name|
|
62
|
+
# TODO: Refactor this code. Submit as pull request to Curb.
|
63
|
+
result = Curl::Easy.http_head("http://#{domain_name}")
|
64
|
+
header_lines = result.head.split("\r\n")
|
65
|
+
header_lines.delete_at(0) # The first reponse header is already parsed.
|
66
|
+
header = {}
|
67
|
+
header_lines.each do |line|
|
68
|
+
key, value = line.split(': ')
|
69
|
+
header[key] = value
|
70
|
+
end
|
71
|
+
(result.response_code == 301) && (/https/ === header['Location'])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
60
75
|
end
|
61
76
|
end
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = RSpec::WebserviceMatchers::VERSION
|
9
9
|
spec.authors = ["Robb Shecter"]
|
10
10
|
spec.email = ["robb@weblaws.org"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{Black-box web app configuration testing}
|
12
|
+
spec.summary = %q{Black-box web app configuration testing}
|
13
13
|
spec.homepage = "https://github.com/dogweather/rspec-webservice_matchers"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'curb',
|
24
|
+
spec.add_runtime_dependency 'curb', '~> 0.8'
|
25
|
+
spec.add_runtime_dependency 'rspec', '~> 3.0'
|
25
26
|
end
|
@@ -6,3 +6,10 @@ describe 'redirect_permanently_to' do
|
|
6
6
|
expect('http://weblaws.org').to redirect_permanently_to('http://www.weblaws.org/')
|
7
7
|
end
|
8
8
|
end
|
9
|
+
|
10
|
+
# See https://www.eff.org/https-everywhere
|
11
|
+
describe 'enforce_https_everywhere' do
|
12
|
+
it 'passes when http requests are redirected to https urls' do
|
13
|
+
expect('eff.org').to enforce_https_everywhere
|
14
|
+
end
|
15
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rspec/webservice_matchers'
|
2
2
|
|
3
3
|
describe 'have_a_valid_cert matcher' do
|
4
|
-
|
5
4
|
it 'passes when SSL is properly configured' do
|
6
5
|
# EFF created the HTTPS Everywhere movement
|
7
6
|
# TODO: set up a test server for this.
|
@@ -15,5 +14,4 @@ describe 'have_a_valid_cert matcher' do
|
|
15
14
|
expect('www.psu.edu').to have_a_valid_cert
|
16
15
|
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-webservice_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
@@ -52,7 +52,21 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.8'
|
55
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Black-box web app configuration testing
|
56
70
|
email:
|
57
71
|
- robb@weblaws.org
|
58
72
|
executables: []
|
@@ -92,7 +106,7 @@ rubyforge_project:
|
|
92
106
|
rubygems_version: 2.2.1
|
93
107
|
signing_key:
|
94
108
|
specification_version: 4
|
95
|
-
summary:
|
109
|
+
summary: Black-box web app configuration testing
|
96
110
|
test_files:
|
97
111
|
- spec/rspec/webservice_matchers/redirect_spec.rb
|
98
112
|
- spec/rspec/webservice_matchers/ssl_spec.rb
|