maestrano 1.0.0.pre.RC4 → 1.0.0.pre.RC5

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: 7bbd3569f7e1c43bb9aba22ab88c4e6dab4c0313
4
- data.tar.gz: 0d04bfbf3ad9d3c059a1d8be39c8da9434975a66
3
+ metadata.gz: 026f33b3cb669405a068fd77f74860e6767950d8
4
+ data.tar.gz: 6a04ca35d44ddeb69ba115f09d43157c6cb55b6a
5
5
  SHA512:
6
- metadata.gz: bc91f23cac0658609f646aca6d92bb1f356afb0dae8c8310e573e2a665ac820ec91255287ffe3df53a5d4dcc224728e032c989efe451e280a0c2b757d88e20cf
7
- data.tar.gz: 2e2dbbc2f898e695e96f3aacac967f38c1137fe171659e8df046d5ad0382d9bc1deafcace9dd75fe28c832905986403b1072cafa5050f23463ea9abb8231821b
6
+ metadata.gz: 83aa95476fd6c663d3a091fe521c6f917fc925dbd16b315663b47cc486ddd301af58b01a987421992feb99714d8aa5b368a62a150e803c657f4210879a6bde06
7
+ data.tar.gz: a2b69dadf460026c307716e57466225071a34fbd01cd6d98bdc80226ffe481c6b8630eb6def6824b4d372283430f1184711d0289926745026b25261a10502545
data/lib/maestrano.rb CHANGED
@@ -278,7 +278,7 @@ module Maestrano
278
278
  last_prop = props.pop
279
279
  obj = props.inject(self,:send)
280
280
  obj.send(last_prop)
281
- elsif EVT_CONFIG[@environment.to_s].has_key?(real_param.to_s)
281
+ elsif EVT_CONFIG.has_key?(@environment.to_s) && EVT_CONFIG[@environment.to_s].has_key?(real_param.to_s)
282
282
  EVT_CONFIG[@environment.to_s][real_param.to_s]
283
283
  else
284
284
  raise ArgumentError, "No such configuration parameter: '#{parameter}'"
data/lib/maestrano/sso.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Maestrano
2
2
  module SSO
3
3
  include Preset
4
-
4
+
5
5
  # Return the saml_settings based on
6
6
  # Maestrano configuration
7
7
  def self.saml_settings
@@ -14,75 +14,75 @@ module Maestrano
14
14
  settings.name_identifier_format = Maestrano[preset].param('sso.name_id_format')
15
15
  settings
16
16
  end
17
-
17
+
18
18
  # Build a new SAML Request
19
19
  def self.build_request(get_params = {})
20
20
  Maestrano::Saml::Request[preset].new(get_params)
21
21
  end
22
-
22
+
23
23
  # Build a new SAML response
24
24
  def self.build_response(saml_post_param)
25
25
  Maestrano::Saml::Response[preset].new(saml_post_param)
26
26
  end
27
-
27
+
28
28
  def self.enabled?
29
29
  !!Maestrano[preset].param('sso.enabled')
30
30
  end
31
-
31
+
32
32
  def self.init_url
33
33
  host = Maestrano[preset].param('sso.idm')
34
34
  path = Maestrano[preset].param('sso.init_path')
35
35
  return "#{host}#{path}"
36
36
  end
37
-
37
+
38
38
  def self.consume_url
39
39
  host = Maestrano[preset].param('sso.idm')
40
40
  path = Maestrano[preset].param('sso.consume_path')
41
41
  return "#{host}#{path}"
42
42
  end
43
-
43
+
44
44
  def self.logout_url
45
- host = Maestrano[preset].param('api_host')
45
+ host = Maestrano[preset].param('api.host')
46
46
  path = '/app_logout'
47
47
  return "#{host}#{path}"
48
48
  end
49
-
49
+
50
50
  def self.unauthorized_url
51
- host = Maestrano[preset].param('api_host')
51
+ host = Maestrano[preset].param('api.host')
52
52
  path = '/app_access_unauthorized'
53
53
  return "#{host}#{path}";
54
54
  end
55
-
55
+
56
56
  def self.idp_url
57
- host = Maestrano[preset].param('api_host')
58
- api_base = Maestrano[preset].param('api_base')
57
+ host = Maestrano[preset].param('api.host')
58
+ api_base = Maestrano[preset].param('api.base')
59
59
  endpoint = 'auth/saml'
60
60
  return "#{host}#{api_base}#{endpoint}"
61
61
  end
62
-
63
- def self.session_check_url(user_uid,sso_session)
64
- host = Maestrano[preset].param('api_host')
65
- api_base = Maestrano[preset].param('api_base')
62
+
63
+ def self.session_check_url(user_uid,sso_session)
64
+ host = Maestrano[preset].param('api.host')
65
+ api_base = Maestrano[preset].param('api.base')
66
66
  endpoint = 'auth/saml'
67
67
  return URI.escape("#{host}#{api_base}#{endpoint}/#{user_uid}?session=#{sso_session}")
