passaporteweb-client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +1063 -0
- data/.travis.yml +2 -3
- data/Gemfile.lock +70 -48
- data/README.rdoc +5 -0
- data/lib/passaporte_web/service_account.rb +16 -0
- data/lib/passaporte_web/version.rb +1 -1
- data/passaporteweb-client.gemspec +12 -12
- data/spec/passaporte_web/http_spec.rb +1 -1
- data/spec/passaporte_web/identity_service_account_spec.rb +2 -2
- data/spec/passaporte_web/identity_service_spec.rb +7 -7
- data/spec/passaporte_web/identity_spec.rb +17 -17
- data/spec/passaporte_web/notification_spec.rb +14 -14
- data/spec/passaporte_web/service_account_member_spec.rb +10 -10
- data/spec/passaporte_web/service_account_spec.rb +35 -3
- data/spec/spec_helper.rb +1 -0
- metadata +35 -33
@@ -5,8 +5,8 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
5
5
|
let(:service_account) { PassaporteWeb::ServiceAccount.find('859d3542-84d6-4909-b1bd-4f43c1312065') }
|
6
6
|
let(:identity) { PassaporteWeb::Identity.find('5e32f927-c4ab-404e-a91c-b2abc05afb56') }
|
7
7
|
|
8
|
-
let(:mock_service_account) {
|
9
|
-
let(:mock_identity) {
|
8
|
+
let(:mock_service_account) { double('ServiceAccount', uuid: 'service-account-uuid') }
|
9
|
+
let(:mock_identity) { double('Identity', uuid: 'identity-uuid') }
|
10
10
|
|
11
11
|
describe ".new" do
|
12
12
|
it "should instanciate a minumum object" do
|
@@ -38,7 +38,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
38
38
|
end
|
39
39
|
it "should raise an 404 error if the membership does not exist" do
|
40
40
|
expect {
|
41
|
-
described_class.find(service_account,
|
41
|
+
described_class.find(service_account, double('Identity', uuid: 'identity-uuid'))
|
42
42
|
}.to raise_error(RestClient::ResourceNotFound, '404 Resource Not Found')
|
43
43
|
end
|
44
44
|
end
|
@@ -46,7 +46,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
46
46
|
describe "#destroy", vcr: true do
|
47
47
|
it "should destroy the membership, removing the association between service_account and identity" do
|
48
48
|
member = described_class.find(service_account, identity)
|
49
|
-
member.destroy.
|
49
|
+
expect(member.destroy).to be_truthy
|
50
50
|
member.should_not be_persisted
|
51
51
|
member.should be_destroyed
|
52
52
|
member.errors.should be_empty
|
@@ -57,7 +57,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
57
57
|
it "should return false if the role is owner" do
|
58
58
|
member = described_class.find(service_account, identity)
|
59
59
|
member.roles.should include('owner')
|
60
|
-
member.destroy.
|
60
|
+
expect(member.destroy).to be_falsy
|
61
61
|
member.should be_persisted
|
62
62
|
member.should_not be_destroyed
|
63
63
|
member.errors.should == "Service owner cannot be removed from members list"
|
@@ -73,7 +73,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
73
73
|
let(:member) { described_class.new(service_account, identity, ['admin','user']) }
|
74
74
|
context "on success" do
|
75
75
|
it "should create the membership between the service_account and the identity" do
|
76
|
-
member.save.
|
76
|
+
expect(member.save).to be_truthy
|
77
77
|
member.service_account.should == service_account
|
78
78
|
member.identity.should == identity
|
79
79
|
member.roles.should == ['admin','user']
|
@@ -95,7 +95,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
95
95
|
context "on failure" do
|
96
96
|
it "should not create the membership and set the errors on the object" do
|
97
97
|
member.roles = ['owner'] # can't create membership for the owner
|
98
|
-
member.save.
|
98
|
+
expect(member.save).to be_falsy
|
99
99
|
member.errors.should == "Adding a member as owner is not allowed"
|
100
100
|
member.should_not be_persisted
|
101
101
|
member.should_not be_destroyed
|
@@ -105,7 +105,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
105
105
|
}.to raise_error(RestClient::ResourceNotFound, '404 Resource Not Found')
|
106
106
|
end
|
107
107
|
it "should return false if the membership already exists" do
|
108
|
-
member.save.
|
108
|
+
expect(member.save).to be_falsy
|
109
109
|
member.errors.should == "Identity with uuid=5e32f927-c4ab-404e-a91c-b2abc05afb56 is already in members list of service identity_client at account 859d3542-84d6-4909-b1bd-4f43c1312065"
|
110
110
|
member.should_not be_persisted
|
111
111
|
member.should_not be_destroyed
|
@@ -122,7 +122,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
122
122
|
it "should update the member roles" do
|
123
123
|
member.roles.should == ['admin', 'user']
|
124
124
|
member.roles = ['user']
|
125
|
-
member.save.
|
125
|
+
expect(member.save).to be_truthy
|
126
126
|
member.errors.should be_empty
|
127
127
|
member.roles.should == ['user']
|
128
128
|
|
@@ -135,7 +135,7 @@ describe PassaporteWeb::ServiceAccountMember do
|
|
135
135
|
pending "está deixando setar como owner e não deixa setar sem nenhum role, como fazer?"
|
136
136
|
member.roles.should == ['admin', 'user']
|
137
137
|
member.roles = ['owner']
|
138
|
-
member.save.
|
138
|
+
expect(member.save).to be_falsy
|
139
139
|
member.errors.should_not be_empty
|
140
140
|
member.roles.should == ['owner']
|
141
141
|
|
@@ -38,7 +38,7 @@ describe PassaporteWeb::ServiceAccount do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe ".find_all", :vcr => true do
|
41
|
-
let(:mock_response) {
|
41
|
+
let(:mock_response) { double('response', body: MultiJson.encode([]), code: 200, headers: {link: "<http://sandbox.app.passaporteweb.com.br/organizations/api/accounts/?page=3&limit=3>; rel=next, <http://sandbox.app.passaporteweb.com.br/organizations/api/accounts/?page=1&limit=3>; rel=prev"}) }
|
42
42
|
it "should find all accounts related to the authenticated application and return them as an array of Account instances" do
|
43
43
|
accounts_and_meta = PassaporteWeb::ServiceAccount.find_all
|
44
44
|
|
@@ -137,7 +137,7 @@ describe PassaporteWeb::ServiceAccount do
|
|
137
137
|
service_account.expiration = '2014-05-01'
|
138
138
|
|
139
139
|
service_account.should be_persisted
|
140
|
-
service_account.save.
|
140
|
+
expect(service_account.save).to be_truthy
|
141
141
|
service_account.should be_persisted
|
142
142
|
|
143
143
|
service_account.plan_slug.should == 'basic'
|
@@ -153,11 +153,43 @@ describe PassaporteWeb::ServiceAccount do
|
|
153
153
|
service_account.plan_slug = nil # required
|
154
154
|
service_account.expiration = nil
|
155
155
|
service_account.should be_persisted
|
156
|
-
service_account.save.
|
156
|
+
expect(service_account.save).to be_falsy
|
157
157
|
service_account.should be_persisted
|
158
158
|
service_account.errors.should == {"field_errors"=>{"plan_slug"=>["Este campo é obrigatório."]}}
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
+
describe '#activate', vcr: true do
|
164
|
+
let(:service_account) { PassaporteWeb::ServiceAccount.find("019a3450-8107-4832-8321-de4e6580c06b") }
|
165
|
+
let(:responsible_identity) { "20a8bbe1-3b4a-4e46-a69a-a7c524bd2ab8" }
|
166
|
+
|
167
|
+
context "on success" do
|
168
|
+
it "activates the service account an returns true" do
|
169
|
+
expect(service_account.activate(responsible_identity)).to be_truthy
|
170
|
+
end
|
171
|
+
|
172
|
+
it "assigns no errors" do
|
173
|
+
service_account.activate(responsible_identity)
|
174
|
+
expect(service_account.errors).to eq({})
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "on failure" do
|
179
|
+
context "when given wrong identity" do
|
180
|
+
let(:service_account) { PassaporteWeb::ServiceAccount.find("bc4bb967-e5b2-4925-813c-4d1e5418247a") }
|
181
|
+
let(:responsible_identity) { 'wrong-idendity' }
|
182
|
+
|
183
|
+
it "returns false" do
|
184
|
+
expect(service_account.activate(responsible_identity)).to be_falsy
|
185
|
+
end
|
186
|
+
|
187
|
+
it "assigns errors" do
|
188
|
+
service_account.activate(responsible_identity)
|
189
|
+
expect(service_account.errors).to eq({"field_errors" => {"identity"=>["Informe um valor v\u00E1lido."]}})
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
163
195
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -30,6 +30,7 @@ RSpec.configure do |c|
|
|
30
30
|
c.before(:vcr => true) do
|
31
31
|
PassaporteWeb.configure do |c|
|
32
32
|
c.url = 'http://sandbox.app.passaporteweb.com.br' # TODO trocar para https
|
33
|
+
# Those credentials are from Identity Client App
|
33
34
|
c.application_token = '8ab29iwKFI'
|
34
35
|
c.application_secret = 'VnWYenOqYsHtcFowrdJlwdJNALq5Go9v'
|
35
36
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passaporteweb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Tassinari de Oliveira
|
8
|
-
-
|
8
|
+
- Eduardo Hertz
|
9
|
+
- Rafael B. Tauil
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rest-client
|
@@ -17,14 +18,14 @@ dependencies:
|
|
17
18
|
requirements:
|
18
19
|
- - "~>"
|
19
20
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
21
|
+
version: 1.8.0
|
21
22
|
type: :runtime
|
22
23
|
prerelease: false
|
23
24
|
version_requirements: !ruby/object:Gem::Requirement
|
24
25
|
requirements:
|
25
26
|
- - "~>"
|
26
27
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
28
|
+
version: 1.8.0
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
30
|
name: multi_json
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,56 +46,56 @@ dependencies:
|
|
45
46
|
requirements:
|
46
47
|
- - "~>"
|
47
48
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.
|
49
|
+
version: '1.9'
|
49
50
|
type: :development
|
50
51
|
prerelease: false
|
51
52
|
version_requirements: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
54
|
- - "~>"
|
54
55
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
56
|
+
version: '1.9'
|
56
57
|
- !ruby/object:Gem::Dependency
|
57
58
|
name: rake
|
58
59
|
requirement: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
61
|
- - "~>"
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: '10.
|
63
|
+
version: '10.4'
|
63
64
|
type: :development
|
64
65
|
prerelease: false
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - "~>"
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: '10.
|
70
|
+
version: '10.4'
|
70
71
|
- !ruby/object:Gem::Dependency
|
71
72
|
name: rdoc
|
72
73
|
requirement: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
75
|
- - "~>"
|
75
76
|
- !ruby/object:Gem::Version
|
76
|
-
version: '4.
|
77
|
+
version: '4.2'
|
77
78
|
type: :development
|
78
79
|
prerelease: false
|
79
80
|
version_requirements: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
82
|
- - "~>"
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version: '4.
|
84
|
+
version: '4.2'
|
84
85
|
- !ruby/object:Gem::Dependency
|
85
86
|
name: rspec
|
86
87
|
requirement: !ruby/object:Gem::Requirement
|
87
88
|
requirements:
|
88
89
|
- - "~>"
|
89
90
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
+
version: 3.3.0
|
91
92
|
type: :development
|
92
93
|
prerelease: false
|
93
94
|
version_requirements: !ruby/object:Gem::Requirement
|
94
95
|
requirements:
|
95
96
|
- - "~>"
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
98
|
+
version: 3.3.0
|
98
99
|
- !ruby/object:Gem::Dependency
|
99
100
|
name: vcr
|
100
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,87 +125,88 @@ dependencies:
|
|
124
125
|
- !ruby/object:Gem::Version
|
125
126
|
version: 1.9.3
|
126
127
|
- !ruby/object:Gem::Dependency
|
127
|
-
name: pry
|
128
|
+
name: pry-byebug
|
128
129
|
requirement: !ruby/object:Gem::Requirement
|
129
130
|
requirements:
|
130
131
|
- - "~>"
|
131
132
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
133
|
+
version: '3.1'
|
133
134
|
type: :development
|
134
135
|
prerelease: false
|
135
136
|
version_requirements: !ruby/object:Gem::Requirement
|
136
137
|
requirements:
|
137
138
|
- - "~>"
|
138
139
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
140
|
+
version: '3.1'
|
140
141
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
142
|
+
name: awesome_print
|
142
143
|
requirement: !ruby/object:Gem::Requirement
|
143
144
|
requirements:
|
144
145
|
- - "~>"
|
145
146
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
147
|
+
version: '1.6'
|
147
148
|
type: :development
|
148
149
|
prerelease: false
|
149
150
|
version_requirements: !ruby/object:Gem::Requirement
|
150
151
|
requirements:
|
151
152
|
- - "~>"
|
152
153
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
154
|
+
version: '1.6'
|
154
155
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
156
|
+
name: simplecov
|
156
157
|
requirement: !ruby/object:Gem::Requirement
|
157
158
|
requirements:
|
158
159
|
- - "~>"
|
159
160
|
- !ruby/object:Gem::Version
|
160
|
-
version: '
|
161
|
+
version: '0.10'
|
161
162
|
type: :development
|
162
163
|
prerelease: false
|
163
164
|
version_requirements: !ruby/object:Gem::Requirement
|
164
165
|
requirements:
|
165
166
|
- - "~>"
|
166
167
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
168
|
+
version: '0.10'
|
168
169
|
- !ruby/object:Gem::Dependency
|
169
|
-
name:
|
170
|
+
name: coveralls
|
170
171
|
requirement: !ruby/object:Gem::Requirement
|
171
172
|
requirements:
|
172
173
|
- - "~>"
|
173
174
|
- !ruby/object:Gem::Version
|
174
|
-
version: '0.
|
175
|
+
version: '0.8'
|
175
176
|
type: :development
|
176
177
|
prerelease: false
|
177
178
|
version_requirements: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
180
|
- - "~>"
|
180
181
|
- !ruby/object:Gem::Version
|
181
|
-
version: '0.
|
182
|
+
version: '0.8'
|
182
183
|
- !ruby/object:Gem::Dependency
|
183
|
-
name:
|
184
|
+
name: json
|
184
185
|
requirement: !ruby/object:Gem::Requirement
|
185
186
|
requirements:
|
186
|
-
- -
|
187
|
+
- - '='
|
187
188
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
189
|
+
version: 1.8.3
|
189
190
|
type: :development
|
190
191
|
prerelease: false
|
191
192
|
version_requirements: !ruby/object:Gem::Requirement
|
192
193
|
requirements:
|
193
|
-
- -
|
194
|
+
- - '='
|
194
195
|
- !ruby/object:Gem::Version
|
195
|
-
version:
|
196
|
+
version: 1.8.3
|
196
197
|
description: A Ruby client for the PassaporteWeb REST API
|
197
198
|
email:
|
198
199
|
- rodrigo@pittlandia.net
|
199
200
|
- rodrigo.tassinari@myfreecomm.com.br
|
200
|
-
-
|
201
|
-
-
|
201
|
+
- eduardo.hertz@myfreecomm.com.br
|
202
|
+
- rafael@tauil.com.br
|
202
203
|
executables: []
|
203
204
|
extensions: []
|
204
205
|
extra_rdoc_files: []
|
205
206
|
files:
|
206
207
|
- ".coveralls.yml"
|
207
208
|
- ".gitignore"
|
209
|
+
- ".hound.yml"
|
208
210
|
- ".rspec"
|
209
211
|
- ".travis.yml"
|
210
212
|
- Gemfile
|
@@ -256,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
258
|
version: '0'
|
257
259
|
requirements: []
|
258
260
|
rubyforge_project:
|
259
|
-
rubygems_version: 2.
|
261
|
+
rubygems_version: 2.4.5
|
260
262
|
signing_key:
|
261
263
|
specification_version: 4
|
262
264
|
summary: 'A Ruby client for the PassaporteWeb REST API: https://app.passaporteweb.com.br/static/docs/'
|