akamai_rspec 1.2.0 → 1.2.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: b838b063b3c410a172becfed5baf405a63f1a8ce
|
4
|
+
data.tar.gz: 9a3f78d72d254edf06b87eae7336b1f3a764a67f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 002b45ff3aeb01872e98d84d1b4fde4c81acee696f80068a167d5a231deb6404656aa678d828570ae69725edd13700b271fa7defab5aaff36084f027984c37ce
|
7
|
+
data.tar.gz: fb59777170ccafbf8fa11c7b37d6f6277adf285a7bfda8b5bfe1359fdcaa395d56e09a3dc59312e89516e64917b66cd4a0f40d6226bcaa816a36ab3f071b9c3a
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module AkamaiRSpec
|
3
3
|
module Matchers
|
4
|
-
define :
|
4
|
+
define :be_forwarded_to_path do |channel|
|
5
5
|
match do |url|
|
6
6
|
response = Request.get(url)
|
7
7
|
session_info = response.headers[:x_akamai_session_info]
|
@@ -16,5 +16,7 @@ module AkamaiRSpec
|
|
16
16
|
response.code == 200 && outcome_url == channel
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
alias_method :be_forwarded_to_index, :be_forwarded_to_path
|
19
21
|
end
|
20
22
|
end
|
@@ -6,11 +6,12 @@ require 'uri'
|
|
6
6
|
module AkamaiRSpec
|
7
7
|
module Matchers
|
8
8
|
|
9
|
-
define :honour_origin_cache_headers do |origin, headers=:both|
|
9
|
+
define :honour_origin_cache_headers do |origin, headers=:both, max_clock_skew: 10|
|
10
10
|
header_options = [:cache_control, :expires, :both]
|
11
11
|
fail("Headers must be one of: #{header_options}") unless header_options.include? headers
|
12
12
|
|
13
13
|
match do |url|
|
14
|
+
@max_clock_skew = max_clock_skew
|
14
15
|
akamai_response = AkamaiRSpec::Request.get url
|
15
16
|
url = "http://" + url unless url =~ /^http/
|
16
17
|
origin_url = URI(url)
|
@@ -64,7 +65,7 @@ module AkamaiRSpec
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def max_age_to_num(max_age)
|
67
|
-
max_age.split('=').last.to_i
|
68
|
+
max_age.split('=').last.to_i rescue nil
|
68
69
|
end
|
69
70
|
|
70
71
|
def clean_max_age(cc_directives)
|
@@ -76,7 +77,9 @@ module AkamaiRSpec
|
|
76
77
|
def check_max_age(origin_cc_directives, akamai_cc_directives)
|
77
78
|
origin_max_age, origin_cc_directives = clean_max_age(origin_cc_directives)
|
78
79
|
akamai_max_age, akamai_cc_directives = clean_max_age(akamai_cc_directives)
|
79
|
-
if akamai_max_age
|
80
|
+
fail "Akamai sent a max-age but Origin did not" if akamai_max_age && origin_max_age.nil?
|
81
|
+
|
82
|
+
if (akamai_max_age && origin_max_age) && (akamai_max_age > origin_max_age)
|
80
83
|
fail "Akamai sent a max-age greater than Origin's: #{akamai_max_age} > #{origin_max_age}"
|
81
84
|
end
|
82
85
|
return origin_cc_directives, akamai_cc_directives
|
@@ -108,14 +111,25 @@ module AkamaiRSpec
|
|
108
111
|
def check_expires(origin_response, akamai_response, headers)
|
109
112
|
if [:both, :expires].include? headers
|
110
113
|
origin_expires, akamai_expires = expires(origin_response, akamai_response)
|
111
|
-
|
114
|
+
|
115
|
+
fail "Origin sent 'Expires: #{
|
116
|
+
origin_response.headers[:expires]
|
117
|
+
}' but Akamai sent 'Expires: #{
|
118
|
+
akamai_response.headers[:expires]
|
119
|
+
}', varies by #{
|
120
|
+
expires_diff origin_expires, akamai_expires
|
121
|
+
} seconds" unless expires_match?(origin_expires, akamai_expires)
|
122
|
+
|
112
123
|
end
|
113
124
|
end
|
114
125
|
|
115
|
-
def
|
116
|
-
|
117
|
-
|
118
|
-
|
126
|
+
def expires_match?(origin, akamai)
|
127
|
+
# Allow some clock skew
|
128
|
+
expires_diff(origin, akamai) <= @max_clock_skew
|
129
|
+
end
|
130
|
+
|
131
|
+
def expires_diff(origin, akamai)
|
132
|
+
((akamai || Time.now).to_i - (origin || Time.now).to_i).abs
|
119
133
|
end
|
120
134
|
|
121
135
|
def expires(origin_response, akamai_response)
|
@@ -28,8 +28,8 @@ module AkamaiRSpec
|
|
28
28
|
|
29
29
|
define :be_verifiably_secure do
|
30
30
|
match do |url|
|
31
|
-
return false if URI(url).scheme == "http"
|
32
31
|
url = "https://#{url}" unless URI(url).scheme
|
32
|
+
url = url.gsub(/^http:/, 'https:')
|
33
33
|
begin
|
34
34
|
# Avoid AkamaiRspec::Request as it turns off SSL checking
|
35
35
|
@response = RestClient::Request.execute(
|
@@ -41,14 +41,14 @@ module AkamaiRSpec
|
|
41
41
|
return true
|
42
42
|
rescue RestClient::MaxRedirectsReached
|
43
43
|
return true # Securely sent a redirect
|
44
|
-
rescue => e
|
44
|
+
rescue Exception => e
|
45
45
|
@error = e
|
46
46
|
return false
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
failure_message do |url|
|
51
|
-
"got error #{@error} fetching #{@response}"
|
51
|
+
"got error #{@error.inspect} fetching #{@response}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akamai_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bianca Gibson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-11-
|
12
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|