akamai_rspec 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38c12fef545212e77f64ed648c186bfd23d69edc
4
- data.tar.gz: 34a2be235eb450581d70bd5a24dcd6cc625e0941
3
+ metadata.gz: 07fe4b6c45db380b71ff544f77ae226a4cc74809
4
+ data.tar.gz: b1f5f15809c6003669937c1466db669c6b9a4c27
5
5
  SHA512:
6
- metadata.gz: 9095d501406f200e279d215860fa08b3c470e717cd42055e3add2876b7035619f83b40ebe2e72041e3776fcca056387e14757c33e7a5f3bfee0eba9c2dfc2a66
7
- data.tar.gz: 945d08c9fccc3c7446fae578d49ee8198cf48d8d0ab3fbf2420df7ed908ff833adb7c93e5bd4c5cfe005ec5d771a20e1ef8c174cb31fb8819c6e8bd136c60c7d
6
+ metadata.gz: a1c3e9b1f6bfa2ad4aa0c1b72f0775c1dae149e20dac1ac07b306b2763b2b240285b1e1af7eb470a9f740e2d7be16bf5de8617f2170f44d34b00131d511dabf2
7
+ data.tar.gz: 8116ec3976984834df9d42218aa284960cd2aed54b1379f6b47dfba0524acb28b348fbb3dc2a17298073e69caa6fd9d54395347c57212bf3c86123db7f32ee66
@@ -15,8 +15,8 @@ module AkamaiRSpec
15
15
  return secure, url
16
16
  end
17
17
 
18
- def redirect(url, expected_location, expected_response_code)
19
- response = AkamaiRSpec::Request.get(url)
18
+ def redirect(url, expected_location, expected_response_code, headers)
19
+ response = AkamaiRSpec::Request.get(url, headers)
20
20
  fail "Response was #{response.inspect}, expected code #{expected_response_code}" unless response.code == expected_response_code
21
21
  unless expected_location === response.headers[:location]
22
22
  fail "redirect location was #{response.headers[:location]} (expected #{expected_location})"
@@ -32,8 +32,15 @@ module AkamaiRSpec
32
32
  url = "https://#{url}" unless URI(url).scheme
33
33
  begin
34
34
  # Avoid AkamaiRspec::Request as it turns off SSL checking
35
- @response = RestClient::Request.execute(method: :get, url: url, verify_ssl: OpenSSL::SSL::VERIFY_PEER)
35
+ @response = RestClient::Request.execute(
36
+ method: :get,
37
+ url: url,
38
+ max_redirects: 0,
39
+ verify_ssl: OpenSSL::SSL::VERIFY_PEER
40
+ )
36
41
  return true
42
+ rescue RestClient::MaxRedirectsReached
43
+ return true # Securely sent a redirect
37
44
  rescue => e
38
45
  @error = e
39
46
  return false
@@ -4,49 +4,59 @@ require 'akamai_rspec/helpers/chainable_redirect'
4
4
 
5
5
  module AkamaiRSpec
6
6
  module Matchers
7
- define :be_permanently_redirected_to do |expected_location|
7
+ define :be_permanently_redirected_to do |expected_location, headers: {}|
8
8
  include AkamaiRSpec::Helpers::ChainableRedirect
9
9
  match do |url|
10
- redirect(url, expected_location, 301)
10
+ redirect(url, expected_location, 301, headers)
11
11
  end
12
12
  end
13
13
 
14
- define :be_temporarily_redirected_to do |expected_location|
14
+ define :be_temporarily_redirected_to do |expected_location, headers: {}|
15
15
  include AkamaiRSpec::Helpers::ChainableRedirect
16
16
  match do |url|
17
- redirect(url, expected_location, 302)
17
+ redirect(url, expected_location, 302, headers)
18
18
  end
19
19
  end
20
20
 
21
- define :redirect_http_to_https do |with: 301|
21
+ define :redirect_http_to_https do |with: 301, headers: {}|
22
22
  include AkamaiRSpec::Helpers::ChainableRedirect
23
23
  match do |url|
24
24
  secure, url = with_and_without_tls(url)
25
- redirect(url, secure, with)
25
+ redirect(url, secure, with, headers)
26
26
  end
27
27
  end
28
28
 
29
- define :redirect_https_to_http do |with: 301|
29
+ define :redirect_https_to_http do |with: 301, headers: {}|
30
30
  include AkamaiRSpec::Helpers::ChainableRedirect
31
31
  match do |url|
32
32
  secure, url = with_and_without_tls(url)
33
- redirect(secure, url, with)
33
+ redirect(secure, url, with, headers)
34
34
  end
35
35
  end
36
36
 
37
- define :redirect_to_add_trailing_slash do |with: 301|
37
+ define :redirect_to_remove_trailing_slash do |with: 301, headers: {}|
38
38
  include AkamaiRSpec::Helpers::ChainableRedirect
39
39
  match do |url|
40
40
  without_trailing_slash = url.gsub(/\/+$/, '')
41
41
  with_trailing_slash = without_trailing_slash + "/"
42
- redirect(without_trailing_slash, with_trailing_slash, with)
42
+ redirect(with_trailing_slash, without_trailing_slash, with, headers)
43
+ end
44
+ end
45
+
46
+ define :redirect_to_add_trailing_slash do |with: 301, headers: {}|
47
+ include AkamaiRSpec::Helpers::ChainableRedirect
48
+ match do |url|
49
+ without_trailing_slash = url.gsub(/\/+$/, '')
50
+ with_trailing_slash = without_trailing_slash + "/"
51
+ redirect(without_trailing_slash, with_trailing_slash, with, headers)
43
52
  end
44
53
  end
45
54
 
46
55
  define :be_temporarily_redirected_with_trailing_slash do
47
56
  include AkamaiRSpec::Helpers::ChainableRedirect
48
57
  match do |url|
49
- redirect(url, url + '/', 302)
58
+ puts "be_temporarily_redirected_with_trailing_slash is deprecated and will be removed in 2.0; use redirect_to_add_trailing_slash(with: 302)"
59
+ redirect(url, url + '/', 302, {})
50
60
  end
51
61
  end
52
62
  end
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.0.1
4
+ version: 1.1.0
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-02 00:00:00.000000000 Z
12
+ date: 2016-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client