http_redirect_test 1.0.0 → 1.0.1

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: 64f09a427c707013226be65e99ca2046031f4193
4
- data.tar.gz: 92ecc2d00aab3052558edd3793ae522e1b947943
3
+ metadata.gz: fdd78b6375f2b10f55086e406ac77edc594f0bf4
4
+ data.tar.gz: 573b470079c18697b89cd17517e3c1eeab5a05c4
5
5
  SHA512:
6
- metadata.gz: b6fde8b137000b1e2636c3cd3f6d9266413fe75831c60052409b00b980c2e44f770f7bfc1f2b413f01f91b19f3ed7f7cab436df52e72fec695e044f316014bb7
7
- data.tar.gz: 8d56d9b74eb42a453218b1ba164009db22ae5ac95501e5df9e85192c9d770df7a5528ba7c738929f9f22a15cc4e70c9bcf28b2e6ecaf606cf17f291b62efe622
6
+ metadata.gz: 18f9c82924efbf58027a1e4007ea87cff5b1a8ec946fdaa172957253a0a50b74ae4ab85951c0110ed847d2cf10e8072b14292324d8fda627c48f51d8d5930449
7
+ data.tar.gz: 8b8a657179793b9396a62a3035d835071f959e49fbdedd3a5a88016c8e5d6e6e0b7218b4b4be6ff7ab46fe82cd7fbbb9293548ef1da9a9f38740bf2d32ed8a93
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_redirect_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt House
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2010-10-21 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -76,12 +76,6 @@ files:
76
76
  - lib/http_redirect_test/http_redirect_test.rb
77
77
  - lib/http_redirect_test/redirect_check.rb
78
78
  - lib/http_redirect_test/resource_path.rb
79
- - test/integration_test.rb
80
- - test/test_app/test_redirect_server.rb
81
- - test/test_helper.rb
82
- - test/unit/http_redirect_test_test.rb
83
- - test/unit/redirect_check_test.rb
84
- - test/unit/resource_path_test.rb
85
79
  homepage: http://github.com/eightbitraptor/http_redirect_test
86
80
  licenses: []
87
81
  metadata: {}
