maestrano 1.0.2 → 1.0.3

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: 56c3af8152ca971c4cb5bfc68eacebce4209c888
4
- data.tar.gz: 6e2d651cb6952a278a690ce5f68f4f205cdaa8d4
3
+ metadata.gz: 239908d7d6161c0c1dfd044b94e1f8e7b381742a
4
+ data.tar.gz: c4623f9182b7f4c40a5a2477f537044254b5e9ef
5
5
  SHA512:
6
- metadata.gz: f1b301e71153a94101357c332f429de4aebea6eaea8b1b030891fba2b7465e2859e4f27ed60bc594c814da051ece6a5d5b97d67e0e6890840c57bb9cf0a92de2
7
- data.tar.gz: 964629739314c7c084228b80fecf885e6a3368a34428d1e744a732fe3368ac682696d61f48a66253682387c13d961948f2cf96c11b5b13f362af5cd3c91fbc5e
6
+ metadata.gz: 2f912056b8a6b04a24bcce09c762610cc9b26e0a6c0c6b8b9c78b0b30201b419c05c44d3ce1c55baa8002c93145740c30885c619ec4429c4bdf1cb302c48da8d
7
+ data.tar.gz: 1fe4792d3fa7223254cdf7bd3ea3ad41bd6335d915f1a2e3e84430e2ddc2e97ca5308c6be0a58ed75ce7422f9186f3e8b03e530cf563d79343e45ec20b76f351
@@ -41,9 +41,10 @@ module Maestrano
41
41
  return "#{host}#{path}"
42
42
  end
43
43
 
44
- def self.logout_url
44
+ def self.logout_url(user_uid = nil)
45
45
  host = Maestrano[preset].param('api.host')
46
46
  path = '/app_logout'
47
+ path = "#{path}?user_uid=#{user_uid}" if user_uid
47
48
  return "#{host}#{path}"
48
49
  end
49
50
 
@@ -1,3 +1,3 @@
1
1
  module Maestrano
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -3,41 +3,41 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Maestrano
4
4
  class SSOTest < Test::Unit::TestCase
5
5
  include SamlTestHelper
6
-
6
+
7
7
  context 'without preset' do
8
8
  setup do
9
9
  Maestrano.configs = nil
10
10
  Maestrano.configure { |config| config.environment = 'production' }
11
11
  end
12
-
12
+
13
13
  should "return the right init_url" do
14
14
  assert Maestrano::SSO.init_url == "http://localhost:3000/maestrano/auth/saml/init"
15
15
  end
16
-
16
+
17
17
  should "return the right consume_url" do
18
18
  assert Maestrano::SSO.consume_url == "http://localhost:3000/maestrano/auth/saml/consume"
19
19
  end
20
-
20
+
21
21
  should "return the right logout_url" do
22
22
  assert Maestrano::SSO.logout_url == "https://maestrano.com/app_logout"
23
23
  end
24
-
24
+
25
25
  should "return the right unauthorized_url" do
26
26
  assert Maestrano::SSO.unauthorized_url == "https://maestrano.com/app_access_unauthorized"
27
27
  end
28
-
28
+
29
29
  should "return the right idp_url" do
30
30
  assert Maestrano::SSO.idp_url == "https://maestrano.com/api/v1/auth/saml"
31
31
  end
32
-
32
+
33
33
  should "return the right session_check_url" do
34
34
  assert Maestrano::SSO.session_check_url('usr-1','f9ds8fdg7f89') == "https://maestrano.com/api/v1/auth/saml/usr-1?session=f9ds8fdg7f89"
35
35
  end
36
-
36
+
37
37
  should "return the right enabled parameter" do
38
38
  assert Maestrano::SSO.enabled? == !!Maestrano.param('sso.enabled')
39
39
  end
40
-
40
+
41
41
  should "return the right saml_settings" do
42
42
  settings = Maestrano::SSO.saml_settings
43
43
  assert settings.assertion_consumer_service_url == Maestrano::SSO.consume_url
@@ -47,20 +47,20 @@ module Maestrano
47
47
  assert settings.idp_cert_fingerprint == Maestrano.param('sso.x509_fingerprint')
48
48
  assert settings.name_identifier_format == Maestrano.param('sso.name_id_format')
49
49
  end
50
-
50
+
51
51
  should "build the right saml request" do
52
52
  request = mock('request')
53
53
  Maestrano::Saml::Request.stubs(:new).with(group_id: "cld-3").returns(request)