68
68
  end
69
-
69
+
70
70
  # Set maestrano attributes in session
71
71
  # Takes the BaseUser hash representation and current session
72
72
  # in arguments
73
73
  def self.set_session(session, auth)
74
74
  Maestrano::SSO::Session[preset].from_user_auth_hash(session,auth).save
75
75
  end
76
-
76
+
77
77
  # Destroy the maestrano session in http session
78
78
  def self.clear_session(session)
79
79
  session.delete(:maestrano)
80
80
  session.delete('maestrano')
81
81
  end
82
-
82
+
83
83
  # Metaclass definitions
84
84
  class << self
85
85
  alias_method :unset_session, :clear_session
86
86
  end
87
87
  end
88
- end
88
+ end
@@ -1,3 +1,3 @@
1
1
  module Maestrano
2
- VERSION = '1.0.0.pre.RC4'
2
+ VERSION = '1.0.0.pre.RC5'
3
3
  end
@@ -4,7 +4,7 @@ module Maestrano
4
4
  module Account
5
5
  class RecurringBillTest < Test::Unit::TestCase
6
6
  include APITestHelper
7
-
7
+
8
8
  should "be listable" do
9
9
  @api_mock.expects(:get).once.returns(test_response(test_account_recurring_bill_array))
10
10
  c = Maestrano::Account::RecurringBill.all
@@ -31,7 +31,7 @@ module Maestrano
31
31
 
32
32
  should "successfully create a remote bill when passed correct parameters" do
33
33
  @api_mock.expects(:post).with do |url, api_token, params|
34
- url == "#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/recurring_bills" && api_token.nil? &&
34
+ url == "#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/recurring_bills" && api_token.nil? &&
35
35
  CGI.parse(params) == {"group_id"=>["cld-1"], "price_cents"=>["23000"], "currency"=>["AUD"], "description"=>["Some recurring bill"], "period"=>["Month"]}
36
36
  end.once.returns(test_response(test_account_recurring_bill))
37
37
 
@@ -46,4 +46,4 @@ module Maestrano
46
46
  end
47
47
  end
48
48
  end
49
- end
49
+ end
@@ -5,7 +5,7 @@ module Maestrano
5
5
  module API
6
6
  class ResourceTest < Test::Unit::TestCase
7
7
  include APITestHelper
8
-
8
+
9
9
  should "creating a new Resource should not fetch over the network" do
10
10
  @api_mock.expects(:get).never
11
11
  Maestrano::Account::Bill.new("someid")
@@ -61,11 +61,11 @@ module Maestrano
61
61
  @original_api_key = Maestrano.param('api.key')
62
62
  Maestrano.configure { |c| c.api_key = nil }
63
63
  end
64
-
64
+
65
65
  teardown do
66
66
  Maestrano.configure { |c| c.api_key = @original_api_key }
67
67
  end
68
-
68
+
69
69
  should "use the per-object credential when creating" do
70
70
  Maestrano::API::Operation::Base.expects(:execute_request).with do |opts|
71
71
  opts[:headers][:authorization] == "Basic #{Base64.strict_encode64('someid:somekey')}"
@@ -103,22 +103,22 @@ module Maestrano
103
103
  context "with valid credentials" do
104
104
  should "urlencode values in GET params" do
105
105
  response = test_response(test_account_bill_array)
106
- @api_mock.expects(:get).with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills?bill=test%20bill", nil, nil).returns(response)
106
+ @api_mock.expects(:get).with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills?bill=test%20bill", nil, nil).returns(response)
107
107
  bills = Maestrano::Account::Bill.all(:bill => 'test bill').data
108
108
  assert bills.kind_of? Array
109
109
  end
110
110
 
111
111
  should "construct URL properly with base query parameters" do
112
112
  response = test_response(test_account_bill_array)
113
- @api_mock.expects(:get).with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills?bill=test_account_bill", nil, nil).returns(response)
113
+ @api_mock.expects(:get).with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills?bill=test_account_bill", nil, nil).returns(response)
114
114
  bills = Maestrano::Account::Bill.all(:bill => 'test_account_bill')
115
115
 
116
-
116
+
117
117
  end
118
-
118
+
119
119
  should "construct URL properly with multiple query parameters" do
120
120
  response = test_response(test_account_bill_array)
121
- @api_mock.expects(:get).with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills?bill=test_account_bill&paid=true", nil, nil).returns(response)
121
+ @api_mock.expects(:get).with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills?bill=test_account_bill&paid=true", nil, nil).returns(response)
122
122
  bills = Maestrano::Account::Bill.all(bill:'test_account_bill', paid: true)
123
123
  end
124
124
 
@@ -162,15 +162,15 @@ module Maestrano
162
162
  @api_mock.expects(:get).with do |url, api_token, params|
163
163
  uri = URI(url)
164
164
  query = CGI.parse(uri.query)
