kensa 1.2.0rc7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,130 +0,0 @@
1
- $:.unshift(File.expand_path("../..",__FILE__))
2
- require 'test/helper'
3
- require 'cgi'
4
-
5
- module SsoSetupActions
6
- include Heroku::Kensa
7
-
8
- def sso_setup
9
- Timecop.freeze Time.utc(2010, 1)
10
- @data = Manifest.new.skeleton.merge(:id => 1)
11
- @data['api']['test'] = 'http://localhost:4567/'
12
- @data['api']['sso_salt'] = 'SSO_SALT'
13
- @sso = Sso.new @data
14
- end
15
-
16
- def asserts_builds_full_url(env)
17
- url, query = @sso.full_url.split('?')
18
- data = CGI.parse(query)
19
-
20
- assert_equal "#{@data['api'][env]}heroku/resources/1", url
21
- assert_equal 'b6010f6fbb850887a396c2bc0ab23974003008f6', data['token'].first
22
- assert_equal '1262304000', data['timestamp'].first
23
- assert_equal 'username@example.com', data['user'].first
24
- end
25
- end
26
-
27
- class SsoLaunchTest < Test::Unit::TestCase
28
- include SsoSetupActions
29
-
30
- def setup
31
- super
32
- sso_setup
33
- end
34
-
35
- def test_builds_path
36
- assert_equal '/heroku/resources/1', @sso.path
37
- end
38
-
39
- def test_builds_full_url
40
- asserts_builds_full_url('test')
41
- end
42
- end
43
-
44
- class SsoGetLaunchTest < Test::Unit::TestCase
45
- include SsoSetupActions
46
-
47
- def setup
48
- super
49
- sso_setup
50
- @data["api"]["test"] = "http://example.org/"
51
- @sso = Sso.new(@data).start
52
- end
53
-
54
- def test_sso_url_should_be_the_full_url
55
- assert_equal @sso.full_url, @sso.sso_url
56
- end
57
-
58
- def test_message_is_opening_full_url
59
- assert_equal "Opening #{@sso.full_url}", @sso.message
60
- end
61
- end
62
-
63
- class SsoPostLaunchTest < Test::Unit::TestCase
64
- include SsoSetupActions
65
-
66
- def setup
67
- super
68
- sso_setup
69
- @data['api']['test'] = {
70
- "base_url" => "http://localhost:4567",
71
- "sso_url" => "http://localhost:4567/users/login/sso"
72
- }
73
- end
74
-
75
- def test_it_starts_the_proxy_server
76
- Artifice.deactivate
77
- @sso = Sso.new(@data).start
78
- body = RestClient.get(@sso.sso_url)
79
-
80
- assert body.include? 'b6010f6fbb850887a396c2bc0ab23974003008f6'
81
- assert body.include? '1262304000'
82
- assert body.include? @sso.url
83
- assert body.include? @sso.sample_nav_data
84
- end
85
- end
86
-
87
- class SsoPostProxyLaunchTest < Test::Unit::TestCase
88
- include SsoSetupActions
89
-
90
- def setup
91
- super
92
- sso_setup
93
- @data['api']['test'] = {
94
- "base_url" => "http://localhost:4567",
95
- "sso_url" => "http://localhost:4567/users/login/sso"
96
- }
97
- any_instance_of(Sso, :run_proxy => false)
98
- @sso = Sso.new(@data).start
99
- end
100
-
101
- def test_sso_url_should_point_to_the_proxy
102
- assert_equal "http://localhost:#{@sso.proxy_port}/", @sso.sso_url
103
- end
104
-
105
- def test_post_url_contains_url_and_path
106
- assert_equal "http://localhost:4567/users/login/sso", @sso.post_url
107
- end
108
-
109
- def test_message_is_posting_data_to_post_url_via_proxy_on_port_proxy_port
110
- assert_equal "POSTing #{@sso.query_data} to #{@sso.post_url} via proxy on port #{@sso.proxy_port}", @sso.message
111
- end
112
- end
113
-
114
- class SsoEnvironmentLaunchTest < Test::Unit::TestCase
115
- include SsoSetupActions
116
-
117
- def setup
118
- super
119
- sso_setup
120
- env = 'production'
121
- @data[:env] = env
122
- @data['api'][env] = 'http://localhost:7654/'
123
-
124
- @sso = Sso.new @data
125
- end
126
-
127
- def test_builds_full_url
128
- asserts_builds_full_url('production')
129
- end
130
- end