54
54
  assert Maestrano::SSO.build_request(group_id: "cld-3") == request
55
55
  end
56
-
56
+
57
57
  should "build the right saml response" do
58
58
  response = mock('response')
59
59
  Maestrano::Saml::Response.stubs(:new).with(response_document).returns(response)
60
60
  response = Maestrano::SSO.build_response(response_document)
61
61
  assert Maestrano::SSO.build_response(response_document) == response
62
62
  end
63
-
63
+
64
64
  context "session management" do
65
65
  setup do
66
66
  @session = {}
@@ -75,7 +75,7 @@ module Maestrano
75
75
  }
76
76
  }
77
77
  end
78
-
78
+
79
79
  should "set the session correctly" do
80
80
  Maestrano::SSO.set_session(@session,@auth)
81
81
  decrypt_session = JSON.parse(Base64.decode64(@session[:maestrano]))
@@ -84,19 +84,19 @@ module Maestrano
84
84
  assert_equal decrypt_session['session_recheck'], @auth[:extra][:session][:recheck].utc.iso8601
85
85
  assert_equal decrypt_session['group_uid'], @auth[:extra][:session][:group_uid]
86
86
  end
87
-
87
+
88
88
  should "unset the session correctly" do
89
89
  Maestrano::SSO.set_session(@session,@auth)
90
90
  Maestrano::SSO.clear_session(@session)
91
91
  assert @session[:maestrano].nil?
92
92
  end
93
-
93
+
94
94
  should "unset the session if key is a string" do
95
95
  @session['maestrano'] = "bla"
96
96
  Maestrano::SSO.clear_session(@session)
97
97
  assert @session["maestrano"].nil?
98
98
  end
99
-
99
+
100
100
  should "alias clear_session as unset_session" do
101
101
  Maestrano::SSO.set_session(@session,@auth)
102
102
  Maestrano::SSO.unset_session(@session)
