maestrano 0.9.2 → 0.10.0
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 +4 -4
- data/Gemfile.lock +11 -6
- data/README.md +84 -0
- data/lib/maestrano.rb +13 -2
- data/lib/maestrano/connec/client.rb +62 -0
- data/lib/maestrano/version.rb +1 -1
- data/maestrano.gemspec +1 -0
- data/test/maestrano/connec/client_test.rb +94 -0
- data/test/maestrano/maestrano_test.rb +15 -6
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d94420ccbb524ba344eacad615d8a0ab9b131fd6
|
4
|
+
data.tar.gz: c09aedc8103d853baf2e39191c9731116bc8103e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c8e40d09ee79f77a21befa7baa8a75b72826129d10586f2a5ca0b90fb30e34d7bfbaef1cf4f81f996613eb524640daf12b4e8bf990f34edcff2e5d74ec2c532
|
7
|
+
data.tar.gz: f8992c9d8b743bfbd704e779f9bf9df707edf0d9097f264668a59db05053a0c5a8a82ae98a05ff6ae0fdb28643acfc6faee871db75bfe0bf33f907637e3fc899
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
maestrano (0.
|
4
|
+
maestrano (0.10.0)
|
5
|
+
httparty (~> 0.13)
|
5
6
|
json (~> 1.8)
|
6
7
|
mime-types (~> 1.25)
|
7
8
|
nokogiri (>= 1.5.0)
|
@@ -11,17 +12,21 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: http://rubygems.org/
|
13
14
|
specs:
|
14
|
-
|
15
|
+
httparty (0.13.3)
|
16
|
+
json (~> 1.8)
|
17
|
+
multi_xml (>= 0.5.2)
|
18
|
+
json (1.8.2)
|
15
19
|
macaddr (1.7.1)
|
16
20
|
systemu (~> 2.6.2)
|
17
21
|
metaclass (0.0.4)
|
18
22
|
mime-types (1.25.1)
|
19
|
-
mini_portile (0.6.
|
23
|
+
mini_portile (0.6.2)
|
20
24
|
mocha (0.13.3)
|
21
25
|
metaclass (~> 0.0.1)
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
multi_xml (0.5.5)
|
27
|
+
netrc (0.10.2)
|
28
|
+
nokogiri (1.6.5)
|
29
|
+
mini_portile (~> 0.6.0)
|
25
30
|
rake (10.3.2)
|
26
31
|
rest-client (1.7.2)
|
27
32
|
mime-types (>= 1.16, < 3.0)
|
data/README.md
CHANGED
@@ -27,6 +27,9 @@ Maestrano Cloud Integration is currently in closed beta. Want to know more? Send
|
|
27
27
|
6. [API](#api)
|
28
28
|
* [Bill](#bill)
|
29
29
|
* [Recurring Bill](#recurring-bill)
|
30
|
+
7. [Connec!™ Data Sharing](#connec-data-sharing)
|
31
|
+
* [Making Requests](#making-requests)
|
32
|
+
* [Webhook Notifications](#webhook-notifications)
|
30
33
|
|
31
34
|
- - -
|
32
35
|
|
@@ -178,6 +181,34 @@ Maestrano.configure do |config|
|
|
178
181
|
#
|
179
182
|
# config.webhook.account.groups_path = '/maestrano/account/groups/:id',
|
180
183
|
# config.webhook.account.group_users_path = '/maestrano/account/groups/:group_id/users/:id',
|
184
|
+
|
185
|
+
|
186
|
+
# ==> Connec Subscriptions/Webhook
|
187
|
+
# The following section is used to configure the Connec!™ webhooks and which entities
|
188
|
+
# you should receive via webhook.
|
189
|
+
#
|
190
|
+
# == Notification Path
|
191
|
+
# This is the path of your application where notifications (created/updated entities) will
|
192
|
+
# be POSTed to.
|
193
|
+
# You should have a controller matching this path handling the update of your internal entities
|
194
|
+
# based on the Connec!™ entities you receive
|
195
|
+
#
|
196
|
+
# config.webhook.connec.notifications_path = '/maestrano/connec/notifications'
|
197
|
+
#
|
198
|
+
# == Subscriptions
|
199
|
+
# This is the list of entities (organizations,people,invoices etc.) for which you want to be
|
200
|
+
# notified upon creation/update in Connec!™
|
201
|
+
#
|
202
|
+
# config.webhook.connec.subscriptions = {
|
203
|
+
# accounts: false,
|
204
|
+
# company: false,
|
205
|
+
# invoice: false,
|
206
|
+
# item: false,
|
207
|
+
# organization: false,
|
208
|
+
# person: false,
|
209
|
+
# tax_codes: false,
|
210
|
+
# tax_rates: false
|
211
|
+
# }
|
181
212
|
end
|
182
213
|
```
|
183
214
|
|
@@ -783,6 +814,59 @@ rec_bill = Maestrano::Account::RecurringBill.retrieve("rbill-f1d2s54")
|
|
783
814
|
rec_bill.cancel
|
784
815
|
```
|
785
816
|
|
817
|
+
## Connec!™ Data Sharing
|
818
|
+
Maestrano offers the capability to share actual business data between application via its data sharing platform Connec!™.
|
819
|
+
|
820
|
+
The platform exposes a set of RESTful JSON APIs allowing your application to receive data generated by other applications and update data in other applications as well!
|
821
|
+
|
822
|
+
Connec!™ also offers the ability to create webhooks on your side to get automatically notified of changes happening in other systems.
|
823
|
+
|
824
|
+
Connec!™ enables seamless data sharing between the Maestrano applications as well as popular apps such as QuickBooks and Xero. One connector - tens of integrations!
|
825
|
+
|
826
|
+
### Making Requests
|
827
|
+
|
828
|
+
Connec!™ REST API documentation can be found here: http://maestrano.github.io/connec
|
829
|
+
|
830
|
+
The Maestrano API provides a built-in client - based on HTTParty - for connecting to Connec!™. Things like connection and authentication are automatically managed by the Connec!™ client.
|
831
|
+
|
832
|
+
|
833
|
+
```ruby
|
834
|
+
# Pass the customer group id as argument
|
835
|
+
client = Maestrano::Connec::Client.new("cld-f7f5g4")
|
836
|
+
|
837
|
+
# Retrieve all organizations (customers and suppliers) created in other applications
|
838
|
+
resp = client.get('/organizations')
|
839
|
+
resp.body # returns the raw response "{\"organizations\":[ ... ]}"
|
840
|
+
resp.parsed_response # returns a ruby hash { "organizations": [ ... ] }
|
841
|
+
|
842
|
+
# Create a new organization
|
843
|
+
client.post('/organizations', { organizations: { name: "DoeCorp Inc."} })
|
844
|
+
|
845
|
+
# Update an organization
|
846
|
+
client.put('/organizations/e32303c1-5102-0132-661e-600308937d74', { organizations: { is_customer: true} })
|
847
|
+
```
|
848
|
+
|
849
|
+
|
850
|
+
|
851
|
+
### Webhook Notifications
|
852
|
+
If you have configured the Maestrano API to receive update notifications (see 'subscriptions' configuration at the top) from Connec!™ then you can expect to receive regular POST requests on the notification_path you have configured.
|
853
|
+
|
854
|
+
Notifications are JSON messages containing the list of entities that have recently changed in other systems. You will only receive notifications for entities you have subscribed to.
|
855
|
+
|
856
|
+
Example of notification message:
|
857
|
+
```ruby
|
858
|
+
{
|
859
|
+
"organizations": [
|
860
|
+
{ "id": "e32303c1-5102-0132-661e-600308937d74", name: "DoeCorp Inc.", ... }
|
861
|
+
],
|
862
|
+
"people": [
|
863
|
+
{ "id": "a34303d1-4142-0152-362e-610408337d74", first_name: "John", last_name: "Doe", ... }
|
864
|
+
]
|
865
|
+
}
|
866
|
+
```
|
867
|
+
|
868
|
+
Entities sent via notifications follow the same data structure as the one described in our REST API documentation (available at http://maestrano.github.io/connec)
|
869
|
+
|
786
870
|
|
787
871
|
## Support
|
788
872
|
This README is still in the process of being written and improved. As such it might not cover some of the questions you might have.
|
data/lib/maestrano.rb
CHANGED
@@ -54,6 +54,9 @@ require 'maestrano/account/group'
|
|
54
54
|
require 'maestrano/account/bill'
|
55
55
|
require 'maestrano/account/recurring_bill'
|
56
56
|
|
57
|
+
# Connec
|
58
|
+
require 'maestrano/connec/client'
|
59
|
+
|
57
60
|
module Maestrano
|
58
61
|
|
59
62
|
class << self
|
@@ -182,6 +185,10 @@ module Maestrano
|
|
182
185
|
account: OpenStruct.new({
|
183
186
|
groups_path: '/maestrano/account/groups/:id',
|
184
187
|
group_users_path: '/maestrano/account/groups/:group_id/users/:id',
|
188
|
+
}),
|
189
|
+
connec: OpenStruct.new({
|
190
|
+
notifications_path: '/maestrano/connec/notifications',
|
191
|
+
subscriptions: {}
|
185
192
|
})
|
186
193
|
})
|
187
194
|
end
|
@@ -258,7 +265,9 @@ module Maestrano
|
|
258
265
|
'sso.idp' => 'https://maestrano.com',
|
259
266
|
'sso.name_id_format' => Maestrano::Saml::Settings::NAMEID_PERSISTENT,
|
260
267
|
'sso.x509_fingerprint' => '01:06:15:89:25:7d:78:12:28:a6:69:c7:de:63:ed:74:21:f9:f5:36',
|
261
|
-
'sso.x509_certificate' => "-----BEGIN CERTIFICATE-----\nMIIDezCCAuSgAwIBAgIJAOehBr+YIrhjMA0GCSqGSIb3DQEBBQUAMIGGMQswCQYD\nVQQGEwJBVTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxGjAYBgNVBAoT\nEU1hZXN0cmFubyBQdHkgTHRkMRYwFAYDVQQDEw1tYWVzdHJhbm8uY29tMSQwIgYJ\nKoZIhvcNAQkBFhVzdXBwb3J0QG1hZXN0cmFuby5jb20wHhcNMTQwMTA0MDUyMjM5\nWhcNMzMxMjMwMDUyMjM5WjCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEP\nMA0GA1UEBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQG\nA1UEAxMNbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVz\ndHJhbm8uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVkIqo5t5Paflu\nP2zbSbzxn29n6HxKnTcsubycLBEs0jkTkdG7seF1LPqnXl8jFM9NGPiBFkiaR15I\n5w482IW6mC7s8T2CbZEL3qqQEAzztEPnxQg0twswyIZWNyuHYzf9fw0AnohBhGu2\n28EZWaezzT2F333FOVGSsTn1+u6tFwIDAQABo4HuMIHrMB0GA1UdDgQWBBSvrNxo\neHDm9nhKnkdpe0lZjYD1GzCBuwYDVR0jBIGzMIGwgBSvrNxoeHDm9nhKnkdpe0lZ\njYD1G6GBjKSBiTCBhjELMAkGA1UE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R15I\n5w482IW6mC7s8T2CbZEL3qqQEAzztEPnxQg0twswyIZWNyuHYzf9fw0AnohBhGu2\n28EZWaezzT2F333FOVGSsTn1+u6tFwIDAQABo4HuMIHrMB0GA1UdDgQWBBSvrNxo\neHDm9nhKnkdpe0lZjYD1GzCBuwYDVR0jBIGzMIGwgBSvrNxoeHDm9nhKnkdpe0lZ\njYD1G6GBjKSBiTCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEPMA0GA1UE\nBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQGA1UEAxMN\nbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVzdHJhbm8u\nY29tggkA56EGv5giuGMwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCc\nMPgV0CpumKRMulOeZwdpnyLQI/NTr3VVHhDDxxCzcB0zlZ2xyDACGnIG2cQJJxfc\n2GcsFnb0BMw48K6TEhAaV92Q7bt1/TYRvprvhxUNMX2N8PHaYELFG2nWfQ4vqxES\nRkjkjqy+H7vir/MOF3rlFjiv5twAbDKYHXDT7v1YCg==\n-----END CERTIFICATE-----",
|
269
|
+
'connec.host' => 'http://api-sandbox.maestrano.io',
|
270
|
+
'connec.base_path' => '/connec/api/v2'
|
262
271
|
},
|
263
272
|
'production' => {
|
264
273
|
'api.host' => 'https://maestrano.com',
|
@@ -266,7 +275,9 @@ module Maestrano
|
|
266
275
|
'sso.idp' => 'https://maestrano.com',
|
267
276
|
'sso.name_id_format' => Maestrano::Saml::Settings::NAMEID_PERSISTENT,
|
268
277
|
'sso.x509_fingerprint' => '2f:57:71:e4:40:19:57:37:a6:2c:f0:c5:82:52:2f:2e:41:b7:9d:7e',
|
269
|
-
'sso.x509_certificate' => "-----BEGIN CERTIFICATE-----\nMIIDezCCAuSgAwIBAgIJAPFpcH2rW0pyMA0GCSqGSIb3DQEBBQUAMIGGMQswCQYD\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QKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQGA1UEAxMN\nbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVzdHJhbm8u\nY29tggkA8WlwfatbSnIwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQDE\nhe/18oRh8EqIhOl0bPk6BG49AkjhZZezrRJkCFp4dZxaBjwZTddwo8O5KHwkFGdy\nyLiPV326dtvXoKa9RFJvoJiSTQLEn5mO1NzWYnBMLtrDWojOe6Ltvn3x0HVo/iHh\nJShjAn6ZYX43Tjl1YXDd1H9O+7/VgEWAQQ32v8p5lA==\n-----END CERTIFICATE-----",
|
279
|
+
'connec.host' => 'https://api-connec.maestrano.com',
|
280
|
+
'connec.base_path' => '/api/v2'
|
270
281
|
}
|
271
282
|
}
|
272
283
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Maestrano
|
4
|
+
module Connec
|
5
|
+
|
6
|
+
class Client
|
7
|
+
include ::HTTParty
|
8
|
+
headers 'Accept' => 'application/vnd.api+json'
|
9
|
+
headers 'Content-Type' => 'application/vnd.api+json'
|
10
|
+
format :json
|
11
|
+
|
12
|
+
attr_reader :group_id
|
13
|
+
|
14
|
+
def initialize(group_id)
|
15
|
+
@group_id = group_id
|
16
|
+
self.class.base_uri("#{Maestrano.param('connec.host')}#{Maestrano.param('connec.base_path')}")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return the default options which includes
|
20
|
+
# maestrano authentication
|
21
|
+
def default_options
|
22
|
+
{
|
23
|
+
basic_auth: {
|
24
|
+
username: Maestrano.param('api.id'),
|
25
|
+
password: Maestrano.param('api.key')
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return the right path scoped using the customer
|
31
|
+
# group id
|
32
|
+
def scoped_path(relative_path)
|
33
|
+
clean_path = relative_path.gsub(/^\/+/, "").gsub(/\/+$/, "")
|
34
|
+
"/#{@group_id}/#{clean_path}"
|
35
|
+
end
|
36
|
+
|
37
|
+
# E.g: client.get('/organizations')
|
38
|
+
# E.g: client.get('/organizations/123')
|
39
|
+
def get(relative_path, options = {})
|
40
|
+
self.class.get(self.scoped_path(relative_path),default_options.merge(options))
|
41
|
+
end
|
42
|
+
|
43
|
+
# E.g: client.post('/organizations', { organizations: { name: 'DoeCorp Inc.' } })
|
44
|
+
def post(relative_path, body, options = {})
|
45
|
+
self.class.post(self.scoped_path(relative_path),
|
46
|
+
default_options.merge(body: body.to_json).merge(options)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# E.g for collection:
|
51
|
+
# => client.put('/organizations/123', { organizations: { name: 'DoeCorp Inc.' } })
|
52
|
+
# E.g for singular resource:
|
53
|
+
# => client.put('/company', { company: { name: 'DoeCorp Inc.' } })
|
54
|
+
def put(relative_path, body, options = {})
|
55
|
+
self.class.put(self.scoped_path(relative_path),
|
56
|
+
default_options.merge(body: body.to_json).merge(options)
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
data/lib/maestrano/version.rb
CHANGED
data/maestrano.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency('rest-client', '~> 1.4')
|
21
21
|
s.add_dependency('mime-types', '~> 1.25')
|
22
22
|
s.add_dependency('json', '~> 1.8')
|
23
|
+
s.add_dependency('httparty', '~> 0.13')
|
23
24
|
|
24
25
|
s.add_development_dependency('test-unit', '~> 2')
|
25
26
|
s.add_development_dependency('mocha', '~> 0.13')
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Maestrano
|
4
|
+
module Connec
|
5
|
+
class ClientTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context 'initializer' do
|
8
|
+
context '.base_uri' do
|
9
|
+
context 'in test' do
|
10
|
+
setup { Maestrano.configure { |config| config.environment = 'test' } }
|
11
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
12
|
+
|
13
|
+
should "return the right uri" do
|
14
|
+
assert_equal "http://api-sandbox.maestrano.io/connec/api/v2", Maestrano::Connec::Client.base_uri
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'in production' do
|
19
|
+
setup { Maestrano.configure { |config| config.environment = 'production' } }
|
20
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
21
|
+
|
22
|
+
should "return the right uri" do
|
23
|
+
assert_equal "https://api-connec.maestrano.com/api/v2", Maestrano::Connec::Client.base_uri
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'scoped_path' do
|
30
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
31
|
+
|
32
|
+
should "return the right scoped path" do
|
33
|
+
assert_equal "/cld-123/people", @client.scoped_path('/people')
|
34
|
+
end
|
35
|
+
|
36
|
+
should "remove any leading or trailing slash" do
|
37
|
+
assert_equal "/cld-123/people", @client.scoped_path('/people/')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'default_options' do
|
42
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
43
|
+
|
44
|
+
should "return the right authentication options" do
|
45
|
+
expected_opts = {
|
46
|
+
basic_auth: {
|
47
|
+
username: Maestrano.param('api.id'),
|
48
|
+
password: Maestrano.param('api.key')
|
49
|
+
}
|
50
|
+
}
|
51
|
+
assert_equal expected_opts, @client.default_options
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'get' do
|
56
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
57
|
+
|
58
|
+
should "perform the right query" do
|
59
|
+
path = '/people'
|
60
|
+
opts = { foo: 'bar' }
|
61
|
+
resp = mock('resp')
|
62
|
+
Maestrano::Connec::Client.expects(:get).with(@client.scoped_path(path),@client.default_options.merge(opts)).returns(resp)
|
63
|
+
assert_equal resp, @client.get(path,opts)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'post' do
|
68
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
69
|
+
|
70
|
+
should "perform the right query" do
|
71
|
+
path = '/people'
|
72
|
+
body = { some: 'data'}
|
73
|
+
opts = { foo: 'bar' }
|
74
|
+
resp = mock('resp')
|
75
|
+
Maestrano::Connec::Client.expects(:post).with(@client.scoped_path(path),@client.default_options.merge(body: body.to_json).merge(opts)).returns(resp)
|
76
|
+
assert_equal resp, @client.post(path,body,opts)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'put' do
|
81
|
+
setup { @client = Maestrano::Connec::Client.new("cld-123") }
|
82
|
+
|
83
|
+
should "perform the right query" do
|
84
|
+
path = '/people/123'
|
85
|
+
body = { some: 'data'}
|
86
|
+
opts = { foo: 'bar' }
|
87
|
+
resp = mock('resp')
|
88
|
+
Maestrano::Connec::Client.expects(:put).with(@client.scoped_path(path),@client.default_options.merge(body: body.to_json).merge(opts)).returns(resp)
|
89
|
+
assert_equal resp, @client.put(path,body,opts)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -16,8 +16,10 @@ class MaestranoTest < Test::Unit::TestCase
|
|
16
16
|
'sso.creation_mode' => 'real',
|
17
17
|
'sso.idm' => 'http://idp.mysuperapp.com',
|
18
18
|
|
19
|
-
'webhook.account.groups_path'
|
20
|
-
'webhook.account.group_users_path'
|
19
|
+
'webhook.account.groups_path' => '/mno/groups/:id',
|
20
|
+
'webhook.account.group_users_path' => '/mno/groups/:group_id/users/:id',
|
21
|
+
'webhook.connec.notifications_path' => 'mno/receive',
|
22
|
+
'webhook.connec.subscriptions' => { organizations: true, people: true }
|
21
23
|
}
|
22
24
|
|
23
25
|
Maestrano.configure do |config|
|
@@ -34,8 +36,11 @@ class MaestranoTest < Test::Unit::TestCase
|
|
34
36
|
config.sso.consume_path = @config['sso.consume_path']
|
35
37
|
config.sso.creation_mode = @config['sso.creation_mode']
|
36
38
|
|
37
|
-
config.webhook.account.groups_path = @config['webhook.account.groups_path'
|
38
|
-
config.webhook.account.group_users_path = @config['webhook.account.group_users_path'
|
39
|
+
config.webhook.account.groups_path = @config['webhook.account.groups_path']
|
40
|
+
config.webhook.account.group_users_path = @config['webhook.account.group_users_path']
|
41
|
+
|
42
|
+
config.webhook.connec.notifications_path = @config['webhook.connec.notifications_path']
|
43
|
+
config.webhook.connec.subscriptions = @config['webhook.connec.subscriptions']
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
@@ -87,7 +92,7 @@ class MaestranoTest < Test::Unit::TestCase
|
|
87
92
|
should "return the right test parameters" do
|
88
93
|
Maestrano.configure { |config| config.environment = 'test' }
|
89
94
|
|
90
|
-
['api.host','api.base','sso.idp', 'sso.name_id_format', 'sso.x509_certificate'].each do |parameter|
|
95
|
+
['api.host','api.base','sso.idp', 'sso.name_id_format', 'sso.x509_certificate', 'connec.host','connec.base_path'].each do |parameter|
|
91
96
|
assert_equal Maestrano::Configuration::EVT_CONFIG['test'][parameter], Maestrano.param(parameter)
|
92
97
|
end
|
93
98
|
end
|
@@ -95,7 +100,7 @@ class MaestranoTest < Test::Unit::TestCase
|
|
95
100
|
should "return the right production parameters" do
|
96
101
|
Maestrano.configure { |config| config.environment = 'production' }
|
97
102
|
|
98
|
-
['api.host','api.base','sso.idp', 'sso.name_id_format', 'sso.x509_certificate'].each do |parameter|
|
103
|
+
['api.host','api.base','sso.idp', 'sso.name_id_format', 'sso.x509_certificate','connec.host','connec.base_path'].each do |parameter|
|
99
104
|
assert_equal Maestrano::Configuration::EVT_CONFIG['production'][parameter], Maestrano.param(parameter)
|
100
105
|
end
|
101
106
|
end
|
@@ -249,6 +254,10 @@ class MaestranoTest < Test::Unit::TestCase
|
|
249
254
|
'account' => {
|
250
255
|
'groups_path' => @config['webhook.account.groups_path'],
|
251
256
|
'group_users_path' => @config['webhook.account.group_users_path'],
|
257
|
+
},
|
258
|
+
'connec' => {
|
259
|
+
'notifications_path' => 'mno/receive',
|
260
|
+
'subscriptions' => { organizations: true, people: true }
|
252
261
|
}
|
253
262
|
}
|
254
263
|
}
|
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: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.13'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.13'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: test-unit
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- lib/maestrano/api/operation/update.rb
|
185
199
|
- lib/maestrano/api/resource.rb
|
186
200
|
- lib/maestrano/api/util.rb
|
201
|
+
- lib/maestrano/connec/client.rb
|
187
202
|
- lib/maestrano/open_struct.rb
|
188
203
|
- lib/maestrano/saml/attribute_value.rb
|
189
204
|
- lib/maestrano/saml/metadata.rb
|
@@ -216,6 +231,7 @@ files:
|
|
216
231
|
- test/maestrano/api/object_test.rb
|
217
232
|
- test/maestrano/api/resource_test.rb
|
218
233
|
- test/maestrano/api/util_test.rb
|
234
|
+
- test/maestrano/connec/client_test.rb
|
219
235
|
- test/maestrano/maestrano_test.rb
|
220
236
|
- test/maestrano/open_struct_test.rb
|
221
237
|
- test/maestrano/saml/request_test.rb
|
@@ -285,6 +301,7 @@ test_files:
|
|
285
301
|
- test/maestrano/api/object_test.rb
|
286
302
|
- test/maestrano/api/resource_test.rb
|
287
303
|
- test/maestrano/api/util_test.rb
|
304
|
+
- test/maestrano/connec/client_test.rb
|
288
305
|
- test/maestrano/maestrano_test.rb
|
289
306
|
- test/maestrano/open_struct_test.rb
|
290
307
|
- test/maestrano/saml/request_test.rb
|