maestrano 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c1c227a0a20347f0a75185197b3baac224c968c
4
+ data.tar.gz: a5b416cd223dd0cea3e04244f404d66681849a98
5
+ SHA512:
6
+ metadata.gz: ed5ca2ae12480f279dd8fb56a1209b5279c66a20fd00b220b1289ca5fe451c92945a63155ed9a422190a331588e17a56c62e6f4de3127e5c1d4c020b0f61d873
7
+ data.tar.gz: fe08eb406c48c00bf204d03ab841330fe702eb001f18a6cd07829cdf0b50094513b5299dd00debad89ee083baa4f779071aa0e81c47eec135a7d32d37ec73eb2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maestrano (0.5.0)
4
+ maestrano (0.6.0)
5
5
  json (~> 1.8)
6
6
  mime-types (~> 1.25)
7
7
  nokogiri (>= 1.5.0)
data/lib/maestrano.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # libs
2
2
  require 'rest_client'
3
3
  require 'json'
4
+
5
+ # OpenStruct (Extended)
4
6
  require 'ostruct'
7
+ require 'maestrano/open_struct'
5
8
 
6
9
  # Version
7
10
  require 'maestrano/version'
@@ -103,33 +106,41 @@ module Maestrano
103
106
  # will be remotely fetched by Maestrano
104
107
  # Exclude any info containing an api key
105
108
  def self.to_metadata
106
- {
107
- 'environment' => self.param('environment'),
108
- 'app' => {
109
- 'host' => self.param('app.host')
110
- },
111
- 'api' => {
112
- 'id' => self.param('api.id'),
113
- 'version' => self.param('api.version'),
114
- 'verify_ssl_certs' => self.param('api.verify_ssl_certs'),
115
- 'lang' => self.param('api.lang'),
116
- 'lang_version' => self.param('api.lang_version'),
117
- 'host' => self.param('api.host'),
118
- 'base' => self.param('api.base'),
109
+ hash = {}
110
+ hash['environment'] = self.param('environment')
119
111
 
120
- },
121
- 'sso' => {
122
- 'enabled' => self.param('sso.enabled'),
123
- 'init_path' => self.param('sso.init_path'),
124
- 'consume_path' => self.param('sso.consume_path'),
125
- 'creation_mode' => self.param('sso.creation_mode'),
126
- 'idm' => self.param('sso.idm'),
127
- 'idp' => self.param('sso.idp'),
128
- 'name_id_format' => self.param('sso.name_id_format'),
129
- 'x509_fingerprint' => self.param('sso.x509_fingerprint'),
130
- 'x509_certificate' => self.param('sso.x509_certificate'),
131
- }
132
- }
112
+ config_groups = ['app','api','sso','webhook']
113
+ blacklist = ['api.key','api.token']
114
+
115
+ config_groups.each do |cgroup_name|
116
+ cgroup = self.config.send(cgroup_name)
117
+
118
+ attr_list = cgroup.attributes.map(&:to_s)
119
+ attr_list += Configuration::EVT_CONFIG[hash['environment']].keys.select { |k| k =~ Regexp.new("^#{cgroup_name}\.") }.map { |k| k.gsub(Regexp.new("^#{cgroup_name}\."),'') }
120
+ attr_list.uniq!
121
+
122
+ attr_list.each do |first_lvl|
123
+ if cgroup.send(first_lvl).is_a?(OpenStruct)
124
+ c2group = cgroup.send(first_lvl)
125
+ c2group.attributes.each do |secnd_lvl|
126
+ full_param = [cgroup_name,first_lvl,secnd_lvl].join('.')
127
+ unless blacklist.include?(full_param)
128
+ hash[cgroup_name.to_s] ||= {}
129
+ hash[cgroup_name.to_s][first_lvl.to_s] ||= {}
130
+ hash[cgroup_name.to_s][first_lvl.to_s][secnd_lvl.to_s] = self.param(full_param)
131
+ end
132
+ end
133
+ else
134
+ full_param = [cgroup_name,first_lvl].join('.')
135
+ unless blacklist.include?(full_param)
136
+ hash[cgroup_name.to_s] ||= {}
137
+ hash[cgroup_name.to_s][first_lvl.to_s] = self.param(full_param)
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ return hash
133
144
  end
134
145
 
135
146
  class Configuration
@@ -223,6 +234,8 @@ module Maestrano
223
234
  def param(parameter)
224
235
  real_param = self.legacy_param_to_new(parameter)
225
236
  props = real_param.split('.')
237
+
238
+ # Either respond to param directly or via properties chaining (e.g: webhook.account.groups_path)
226
239
  if self.respond_to?(real_param) || props.inject(self) { |result,elem| result && result.respond_to?(elem) ? result.send(elem) || elem : false }
227
240
  last_prop = props.pop
228
241
  obj = props.inject(self,:send)
@@ -0,0 +1,11 @@
1
+ module Maestrano
2
+
3
+ # Extebd OpenStruct to include a 'attributes'
4
+ # method
5
+ class OpenStruct < ::OpenStruct
6
+ # Return all object defined attributes
7
+ def attributes
8
+ (self.methods - self.class.new.methods).reject {|method| method =~ /=$/ }
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Maestrano
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -229,6 +229,12 @@ class MaestranoTest < Test::Unit::TestCase
229
229
  'name_id_format' => Maestrano::Configuration::EVT_CONFIG[@config['environment']]['sso.name_id_format'],
230
230
  'x509_fingerprint' => Maestrano::Configuration::EVT_CONFIG[@config['environment']]['sso.x509_fingerprint'],
231
231
  'x509_certificate' => Maestrano::Configuration::EVT_CONFIG[@config['environment']]['sso.x509_certificate'],