@@ -112,10 +112,10 @@ module Maestrano
112
112
  @config = {
113
113
  'environment' => 'production',
114
114
  'app.host' => 'http://mysuperapp.com',
115
-
115
+
116
116
  'api.id' => 'app-f54ds4f8',
117
117
  'api.key' => 'someapikey',
118
-
118
+
119
119
  'sso.enabled' => false,
120
120
  'sso.slo_enabled' => false,
121
121
  'sso.init_path' => '/mno/sso/init',
@@ -127,7 +127,7 @@ module Maestrano
127
127
  @preset_config = {
128
128
  'environment' => 'production',
129
129
  'app.host' => 'http://myotherapp.com',
130
-
130
+
131
131
  'api.id' => 'app-553941',
132
132
  'api.key' => 'otherapikey',
133
133
 
@@ -142,10 +142,10 @@ module Maestrano
142
142
  Maestrano.configure do |config|
143
143
  config.environment = @config['environment']
144
144
  config.app.host = @config['app.host']
145
-
145
+
146
146
  config.api.id = @config['api.id']
147
147
  config.api.key = @config['api.key']
148
-
148
+
149
149
  config.sso.enabled = @config['sso.enabled']
150
150
  config.sso.slo_enabled = @config['sso.slo_enabled']
151
151
  config.sso.idm = @config['sso.idm']
@@ -153,14 +153,14 @@ module Maestrano
153
153
  config.sso.consume_path = @config['sso.consume_path']
154
154
  config.sso.creation_mode = @config['sso.creation_mode']
155
155
  end
156
-
156
+
157
157
  Maestrano[@preset].configure do |config|
158
158
  config.environment = @preset_config['environment']
159
159
  config.app.host = @preset_config['app.host']
160
-
160
+
161
161
  config.api.id = @preset_config['api.id']
162
162
  config.api.key = @preset_config['api.key']
163
-
163
+
164
164
  config.sso.enabled = @preset_config['sso.enabled']
165
165
  config.sso.slo_enabled = @preset_config['sso.slo_enabled']
166
166
  config.sso.idm = @preset_config['sso.idm']
@@ -169,35 +169,39 @@ module Maestrano
169
169
  config.sso.creation_mode = @preset_config['sso.creation_mode']
170
170
  end
171
171
  end
172
-
172
+
173
173
  should "return the right init_url" do
174
174
  assert_equal Maestrano::SSO[@preset].init_url, "http://idp.myotherapp.com/mno/sso/init"
175
175
  end
176
-
176
+
177
177
  should "return the right consume_url" do
178
178
  assert_equal Maestrano::SSO[@preset].consume_url, "http://idp.myotherapp.com/mno/sso/consume"
179
179
  end
180
-
180
+
181
181
  should "return the right logout_url" do
182
182
  assert_equal Maestrano::SSO[@preset].logout_url, "https://maestrano.com/app_logout"
183
183
  end
184
-
184
+
185
+ should "return the right logout_url with a user uid" do
186
+ assert_equal Maestrano::SSO[@preset].logout_url('usr-123'), "https://maestrano.com/app_logout?user_uid=usr-123"
187
+ end
188
+
185
189
  should "return the right unauthorized_url" do
186
190
  assert_equal Maestrano::SSO[@preset].unauthorized_url, "https://maestrano.com/app_access_unauthorized"
187
191
  end
188
-
192
+
189
193
  should "return the right idp_url" do
190
194
  assert_equal Maestrano::SSO[@preset].idp_url, "https://maestrano.com/api/v1/auth/saml"
191
195
  end
192
-
196
+
193
197
  should "return the right session_check_url" do
194
198
  assert_equal Maestrano::SSO[@preset].session_check_url('usr-1','f9ds8fdg7f89'), "https://maestrano.com/api/v1/auth/saml/usr-1?session=f9ds8fdg7f89"
195
199
  end
196
-
200
+
197
201
  should "return the right enabled parameter" do
198
202
  assert_equal Maestrano::SSO[@preset].enabled?, !!Maestrano[@preset].param('sso.enabled')
199
203
  end
200
-
204
+
201
205
  should "return the right saml_settings" do
202
206
  settings = Maestrano::SSO[@preset].saml_settings
203
207
  assert settings.assertion_consumer_service_url == Maestrano::SSO[@preset].consume_url
@@ -207,20 +211,20 @@ module Maestrano
207
211
  assert settings.idp_cert_fingerprint == Maestrano[@preset].param('sso.x509_fingerprint')
208
212
  assert settings.name_identifier_format == Maestrano[@preset].param('sso.name_id_format')
209
213
  end
210
-
214
+
211
215
  should "build the right saml request" do
212
216
  request = mock('request')
213
217
  Maestrano::Saml::Request.stubs(:new).with(group_id: "cld-3").returns(request)
214
218
  assert Maestrano::SSO[@preset].build_request(group_id: "cld-3") == request
215
219
  end
216
-
220
+
217
221
  should "build the right saml response" do
218
222
  response = mock('response')
219
223
  Maestrano::Saml::Response.stubs(:new).with(response_document).returns(response)
220
224
  response = Maestrano::SSO[@preset].build_response(response_document)
221
225
  assert Maestrano::SSO[@preset].build_response(response_document) == response
222
226
  end
223
-
227
+
224
228
  context "session management" do
225
229
  setup do
226
230
  @session = {}
@@ -235,7 +239,7 @@ module Maestrano
235
239
  }
236
240
  }
237
241
  end
238
-
242
+
239
243
  should "set the session correctly" do
240
244
  Maestrano::SSO[@preset].set_session(@session,@auth)
241
245
  decrypt_session = JSON.parse(Base64.decode64(@session[:maestrano]))
@@ -244,19 +248,19 @@ module Maestrano
244
248
  assert_equal decrypt_session['session_recheck'], @auth[:extra][:session][:recheck].utc.iso8601
245
249
  assert_equal decrypt_session['group_uid'], @auth[:extra][:session][:group_uid]
246
250
  end
247
-
251
+
248
252
  should "unset the session correctly" do
249
253
  Maestrano::SSO[@preset].set_session(@session,@auth)
250
254
  Maestrano::SSO[@preset].clear_session(@session)
251
255
  assert @session[:maestrano].nil?
252
256
  end
253
-
257
+
254
258
  should "unset the session if key is a string" do
255
259
  @session['maestrano'] = "bla"
256
260
  Maestrano::SSO[@preset].clear_session(@session)
257
261
  assert @session["maestrano"].nil?
258
262
  end
259
-
263
+
260
264
  should "alias clear_session as unset_session" do
261
265
  Maestrano::SSO[@preset].set_session(@session,@auth)
262
266
  Maestrano::SSO[@preset].unset_session(@session)
@@ -265,4 +269,4 @@ module Maestrano
265
269
  end
266
270
  end
267
271
  end
268
- end
272
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maestrano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client