rspec-webservice_matchers 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8651a565b58e694aaded1c7e89faf9ee79f2b020
|
4
|
+
data.tar.gz: 1cf00d26f4cd5dd7f3e7697429f2662b316012ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6e385cbee4b154cfd367270e4dad775cf2028a142f70481e4f70a22f3e20cdba3831f850e0b78dbaef2ae2aeb49c3ed6234e1625e51686d7143224d91d813a
|
7
|
+
data.tar.gz: a95d2c497c4023d43a8501574e38817e5ae97a3abc18ac4fc14ad9bd99bf35f9e70daa2d9df64a9ccab95b6d68177b371eeb2195247adfc04f4c4bc09dfc1c46
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'rspec/webservice_matchers/util'
|
3
|
+
require 'rspec/webservice_matchers/redirect_helpers'
|
3
4
|
|
4
5
|
module RSpec
|
5
6
|
module WebserviceMatchers
|
@@ -9,6 +10,7 @@ module RSpec
|
|
9
10
|
# 2. to an https url
|
10
11
|
# 3. which is correctly configured
|
11
12
|
RSpec::Matchers.define :enforce_https_everywhere do
|
13
|
+
include RedirectHelpers
|
12
14
|
error_msg = status = final_protocol = has_valid_cert = nil
|
13
15
|
|
14
16
|
match do |domain_name|
|
@@ -30,7 +32,7 @@ module RSpec
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def meets_expectations?(status, protocol, valid_cert)
|
33
|
-
(status
|
35
|
+
permanent_redirect?(status) && (protocol == 'https') && valid_cert
|
34
36
|
end
|
35
37
|
|
36
38
|
# Create a compound error message listing all of the
|
@@ -40,13 +42,15 @@ module RSpec
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def higher_level_errors(status, protocol, cert_is_valid)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
mesgs << "destination uses protocol #{protocol.upcase}"
|
45
|
+
errors = []
|
46
|
+
unless permanent_redirect?(status)
|
47
|
+
errors << "received status #{status} instead of 301"
|
47
48
|
end
|
48
|
-
|
49
|
-
|
49
|
+
if protocol && (protocol != 'https')
|
50
|
+
errors << "destination uses protocol #{protocol.upcase}"
|
51
|
+
end
|
52
|
+
errors << "there's no valid SSL certificate" unless cert_is_valid
|
53
|
+
Util.error_message(errors)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|