232
+ },
233
+ 'webhook' => {
234
+ 'account' => {
235
+ 'groups_path' => @config['webhook.account.groups_path'],
236
+ 'group_users_path' => @config['webhook.account.group_users_path'],
237
+ }
232
238
  }
233
239
  }
234
240
 
@@ -0,0 +1,10 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Maestrano
4
+ class MaestranoOpenStructTest < Test::Unit::TestCase
5
+ should "return the right attributes" do
6
+ o = Maestrano::OpenStruct.new(bla: 'hello', ha: 'yo')
7
+ assert_equal [:bla,:ha], o.attributes
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,137 +1,164 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: maestrano
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.6.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Arnaud Lachaume
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2014-06-05 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: rest-client
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
21
17
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: "1.4"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
24
20
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: mime-types
28
21
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mime-types
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
32
31
  - - ~>
33
- - !ruby/object:Gem::Version
34
- version: "1.25"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.25'
35
34
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: json
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.25'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
43
45
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: "1.8"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
46
48
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: test-unit
50
49
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
56
- version: "2"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
57
62
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: mocha
61
63
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
65
73
  - - ~>
66
- - !ruby/object:Gem::Version
67
- version: "0.13"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.13'
68
76
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: shoulda
72
77
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: shoulda
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
76
87
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: "2.11"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.11'
79
90
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: timecop
83
91
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: timecop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
87
101
  - - <=
88
- - !ruby/object:Gem::Version
102
+ - !ruby/object:Gem::Version
89
103
  version: 0.6.0
90
104
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: rake
94
105
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - <=
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
98
115
  - - ~>
99
- - !ruby/object:Gem::Version
100
- version: "10"
116
+ - !ruby/object:Gem::Version
117
+ version: '10'
101
118
  type: :development
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
- name: uuid
105
119
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
109
122
  - - ~>
110
- - !ruby/object:Gem::Version
111
- version: "2.3"
123
+ - !ruby/object:Gem::Version
124
+ version: '10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: uuid
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '2.3'
112
132
  type: :runtime
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
- name: nokogiri
116
133
  prerelease: false
117
- requirement: &id010 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '2.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: nokogiri
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
122
145
  version: 1.5.0
123
146
  type: :runtime
124
- version_requirements: *id010
125
- description: Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details.
126
- email:
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.5.0
153
+ description: Maestrano is the next generation marketplace for SME applications. See
154
+ https://maestrano.com for details.
155
+ email:
127
156
  - arnaud.lachaume@maestrano.com
128
- executables:
157
+ executables:
129
158
  - maestrano-console
130
159
  extensions: []
131
-
132
160
  extra_rdoc_files: []
133
-
134
- files:
161
+ files:
135
162
  - .gitignore
136
163
  - Gemfile
137
164
  - Gemfile.lock
@@ -155,6 +182,7 @@ files:
155
182
  - lib/maestrano/api/operation/update.rb
156
183
  - lib/maestrano/api/resource.rb
157
184
  - lib/maestrano/api/util.rb
185
+ - lib/maestrano/open_struct.rb
158
186
  - lib/maestrano/saml/attribute_value.rb
159
187
  - lib/maestrano/saml/metadata.rb
160
188
  - lib/maestrano/saml/request.rb
@@ -185,6 +213,7 @@ files:
185
213
  - test/maestrano/api/resource_test.rb
186
214
  - test/maestrano/api/util_test.rb
187
215
  - test/maestrano/maestrano_test.rb
216
+ - test/maestrano/open_struct_test.rb
188
217
  - test/maestrano/saml/request_test.rb
189
218
  - test/maestrano/saml/response_test.rb
190
219
  - test/maestrano/saml/settings_test.rb
@@ -218,33 +247,30 @@ files:
218
247
  - test/support/saml/responses/wrapped_response_2.xml.base64
219
248
  - test/test_helper.rb
220
249
  homepage: https://maestrano.com
221
- licenses:
250
+ licenses:
222
251
  - MIT
252
+ metadata: {}
223
253
  post_install_message:
224
254
  rdoc_options: []
225
-
226
- require_paths:
255
+ require_paths:
227
256
  - lib
228
- required_ruby_version: !ruby/object:Gem::Requirement
229
- none: false
230
- requirements:
231
- - - ">="
232
- - !ruby/object:Gem::Version
233
- version: "0"
234
- required_rubygems_version: !ruby/object:Gem::Requirement
235
- none: false
236
- requirements:
237
- - - ">="
238
- - !ruby/object:Gem::Version
239
- version: "0"
257
+ required_ruby_version: !ruby/object:Gem::Requirement
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ! '>='
265
+ - !ruby/object:Gem::Version
266
+ version: '0'
240
267
  requirements: []
241
-
242
268
  rubyforge_project:
243
- rubygems_version: 1.8.21
269
+ rubygems_version: 2.2.1
244
270
  signing_key:
245
- specification_version: 3
271
+ specification_version: 4
246
272
  summary: Ruby bindings for the Maestrano API
247
- test_files:
273
+ test_files:
248
274
  - test/helpers/api_helpers.rb
249
275
  - test/helpers/saml_helpers.rb
250
276
  - test/maestrano/account/bill_test.rb
@@ -254,6 +280,7 @@ test_files:
254
280
  - test/maestrano/api/resource_test.rb
255
281
  - test/maestrano/api/util_test.rb
256
282
  - test/maestrano/maestrano_test.rb
283
+ - test/maestrano/open_struct_test.rb
257
284
  - test/maestrano/saml/request_test.rb
258
285
  - test/maestrano/saml/response_test.rb
259
286
  - test/maestrano/saml/settings_test.rb