passaporteweb-client 0.0.15 → 0.0.16
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.
- data/Gemfile.lock +10 -10
- data/lib/passaporte_web/identity.rb +1 -1
- data/lib/passaporte_web/identity_service_account.rb +8 -0
- data/lib/passaporte_web/version.rb +1 -1
- data/passaporteweb-client.gemspec +9 -9
- data/spec/passaporte_web/identity_service_account_spec.rb +6 -2
- data/spec/passaporte_web/identity_spec.rb +21 -3
- metadata +20 -20
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
passaporteweb-client (0.0.
|
4
|
+
passaporteweb-client (0.0.16)
|
5
5
|
multi_json (~> 1.7.1)
|
6
6
|
rest-client (~> 1.6.7)
|
7
7
|
|
@@ -58,15 +58,15 @@ PLATFORMS
|
|
58
58
|
ruby
|
59
59
|
|
60
60
|
DEPENDENCIES
|
61
|
-
awesome_print (~> 1.1
|
61
|
+
awesome_print (~> 1.1)
|
62
62
|
bundler (~> 1.3.2)
|
63
|
-
coveralls (~> 0.6
|
63
|
+
coveralls (~> 0.6)
|
64
64
|
passaporteweb-client!
|
65
|
-
pry (~> 0.9
|
66
|
-
pry-nav (~> 0.2
|
67
|
-
rake (~> 10.0
|
68
|
-
rdoc (~> 4.0
|
69
|
-
rspec (~> 2.13
|
70
|
-
simplecov (~> 0.7
|
71
|
-
vcr (~> 2.4
|
65
|
+
pry (~> 0.9)
|
66
|
+
pry-nav (~> 0.2)
|
67
|
+
rake (~> 10.0)
|
68
|
+
rdoc (~> 4.0)
|
69
|
+
rspec (~> 2.13)
|
70
|
+
simplecov (~> 0.7)
|
71
|
+
vcr (~> 2.4)
|
72
72
|
webmock (~> 1.9.3)
|
@@ -6,7 +6,7 @@ module PassaporteWeb
|
|
6
6
|
class Identity
|
7
7
|
include Attributable
|
8
8
|
|
9
|
-
ATTRIBUTES = [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos]
|
9
|
+
ATTRIBUTES = [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos]
|
10
10
|
UPDATABLE_ATTRIBUTES = [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone]
|
11
11
|
CREATABLE_ATTRIBUTES = *(UPDATABLE_ATTRIBUTES + [:email, :password, :password2, :must_change_password, :tos, :inhibit_activation_message])
|
12
12
|
|
@@ -36,6 +36,14 @@ module PassaporteWeb
|
|
36
36
|
@errors = {}
|
37
37
|
end
|
38
38
|
|
39
|
+
def name
|
40
|
+
@name || (@account_data.nil? ? nil : @account_data['name'])
|
41
|
+
end
|
42
|
+
|
43
|
+
def uuid
|
44
|
+
@uuid || (@account_data.nil? ? nil : @account_data['uuid'])
|
45
|
+
end
|
46
|
+
|
39
47
|
# Creates a new ServiceAccount for the supplied Identity on the current authenticated application.
|
40
48
|
# The supplied Identity will be the ServiceAccount's owner. You should supply either the <tt>name</tt>
|
41
49
|
# or the (service account's) <tt>uuid</tt> attribute. If the latter is supplied, the supplied Identity
|
@@ -27,14 +27,14 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency "multi_json", "~> 1.7.1"
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.3.2"
|
30
|
-
spec.add_development_dependency "rake", "~> 10.0
|
31
|
-
spec.add_development_dependency 'rdoc', '~> 4.0
|
32
|
-
spec.add_development_dependency "rspec", "~> 2.13
|
33
|
-
spec.add_development_dependency "vcr", "~> 2.4
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency 'rdoc', '~> 4.0'
|
32
|
+
spec.add_development_dependency "rspec", "~> 2.13"
|
33
|
+
spec.add_development_dependency "vcr", "~> 2.4"
|
34
34
|
spec.add_development_dependency "webmock", "~> 1.9.3"
|
35
|
-
spec.add_development_dependency "pry", "~> 0.9
|
36
|
-
spec.add_development_dependency "pry-nav", "~> 0.2
|
37
|
-
spec.add_development_dependency "awesome_print", "~> 1.1
|
38
|
-
spec.add_development_dependency "simplecov", "~> 0.7
|
39
|
-
spec.add_development_dependency "coveralls", "~> 0.6
|
35
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
36
|
+
spec.add_development_dependency "pry-nav", "~> 0.2"
|
37
|
+
spec.add_development_dependency "awesome_print", "~> 1.1"
|
38
|
+
spec.add_development_dependency "simplecov", "~> 0.7"
|
39
|
+
spec.add_development_dependency "coveralls", "~> 0.6"
|
40
40
|
end
|
@@ -56,8 +56,8 @@ describe PassaporteWeb::IdentityServiceAccount do
|
|
56
56
|
account.service_data.should == {"name" => "Identity Client","slug" => "identity_client"}
|
57
57
|
account.account_data.should == {"name" => "Investimentos","uuid" => "859d3542-84d6-4909-b1bd-4f43c1312065"}
|
58
58
|
account.add_member_url.should == '/organizations/api/accounts/859d3542-84d6-4909-b1bd-4f43c1312065/members/'
|
59
|
-
|
60
|
-
|
59
|
+
account.name.should == 'Investimentos'
|
60
|
+
account.uuid.should == '859d3542-84d6-4909-b1bd-4f43c1312065'
|
61
61
|
end
|
62
62
|
it "should include expired service accounts if asked to" do
|
63
63
|
accounts = described_class.find_all(identity, true)
|
@@ -90,6 +90,8 @@ describe PassaporteWeb::IdentityServiceAccount do
|
|
90
90
|
account.service_data.should == {"name" => "Identity Client","slug" => "identity_client"}
|
91
91
|
account.account_data['name'].should == 'Conta Nova em Folha'
|
92
92
|
account.account_data['uuid'].should_not be_nil
|
93
|
+
account.name.should == 'Conta Nova em Folha'
|
94
|
+
account.uuid.should_not be_nil
|
93
95
|
account.url.should_not be_nil
|
94
96
|
account.membership_details_url.should_not be_nil
|
95
97
|
account.add_member_url.should_not be_nil
|
@@ -112,6 +114,8 @@ describe PassaporteWeb::IdentityServiceAccount do
|
|
112
114
|
account.service_data.should == {"name" => "Identity Client","slug" => "identity_client"}
|
113
115
|
account.account_data['name'].should_not be_nil
|
114
116
|
account.account_data['uuid'].should == account_uuid
|
117
|
+
account.name.should_not be_nil
|
118
|
+
account.uuid.should == account_uuid
|
115
119
|
account.url.should_not be_nil
|
116
120
|
account.membership_details_url.should_not be_nil
|
117
121
|
account.add_member_url.should_not be_nil
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
describe PassaporteWeb::Identity do
|
5
5
|
|
6
6
|
describe "constants" do
|
7
|
-
it { described_class::ATTRIBUTES.should == [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos] }
|
7
|
+
it { described_class::ATTRIBUTES.should == [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos] }
|
8
8
|
it { described_class::UPDATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone] }
|
9
9
|
it { described_class::CREATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone, :email, :password, :password2, :must_change_password, :tos, :inhibit_activation_message] }
|
10
10
|
end
|
@@ -12,7 +12,7 @@ describe PassaporteWeb::Identity do
|
|
12
12
|
describe ".new" do
|
13
13
|
it "should instanciate an empty object" do
|
14
14
|
identity = described_class.new
|
15
|
-
identity.attributes.should == {:accounts=>nil, :birth_date=>nil, :country=>nil, :cpf=>nil, :email=>nil, :first_name=>nil, :gender=>nil, :is_active=>nil, :language=>nil, :last_name=>nil, :nickname=>nil, :notifications=>nil, :send_myfreecomm_news=>nil, :send_partner_news=>nil, :services=>nil, :timezone=>nil, :update_info_url=>nil, :uuid=>nil, :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
|
15
|
+
identity.attributes.should == {:accounts=>nil, :birth_date=>nil, :country=>nil, :cpf=>nil, :email=>nil, :first_name=>nil, :gender=>nil, :id_token => nil, :is_active=>nil, :language=>nil, :last_name=>nil, :nickname=>nil, :notifications=>nil, :send_myfreecomm_news=>nil, :send_partner_news=>nil, :services=>nil, :timezone=>nil, :update_info_url=>nil, :uuid=>nil, :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
|
16
16
|
end
|
17
17
|
it "should instanciate an object with attributes set" do
|
18
18
|
attributes = {
|
@@ -46,7 +46,7 @@ describe PassaporteWeb::Identity do
|
|
46
46
|
"tos"=>nil
|
47
47
|
}
|
48
48
|
identity = described_class.new(attributes)
|
49
|
-
identity.attributes.should == {:accounts=>[], :birth_date=>"1945-10-27", :country=>"Brasil", :cpf=>nil, :email=>"lula@example.com", :first_name=>"Luis Inácio", :gender=>"M", :is_active=>true, :language=>"pt_BR", :last_name=>"da Silva", :nickname=>"Lula", :notifications=>{"count"=>0, "list"=>"/notifications/api/"}, :send_myfreecomm_news=>false, :send_partner_news=>false, :services=>{"myfinance"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/myfinance/", "account_manager"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/account_manager/"}, :timezone=>"GMT-3", :update_info_url=>"/profile/api/info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/", :uuid=>"a5868d14-6529-477a-9c6b-a09dd42a7cd2", :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
|
49
|
+
identity.attributes.should == {:accounts=>[], :birth_date=>"1945-10-27", :country=>"Brasil", :cpf=>nil, :email=>"lula@example.com", :first_name=>"Luis Inácio", :gender=>"M", :id_token => nil, :is_active=>true, :language=>"pt_BR", :last_name=>"da Silva", :nickname=>"Lula", :notifications=>{"count"=>0, "list"=>"/notifications/api/"}, :send_myfreecomm_news=>false, :send_partner_news=>false, :services=>{"myfinance"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/myfinance/", "account_manager"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/account_manager/"}, :timezone=>"GMT-3", :update_info_url=>"/profile/api/info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/", :uuid=>"a5868d14-6529-477a-9c6b-a09dd42a7cd2", :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
|
50
50
|
identity.last_name.should == "da Silva"
|
51
51
|
identity.is_active.should == true
|
52
52
|
identity.timezone.should == "GMT-3"
|
@@ -125,6 +125,12 @@ describe PassaporteWeb::Identity do
|
|
125
125
|
identity.accounts.map { |a| a['expiration'] }.uniq.should == [nil, "2013-04-02 00:00:00", "2014-05-01 00:00:00"]
|
126
126
|
identity.accounts.map { |a| a['services'] }.flatten.uniq.map { |s| s['slug'] }.sort.should == ["identity_client", "vc-promove"]
|
127
127
|
end
|
128
|
+
# REGRSSION
|
129
|
+
it "should return the is_active and id_token fields" do
|
130
|
+
identity = described_class.find('13b972ab-0946-4a5b-8217-60255a9cbee7', true, true)
|
131
|
+
identity.is_active.should be_true
|
132
|
+
identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
|
133
|
+
end
|
128
134
|
it "should raise an error if no profiles exist with that uuid" do
|
129
135
|
expect {
|
130
136
|
described_class.find("invalid-uuid")
|
@@ -166,6 +172,12 @@ describe PassaporteWeb::Identity do
|
|
166
172
|
identity.accounts.map { |a| a['expiration'] }.uniq.should == [nil, "2013-04-02 00:00:00", "2014-05-01 00:00:00"]
|
167
173
|
identity.accounts.map { |a| a['services'] }.flatten.uniq.map { |s| s['slug'] }.sort.should == ["identity_client", "vc-promove"]
|
168
174
|
end
|
175
|
+
# REGRSSION
|
176
|
+
it "should return the is_active and id_token fields" do
|
177
|
+
identity = described_class.find_by_email('mobileteste269@mailinator.com', true, true)
|
178
|
+
identity.is_active.should be_true
|
179
|
+
identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
|
180
|
+
end
|
169
181
|
it "should raise an error if no profiles exist with that email" do
|
170
182
|
expect {
|
171
183
|
described_class.find("invalid@email.com")
|
@@ -182,6 +194,12 @@ describe PassaporteWeb::Identity do
|
|
182
194
|
identity.email.should == 'teste@teste.com'
|
183
195
|
identity.update_info_url.should == '/accounts/api/identities/5e32f927-c4ab-404e-a91c-b2abc05afb56/'
|
184
196
|
end
|
197
|
+
# REGRSSION
|
198
|
+
it "should return the is_active and id_token fields" do
|
199
|
+
identity = described_class.authenticate('mobileteste269@mailinator.com', 'vivalasvegas')
|
200
|
+
identity.is_active.should be_true
|
201
|
+
identity.id_token.should == '9864ec27fb4fd866f6fad5bc041d0363d0bc0fd2945858a1'
|
202
|
+
end
|
185
203
|
it "should return false if the password is wrong for the given email" do
|
186
204
|
described_class.authenticate('teste@teste.com', 'wrong password').should be_false
|
187
205
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: passaporteweb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Rodrigo Tassinari de Oliveira
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -67,13 +67,13 @@ dependencies:
|
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 10.0
|
70
|
+
version: '10.0'
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 10.0
|
76
|
+
version: '10.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
- !ruby/object:Gem::Dependency
|
@@ -83,13 +83,13 @@ dependencies:
|
|
83
83
|
requirements:
|
84
84
|
- - ~>
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 4.0
|
86
|
+
version: '4.0'
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ~>
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 4.0
|
92
|
+
version: '4.0'
|
93
93
|
type: :development
|
94
94
|
prerelease: false
|
95
95
|
- !ruby/object:Gem::Dependency
|
@@ -99,13 +99,13 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.13
|
102
|
+
version: '2.13'
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
106
106
|
- - ~>
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 2.13
|
108
|
+
version: '2.13'
|
109
109
|
type: :development
|
110
110
|
prerelease: false
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -115,13 +115,13 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 2.4
|
118
|
+
version: '2.4'
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
122
122
|
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.4
|
124
|
+
version: '2.4'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
- !ruby/object:Gem::Dependency
|
@@ -147,13 +147,13 @@ dependencies:
|
|
147
147
|
requirements:
|
148
148
|
- - ~>
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.9
|
150
|
+
version: '0.9'
|
151
151
|
requirement: !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|
154
154
|
- - ~>
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: 0.9
|
156
|
+
version: '0.9'
|
157
157
|
type: :development
|
158
158
|
prerelease: false
|
159
159
|
- !ruby/object:Gem::Dependency
|
@@ -163,13 +163,13 @@ dependencies:
|
|
163
163
|
requirements:
|
164
164
|
- - ~>
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.2
|
166
|
+
version: '0.2'
|
167
167
|
requirement: !ruby/object:Gem::Requirement
|
168
168
|
none: false
|
169
169
|
requirements:
|
170
170
|
- - ~>
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: 0.2
|
172
|
+
version: '0.2'
|
173
173
|
type: :development
|
174
174
|
prerelease: false
|
175
175
|
- !ruby/object:Gem::Dependency
|
@@ -179,13 +179,13 @@ dependencies:
|
|
179
179
|
requirements:
|
180
180
|
- - ~>
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.1
|
182
|
+
version: '1.1'
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
none: false
|
185
185
|
requirements:
|
186
186
|
- - ~>
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: 1.1
|
188
|
+
version: '1.1'
|
189
189
|
type: :development
|
190
190
|
prerelease: false
|
191
191
|
- !ruby/object:Gem::Dependency
|
@@ -195,13 +195,13 @@ dependencies:
|
|
195
195
|
requirements:
|
196
196
|
- - ~>
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
version: 0.7
|
198
|
+
version: '0.7'
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
200
200
|
none: false
|
201
201
|
requirements:
|
202
202
|
- - ~>
|
203
203
|
- !ruby/object:Gem::Version
|
204
|
-
version: 0.7
|
204
|
+
version: '0.7'
|
205
205
|
type: :development
|
206
206
|
prerelease: false
|
207
207
|
- !ruby/object:Gem::Dependency
|
@@ -211,13 +211,13 @@ dependencies:
|
|
211
211
|
requirements:
|
212
212
|
- - ~>
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: 0.6
|
214
|
+
version: '0.6'
|
215
215
|
requirement: !ruby/object:Gem::Requirement
|
216
216
|
none: false
|
217
217
|
requirements:
|
218
218
|
- - ~>
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version: 0.6
|
220
|
+
version: '0.6'
|
221
221
|
type: :development
|
222
222
|
prerelease: false
|
223
223
|
description: A Ruby client for the PassaporteWeb REST API
|