165
- (url =~ %r{^#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills?} &&
165
+ (url =~ %r{^#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills?} &&
166
166
  query.keys.sort == ['offset', 'sad'])
167
167
  end.returns(test_response(test_account_bill_array_one))
168
168
  Maestrano::Account::Bill.all(:count => nil, :offset => 5, :sad => false)
169
169
  end
170
-
170
+
171
171
  should "setting a nil value for a param should exclude that param from the POST request" do
172
172
  @api_mock.expects(:post).with do |url, api_token, params|
173
- url == "#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills" &&
173
+ url == "#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills" &&
174
174
  api_token.nil? &&
175
175
  CGI.parse(params) == { 'group_id' => ['cld-1'], 'price_cents' => ['23000'], 'currency' => ['AUD'] }
176
176
  end.returns(test_response(test_account_bill))
@@ -184,7 +184,7 @@ module Maestrano
184
184
 
185
185
  should "requesting with a unicode ID should result in a request" do
186
186
  response = test_response(test_missing_id_error, 404)
187
- @api_mock.expects(:get).once.with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills/%E2%98%83", nil, nil).raises(RestClient::ExceptionWithResponse.new(response, 404))
187
+ @api_mock.expects(:get).once.with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills/%E2%98%83", nil, nil).raises(RestClient::ExceptionWithResponse.new(response, 404))
188
188
  c = Maestrano::Account::Bill.new("☃")
189
189
  assert_raises(Maestrano::API::Error::InvalidRequestError) { c.refresh }
190
190
  end
@@ -196,7 +196,7 @@ module Maestrano
196
196
 
197
197
  should "making a GET request with parameters should have a query string and no body" do
198
198
  params = { :limit => 1 }
199
- @api_mock.expects(:get).once.with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills?limit=1", nil, nil).returns(test_response(test_account_bill_array_one))
199
+ @api_mock.expects(:get).once.with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills?limit=1", nil, nil).returns(test_response(test_account_bill_array_one))
200
200
  Maestrano::Account::Bill.all(params)
201
201
  end
202
202
 
@@ -210,7 +210,7 @@ module Maestrano
210
210
  period_started_at: date
211
211
  }
212
212
  @api_mock.expects(:post).once.with do |url, get, post|
213
- get.nil? &&
213
+ get.nil? &&
214
214
  CGI.parse(post) == {"group_id"=>["cld-1"], "price_cents"=>["23000"], "currency"=>["AUD"], "description"=>["Some bill"], "period_started_at" => ["#{date.iso8601}"]}
215
215
  end.returns(test_response(test_account_bill))
216
216
  Maestrano::Account::Bill.create(params)
@@ -242,15 +242,15 @@ module Maestrano
242
242
 
243
243
  should "updating an object should issue a PUT request with only the changed properties" do
244
244
  @api_mock.expects(:put).with do |url, api_token, params|
245
- url == "#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills/bill-1" &&
245
+ url == "#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills/bill-1" &&
246
246
  api_token.nil? && CGI.parse(params) == {'description' => ['another_mn']}
247
247
  end.once.returns(test_response(test_account_bill))
248
-
248
+
249
249
  c = Maestrano::Account::Bill.construct_from(test_account_bill[:data])
250
250
  class << c
251
251
  include Maestrano::API::Operation::Update
252
252
  end
253
-
253
+
254
254
  c.description = "another_mn"
255
255
  c.save
256
256
  end
@@ -261,7 +261,7 @@ module Maestrano
261
261
  class << c
262
262
  include Maestrano::API::Operation::Update
263
263
  end
264
-
264
+
265
265
  c.description = "another_mn"
266
266
  c.save
267
267
  end
@@ -269,7 +269,7 @@ module Maestrano
269
269
  should "deleting should send no props and result in an object that has no props other deleted" do
270
270
  @api_mock.expects(:get).never
271
271
  @api_mock.expects(:post).never
272
- @api_mock.expects(:delete).with("#{Maestrano.param('api_host')}#{Maestrano.param('api_base')}account/bills/bill-1", nil, nil).once.returns(test_response(test_account_bill))
272
+ @api_mock.expects(:delete).with("#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/bills/bill-1", nil, nil).once.returns(test_response(test_account_bill))
273
273
 
274
274
  c = Maestrano::Account::Bill.construct_from(test_account_bill[:data])
275
275
  class << c
@@ -295,7 +295,7 @@ module Maestrano
295
295
  c = Maestrano::Account::Bill.all.data
296
296
  assert c.kind_of? Array
297
297
  assert c[0].kind_of? Maestrano::Account::Bill
298
-
298
+
299
299
  # No object to test for the moment
300
300
  #assert c[0].card.kind_of?(Maestrano::API::Object) && c[0].card.object == 'card'
301
301
  end
@@ -335,9 +335,9 @@ module Maestrano
335
335
 
336
336
  assert_equal true, rescued
337
337
  end
338
-
338
+
339
339
  end
340
340
  end
341
341
  end
342
342
  end
343
- end
343
+ 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.0.pre.RC4
4
+ version: 1.0.0.pre.RC5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client