nexaas_id-client 0.5.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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.env.test +5 -0
  4. data/.gitignore +25 -0
  5. data/.hound.yml +1063 -0
  6. data/.rspec +2 -0
  7. data/.travis.yml +4 -0
  8. data/Gemfile +4 -0
  9. data/Gemfile.lock +130 -0
  10. data/LICENSE +202 -0
  11. data/README.md +157 -0
  12. data/Rakefile +16 -0
  13. data/lib/nexaas_id/client/application.rb +35 -0
  14. data/lib/nexaas_id/client/exception.rb +30 -0
  15. data/lib/nexaas_id/client/exception_wrapper.rb +23 -0
  16. data/lib/nexaas_id/client/identity.rb +67 -0
  17. data/lib/nexaas_id/client/oauth.rb +20 -0
  18. data/lib/nexaas_id/client.rb +2 -0
  19. data/lib/nexaas_id/configuration.rb +13 -0
  20. data/lib/nexaas_id/entities/base.rb +5 -0
  21. data/lib/nexaas_id/entities/collection.rb +53 -0
  22. data/lib/nexaas_id/entities/profile/contacts.rb +4 -0
  23. data/lib/nexaas_id/entities/profile/emails.rb +4 -0
  24. data/lib/nexaas_id/entities/profile/professional_info.rb +6 -0
  25. data/lib/nexaas_id/entities/profile.rb +14 -0
  26. data/lib/nexaas_id/entities/sign_up.rb +5 -0
  27. data/lib/nexaas_id/entities.rb +2 -0
  28. data/lib/nexaas_id/resources/base.rb +34 -0
  29. data/lib/nexaas_id/resources/profile.rb +67 -0
  30. data/lib/nexaas_id/resources/sign_up.rb +30 -0
  31. data/lib/nexaas_id/resources/widget.rb +28 -0
  32. data/lib/nexaas_id/resources.rb +2 -0
  33. data/lib/nexaas_id/version.rb +4 -0
  34. data/lib/nexaas_id.rb +40 -0
  35. data/nexaas_id-client.gemspec +43 -0
  36. data/spec/nexaas_id/client/application_spec.rb +13 -0
  37. data/spec/nexaas_id/client/exception_spec.rb +15 -0
  38. data/spec/nexaas_id/client/exception_wrapper_spec.rb +48 -0
  39. data/spec/nexaas_id/client/identity_spec.rb +29 -0
  40. data/spec/nexaas_id/configuration_spec.rb +38 -0
  41. data/spec/nexaas_id/resources/profile_spec.rb +54 -0
  42. data/spec/nexaas_id/resources/sign_up_spec.rb +33 -0
  43. data/spec/nexaas_id/resources/widget_spec.rb +18 -0
  44. data/spec/nexaas_id_spec.rb +30 -0
  45. data/spec/spec_helper.rb +43 -0
  46. data/spec/support/authorization.rb +62 -0
  47. metadata +331 -0
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe NexaasID do
5
+
6
+ it 'should have a version number' do
7
+ expect(NexaasID::VERSION).not_to be_nil
8
+ end
9
+
10
+ describe 'configuration' do
11
+ it 'should be done via block initialization' do
12
+ NexaasID.configure do |c|
13
+ c.url = 'http://some/where'
14
+ c.user_agent = 'My App v1.0'
15
+ c.application_token = 'some-app-token'
16
+ c.application_secret = 'some-app-secret'
17
+ end
18
+ expect(NexaasID.configuration.url).to eq('http://some/where')
19
+ expect(NexaasID.configuration.user_agent).to eq('My App v1.0')
20
+ expect(NexaasID.configuration.application_token).to eq('some-app-token')
21
+ expect(NexaasID.configuration.application_secret).to eq('some-app-secret')
22
+ end
23
+ it 'should use a singleton object for the configuration values' do
24
+ config1 = NexaasID.configuration
25
+ config2 = NexaasID.configuration
26
+ expect(config1).to be === config2
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,43 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ require 'dotenv'
4
+
5
+ Dotenv.load('.env.test')
6
+
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ])
11
+ SimpleCov.start
12
+
13
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
14
+ require 'nexaas_id'
15
+
16
+ require 'vcr'
17
+ require 'pry'
18
+ require 'webmock/rspec'
19
+ require 'support/authorization'
20
+
21
+ VCR.configure do |c|
22
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
23
+ c.hook_into :webmock
24
+ c.ignore_localhost = true
25
+ c.default_cassette_options = { record: :new_episodes }
26
+ c.configure_rspec_metadata!
27
+ end
28
+
29
+ RSpec.configure do |c|
30
+ c.mock_with :rspec
31
+ c.example_status_persistence_file_path = '.rspec_persistence'
32
+ c.include Authorization
33
+
34
+ c.before do
35
+ NexaasID.configure do |config|
36
+ # https://sandbox.id.nexaas.com/applications/89e9d504-e2a8-476e-ac94-c33e68399c7e
37
+ # Test application - luiz.buiatte+pw.api.test@nexaas.com
38
+ config.url = ENV['NEXAAS_ID_URL']
39
+ config.application_token = ENV['APPLICATION_TOKEN']
40
+ config.application_secret = ENV['APPLICATION_SECRET']
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,62 @@
1
+ require 'faraday-cookie_jar'
2
+
3
+ module Authorization
4
+
5
+ def authorization_code
6
+ connection = Faraday.new(url: NexaasID.configuration.url) do |builder|
7
+ builder.use :cookie_jar
8
+ builder.adapter Faraday.default_adapter
9
+ end
10
+
11
+ response = connection.get('/sign_in')
12
+ data = {
13
+ 'session[email]': ENV['USER_NAME'],
14
+ 'session[password]': ENV['USER_PASSWORD'],
15
+ 'authenticity_token': authenticity_token(response)
16
+ }
17
+
18
+ connection.post('/sign_in', URI.encode_www_form(data))
19
+
20
+ response = connection.get('oauth/authorize',
21
+ client_id: NexaasID.configuration.application_token,
22
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
23
+ response_type: 'code',
24
+ scope: 'profile invite')
25
+
26
+ if(response.headers['location'].nil? || response.headers['location'] == '')
27
+ data = {
28
+ client_id: NexaasID.configuration.application_token,
29
+ commit: 'Authorize',
30
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
31
+ response_type: 'code',
32
+ authenticity_token: authenticity_token(response),
33
+ scope: 'profile invite'
34
+ }
35
+
36
+ response = connection.post('/oauth/authorize', URI.encode_www_form(data))
37
+ end
38
+
39
+ response.headers['location'].match(%r{code=(.+?)$}).captures.first
40
+ end
41
+
42
+ def authenticity_token(response)
43
+ response.body.match(%r{name="authenticity_token" value="(.+?)"}).captures.first
44
+ end
45
+
46
+ def access_token
47
+ VCR.use_cassette('access_token') do
48
+ client = NexaasID::Client::OAuth.build
49
+ client.auth_code.get_token(authorization_code, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
50
+ end
51
+ end
52
+
53
+ def user_credentials
54
+ OpenStruct.new.tap do |credentials|
55
+ token = access_token
56
+ credentials.access_token = token.token
57
+ credentials.refresh_token = token.refresh_token
58
+ credentials.expires_in = token.expires_in
59
+ credentials.expires_at = token.expires_at
60
+ end
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,331 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nexaas_id-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Tassinari de Oliveira
8
+ - Eduardo Hertz
9
+ - Rafael B. Tauil
10
+ - Luiz Carlos Buiatte
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2018-09-10 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: multi_json
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.11'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.11'
30
+ - !ruby/object:Gem::Dependency
31
+ name: virtus
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '1.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: oauth2
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: 1.4.0
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: 1.4.0
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '1.9'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.9'
72
+ - !ruby/object:Gem::Dependency
73
+ name: rake
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '12.0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '12.0'
86
+ - !ruby/object:Gem::Dependency
87
+ name: rdoc
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '6.0'
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '6.0'
100
+ - !ruby/object:Gem::Dependency
101
+ name: rspec
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '3.6'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '3.6'
114
+ - !ruby/object:Gem::Dependency
115
+ name: vcr
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '2.4'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '2.4'
128
+ - !ruby/object:Gem::Dependency
129
+ name: webmock
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '3.4'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '3.4'
142
+ - !ruby/object:Gem::Dependency
143
+ name: pry-byebug
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: '3.4'
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '3.4'
156
+ - !ruby/object:Gem::Dependency
157
+ name: awesome_print
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: '1.8'
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '1.8'
170
+ - !ruby/object:Gem::Dependency
171
+ name: simplecov
172
+ requirement: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - "~>"
175
+ - !ruby/object:Gem::Version
176
+ version: '0.14'
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '0.14'
184
+ - !ruby/object:Gem::Dependency
185
+ name: coveralls
186
+ requirement: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '0.8'
191
+ type: :development
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: '0.8'
198
+ - !ruby/object:Gem::Dependency
199
+ name: json
200
+ requirement: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - "~>"
203
+ - !ruby/object:Gem::Version
204
+ version: '2.1'
205
+ type: :development
206
+ prerelease: false
207
+ version_requirements: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - "~>"
210
+ - !ruby/object:Gem::Version
211
+ version: '2.1'
212
+ - !ruby/object:Gem::Dependency
213
+ name: faraday-cookie_jar
214
+ requirement: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - "~>"
217
+ - !ruby/object:Gem::Version
218
+ version: 0.0.6
219
+ type: :development
220
+ prerelease: false
221
+ version_requirements: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - "~>"
224
+ - !ruby/object:Gem::Version
225
+ version: 0.0.6
226
+ - !ruby/object:Gem::Dependency
227
+ name: dotenv
228
+ requirement: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - "~>"
231
+ - !ruby/object:Gem::Version
232
+ version: 2.5.0
233
+ type: :development
234
+ prerelease: false
235
+ version_requirements: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - "~>"
238
+ - !ruby/object:Gem::Version
239
+ version: 2.5.0
240
+ description: A Ruby client for the Nexaas ID REST API
241
+ email:
242
+ - rodrigo@pittlandia.net
243
+ - rodrigo.tassinari@myfreecomm.com.br
244
+ - eduardo.hertz@myfreecomm.com.br
245
+ - rafael@tauil.com.br
246
+ - luiz.buiatte@nexaas.com
247
+ executables: []
248
+ extensions: []
249
+ extra_rdoc_files: []
250
+ files:
251
+ - ".coveralls.yml"
252
+ - ".env.test"
253
+ - ".gitignore"
254
+ - ".hound.yml"
255
+ - ".rspec"
256
+ - ".travis.yml"
257
+ - Gemfile
258
+ - Gemfile.lock
259
+ - LICENSE
260
+ - README.md
261
+ - Rakefile
262
+ - lib/nexaas_id.rb
263
+ - lib/nexaas_id/client.rb
264
+ - lib/nexaas_id/client/application.rb
265
+ - lib/nexaas_id/client/exception.rb
266
+ - lib/nexaas_id/client/exception_wrapper.rb
267
+ - lib/nexaas_id/client/identity.rb
268
+ - lib/nexaas_id/client/oauth.rb
269
+ - lib/nexaas_id/configuration.rb
270
+ - lib/nexaas_id/entities.rb
271
+ - lib/nexaas_id/entities/base.rb
272
+ - lib/nexaas_id/entities/collection.rb
273
+ - lib/nexaas_id/entities/profile.rb
274
+ - lib/nexaas_id/entities/profile/contacts.rb
275
+ - lib/nexaas_id/entities/profile/emails.rb
276
+ - lib/nexaas_id/entities/profile/professional_info.rb
277
+ - lib/nexaas_id/entities/sign_up.rb
278
+ - lib/nexaas_id/resources.rb
279
+ - lib/nexaas_id/resources/base.rb
280
+ - lib/nexaas_id/resources/profile.rb
281
+ - lib/nexaas_id/resources/sign_up.rb
282
+ - lib/nexaas_id/resources/widget.rb
283
+ - lib/nexaas_id/version.rb
284
+ - nexaas_id-client.gemspec
285
+ - spec/nexaas_id/client/application_spec.rb
286
+ - spec/nexaas_id/client/exception_spec.rb
287
+ - spec/nexaas_id/client/exception_wrapper_spec.rb
288
+ - spec/nexaas_id/client/identity_spec.rb
289
+ - spec/nexaas_id/configuration_spec.rb
290
+ - spec/nexaas_id/resources/profile_spec.rb
291
+ - spec/nexaas_id/resources/sign_up_spec.rb
292
+ - spec/nexaas_id/resources/widget_spec.rb
293
+ - spec/nexaas_id_spec.rb
294
+ - spec/spec_helper.rb
295
+ - spec/support/authorization.rb
296
+ homepage: https://github.com/myfreecomm/nexaas-id-client-ruby
297
+ licenses:
298
+ - Apache-2.0
299
+ metadata: {}
300
+ post_install_message:
301
+ rdoc_options: []
302
+ require_paths:
303
+ - lib
304
+ required_ruby_version: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '0'
309
+ required_rubygems_version: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ requirements: []
315
+ rubyforge_project:
316
+ rubygems_version: 2.7.6
317
+ signing_key:
318
+ specification_version: 4
319
+ summary: 'A Ruby client for the Nexaas ID REST API: https://id.nexaas.com/static/docs/'
320
+ test_files:
321
+ - spec/nexaas_id/client/application_spec.rb
322
+ - spec/nexaas_id/client/exception_spec.rb
323
+ - spec/nexaas_id/client/exception_wrapper_spec.rb
324
+ - spec/nexaas_id/client/identity_spec.rb
325
+ - spec/nexaas_id/configuration_spec.rb
326
+ - spec/nexaas_id/resources/profile_spec.rb
327
+ - spec/nexaas_id/resources/sign_up_spec.rb
328
+ - spec/nexaas_id/resources/widget_spec.rb
329
+ - spec/nexaas_id_spec.rb
330
+ - spec/spec_helper.rb
331
+ - spec/support/authorization.rb