@@ -1,69 +0,0 @@
1
- require 'http_redirect_test'
2
-
3
- class IntegrationTest < HTTPRedirectTest
4
- set_domain "localhost:4567"
5
-
6
- def test_not_redirect
7
- should_not_redirect '/ok'
8
- end
9
-
10
- def test_should_redirect_non_permanantly
11
- should_redirect '/redirect', to: '/ok'
12
- end
13
-
14
- def should_redirect_permanently
15
- should_redirect '/redirect_permanant', to: '/ok', permanent: true
16
- end
17
-
18
- def test_should_not_be_found
19
- should_not_be_found '/not_found'
20
- end
21
-
22
- def test_should_be_gone
23
- should_be_gone '/gone'
24
- end
25
-
26
- def test_custom_header
27
- should_have_header('/custom_header', 'X-One-Million-Years', with_value: 'Dungeon')
28
- end
29
- end
30
-
31
- class AllRedirectsArePermanent < HTTPRedirectTest
32
- set_domain "localhost:4567"
33
- treat_all_redirects_as_permanent
34
-
35
- def test_should_redirect
36
- should_redirect '/redirect_permanant', to: '/ok'
37
- end
38
-
39
- def test_non_permanent_redirect_should_fail
40
- assertion_failed = begin
41
- should_redirect '/redirect', to: '/ok'
42
- false
43
- rescue MiniTest::Assertion
44
- true
45
- end
46
-
47
- assert assertion_failed
48
- end
49
-
50
- def test_explicit_non_permanent_check_should_override
51
- should_redirect '/redirect', to: '/ok', permanent: false
52
- end
53
- end
54
-
55
- class DomainsWithExplicitSSLSchemes < HTTPRedirectTest
56
- set_domain "https://uk.yahoo.com"
57
-
58
- def test_should_not_redirect
59
- should_not_redirect '/'
60
- end
61
- end
62
-
63
- class DomainsWithExplicitNonSSLSchemes < HTTPRedirectTest
64
- set_domain "http://www.example.com"
65
-
66
- def test_should_not_redirect
67
- should_not_redirect '/'
68
- end
69
- end
@@ -1,28 +0,0 @@
1
- require 'sinatra'
2
-
3
- get '/ok' do
4
- status 200
5
- end
6
-
7
- get '/redirect' do
8
- redirect '/ok'
9
- end
10
-
11
- get '/redirect_permanant' do
12
- redirect '/ok', 301
13
- end
14
-
15
- get '/not_found' do
16
- status 404
17
- end
18
-
19
- get '/gone' do
20
- status 410
21
- end
22
-
23
- get '/custom_header' do
24
- headers['X-One-Million-Years'] = 'Dungeon'
25
- status 200
26
- end
27
-
28
-
@@ -1,5 +0,0 @@
1
- require 'minitest/autorun'
2
-
3
- require 'http_redirect_test'
4
- require 'mocha/mini_test'
5
-
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HttpRedirectTestTests < MiniTest::Test
4
- def test_that_permanent_flag_is_being_set_correctly
5
- assert_equal false, HTTPRedirectTest.permanent?
6
-
7
- HTTPRedirectTest.treat_all_redirects_as_permanent
8
-
9
- assert_equal true, HTTPRedirectTest.permanent?
10
- end
11
-
12
- def test_each_class_should_have_its_own_domain
13
- a = Class.new(HTTPRedirectTest)
14
- a.set_domain "a.example.com"
15
- b = Class.new(HTTPRedirectTest)
16
- b.set_domain "b.example.com"
17
- assert_equal "a.example.com", a.__send__(:domain)
18
- assert_equal "b.example.com", b.__send__(:domain)
19
- end
20
- end
@@ -1,82 +0,0 @@
1
- require 'test_helper'
2
- require 'net/http'
3
-
4
- class RedirectCheckTest < MiniTest::Test
5
-
6
- def test_redirect_check_supports_https
7
- assert_equal 'https', RedirectCheck.new('https://www.example.com', '/dontcare').uri.scheme
8
- end
9
-
10
- def test_that_redirect_checker_returns_legitimate_response
11
- stub_http_head_request(Net::HTTPOK)
12
- assert_equal @http_head, RedirectCheck.new("example.com", "/index.html").response
13
- end
14
-
15
- def test_that_http_ok_results_in_success
16
- stub_http_head_request(Net::HTTPOK)
17
- assert RedirectCheck.new("example.com", "/index.html").success?
18
- end
19
-
20
- def test_that_http_redirection_resuts_in_positive_redirection
21
- stub_http_head_request(Net::HTTPRedirection)
22
- assert RedirectCheck.new("example.com", "/index.html").redirected?
23
- end
24
-
25
- def test_that_http_301_resuts_in_permanent_redirection
26
- stub_http_head_request(Net::HTTPMovedPermanently)
27
- assert RedirectCheck.new("example.com", "/index.html").permanent_redirect?
28
- end
29
-
30
- def test_that_gone_page_returns_correctly
31
- stub_http_head_request(Net::HTTPGone)
32
- assert RedirectCheck.new("example.com", "/index.html").gone?
33
- end
34
-
35
- def test_that_not_found_page_returns_correctly
36
- stub_http_head_request(Net::HTTPNotFound)
37
- assert RedirectCheck.new("example.com", "/index.html").not_found?
38
- end
39
-
40
- def test_that_uri_can_be_built_correctly
41
- assert_equal RedirectCheck.new("example.com", "/index.html").uri, URI.parse("http://example.com/index.html")
42
- end
43
-
44
- def test_redirection_path
45
- stub_http_head_request(Net::HTTPMovedPermanently)
46
- r = RedirectCheck.new("example.com", "/index.html")
47
- r.response['location'] = "http://www.someurl.com"
48
-
49
- assert_equal "http://www.someurl.com", r.redirected_path
50
- end
51
-
52
- def test_redirection_path_without_query_params
53
- assert_equal "/index.html", RedirectCheck.new("example.com", "/index.html").source_uri
54
- end
55
-
56
- def test_redirection_path_with_query_params
57
- assert_equal "/index.html?foo=bar", RedirectCheck.new("example.com", "/index.html?foo=bar").source_uri
58
- end
59
-
60
- def test_request_for_specific_header
61
- stub_http_header('X-Powered-By', 'Pixies and Stardust')
62
- assert RedirectCheck.new("example.com", "/index.html").header('X-Powered-By') == "Pixies and Stardust"
63
- end
64
-
65
- private
66
- def stub_http_head_request(response_type)
67
- @http_head = response_type.new(stub, stub, stub)
68
- @http_session = stub(:session)
69
- @http_session.stubs(:head).with("/index.html").returns(@http_head)
70
- Net::HTTP.stubs(:start).with("example.com", 80, use_ssl: false).yields(@http_session)
71
- end
72
-
73
- def stub_http_header(header_name, value)
74
- http_head = Net::HTTPOK.new(stub, stub, stub)
75
- http_head.initialize_http_header({ header_name => value })
76
-
77
- http_session = stub(:session)
78
- http_session.stubs(:head).with("/index.html").returns(http_head)
79
-
80
- Net::HTTP.stubs(:start).with("example.com", 80, use_ssl: false).yields(http_session)
81
- end
82
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ResourcePathTest < MiniTest::Test
4
-
5
- def test_that_resource_path_is_created_successfully
6
- rp = ResourcePath.new("")
7
- assert rp.instance_of? ResourcePath
8
- end
9
- end