g5_authentication_client 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 631343ac9b439ce2f1e1cbad1e8fa52999ff30ad
4
- data.tar.gz: 903d0901198ef0057473475b33eeb74a13b61317
3
+ metadata.gz: 475820a142d4fd801168d3e1bc7f5ffca38dd3d1
4
+ data.tar.gz: 2992ed1d10a40c9bdfc60d34c635b469150d777a
5
5
  SHA512:
6
- metadata.gz: 08bb76c84e52b228ff9790d83dc7282869e7128a72ecd855a97255a396ac8cdf241866dd9a5b194e0d96a7fed589f71eba8cc42ed74faaae35babf8eb90888c8
7
- data.tar.gz: 8ab1e14d06f37eb166c15d05b921d8b8be1bb2bfe60dc1a239ae45b035c732f5c8961f0db63c3b6cb77b9abc437d1832df17b56dae10aeac59ca3f2d9bd44eec
6
+ metadata.gz: 810219c6c6824c08aa6fd4b0499606ce94c4fdc70ccd00594b2f8649888946acdced45f6fcd19c76c449a1732f9b36eefc24c5071c831b3bdea325d1a5668a5d
7
+ data.tar.gz: e114437fc35c187dcc121ef0d39cb5d58eface8ab734f08ab5715a7e06f5f60257892253a6d7431f956820ea1d3b06e6344668a8c7a60b6b358f0fe0e3d92717
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
+ ## v0.3.0 (2015-01-08)
2
+
3
+ * Add `G5AuthenticationClient::Client#list_users`
4
+ ([#22](https://github.com/G5/g5_authentication_client/pull/22))
5
+
1
6
  ## v0.2.3 (2014-07-31)
7
+
2
8
  * remove id from body in create/update user
3
9
 
4
10
  ## v0.2.0 (2014-03-10)
@@ -7,12 +13,12 @@
7
13
 
8
14
  ## v0.1.5 (2014-03-07)
9
15
 
10
- * Add allow_password_credentials flag to determine whether client instances
16
+ * Add `allow_password_credentials` flag to determine whether client instances
11
17
  * will allow use of username/passwored attributes
12
18
 
13
19
  ## v0.1.4 (2014-03-06)
14
20
 
15
- * Change configure method namespace to g5_auth from g5_authentication_client
21
+ * Change configure method namespace to `g5_auth` from `g5_authentication_client`
16
22
 
17
23
  ## v0.1.1 (2013-11-15)
18
24
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ A client library for the g5-authentication service.
4
4
 
5
5
  ## Current version ##
6
6
 
7
- 0.2.0
7
+ 0.3.0
8
8
 
9
9
  ## Requirements ##
10
10
 
@@ -38,6 +38,7 @@ environment variable (not all of these will be used concurrently!):
38
38
  * `G5_AUTH_USERNAME` - the username for the end user to authenticate as
39
39
  * `G5_AUTH_PASSWORD` - the password for the end user to authenticate as
40
40
  * `G5_AUTH_ACCESS_TOKEN` - a valid OAuth 2.0 access token (note that tokens do expire)
41
+ * `G5_AUTH_ALLOW_PASSWORD_CREDENTIALS` - set to 'true' to use resource owner password credentials grant
41
42
 
42
43
  ### Module-level config ###
43
44
 
@@ -107,13 +108,20 @@ current_user = auth_client.me
107
108
  # => #<G5AuthenticationClient::User email="my.user@test.host" id=1>
108
109
  ```
109
110
 
110
- You can also retrieve informatino about any other user by ID:
111
+ You can also retrieve information about any other user by ID:
111
112
 
112
113
  ```ruby
113
114
  user = auth_client.get_user(42)
114
115
  # => #<G5AuthenticationClient::User email="another.user@test.host" id=42>
115
116
  ```
116
117
 
118
+ You can list all users in the remote service:
119
+
120
+ ```ruby
121
+ user = auth_client.list_users
122
+ # => [#<G5AuthenticationClient::User email="another.user@test.host" id=42>, ... ]
123
+ ```
124
+
117
125
  ### Retrieving token information ###
118
126
 
119
127
  You can retrieve information specific to the current access token, including
@@ -266,7 +274,11 @@ module-level configuration or environment variables for those:
266
274
  export G5_AUTH_CLIENT_ID='my-client-id'
267
275
  export G5_AUTH_CLIENT_SECRET='my-client-secret'
268
276
  export G5_AUTH_REDIRECT_URI='https://test.host/callback'
277
+ export G5_AUTH_ALLOW_PASSWORD_CREDENTIALS='true'
269
278
  ```
279
+ Warning: setting G5_AUTH_ALLOW_PASSWORD_CREDENTIALS will cause all client instances
280
+ to use the username/password specified in the absence of an access_token. Usually, this
281
+ will be used per instance.
270
282
 
271
283
  If you want to use a different username and password per request, then you
272
284
  should configure these on each client instance:
@@ -169,6 +169,13 @@ module G5AuthenticationClient
169
169
  auth_server_url.to_s
170
170
  end
171
171
 
172
+ # Return all users from the remote service
173
+ # @return [Array<G5AuthenticationClient::User>]
174
+ def list_users
175
+ response=oauth_access_token.get("/v1/users")
176
+ response.parsed.collect { |parsed_user| User.new(parsed_user) }
177
+ end
178
+
172
179
  private
173
180
 
174
181
  def user_hash(h)
@@ -1,3 +1,3 @@
1
1
  module G5AuthenticationClient
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -166,7 +166,7 @@ describe G5AuthenticationClient::Client do
166
166
  context 'when there is no logger configured at the top level' do
167
167
  it 'should change the value of the logger to the default' do
168
168
  expect { subject }.to change { client.logger }
169
- client.logger.should be_an_instance_of(Logger)
169
+ expect(client.logger).to be_an_instance_of(Logger)
170
170
  end
171
171
  end
172
172
  end
@@ -422,4 +422,26 @@ describe G5AuthenticationClient::Client do
422
422
 
423
423
  it_should_behave_like 'an oauth protected resource', G5AuthenticationClient::TokenInfo
424
424
  end
425
+
426
+ describe '#list_users' do
427
+ subject(:list_users) { client.list_users }
428
+
429
+ before do
430
+ stub_request(:get, /#{endpoint}\/v1\/users/).
431
+ with(headers: {'Authorization' => auth_header_value}).
432
+ to_return(status: 200,
433
+ body: [returned_user].to_json,
434
+ headers: {'Content-Type' => 'application/json'})
435
+ end
436
+
437
+ it 'should return one user' do
438
+ expect(list_users.size).to eq(1)
439
+ end
440
+
441
+ describe 'the first user' do
442
+ subject(:user) { list_users.first }
443
+
444
+ it_should_behave_like 'an oauth protected resource', G5AuthenticationClient::User
445
+ end
446
+ end
425
447
  end
@@ -372,7 +372,7 @@ describe G5AuthenticationClient::Configuration do
372
372
  subject(:options) { test_module.options }
373
373
 
374
374
  it "should have correct options" do
375
- options.should include(
375
+ expect(options).to include(
376
376
  debug: 'true',
377
377
  username: username,
378
378
  password: password,
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe G5AuthenticationClient do
4
4
  it "should have a version" do
5
- subject::VERSION.should be
5
+ expect(subject::VERSION).to be
6
6
  end
7
7
 
8
- it { should respond_to(:configure) }
9
- it { should respond_to(:reset) }
10
- it { should respond_to(:options) }
8
+ it { is_expected.to respond_to(:configure) }
9
+ it { is_expected.to respond_to(:reset) }
10
+ it { is_expected.to respond_to(:options) }
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g5_authentication_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Revels
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-31 00:00:00.000000000 Z
12
+ date: 2015-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: modelish
@@ -247,13 +247,5 @@ rubygems_version: 2.2.2
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: Client for the G5 Auth service
250
- test_files:
251
- - spec/g5_authentication_client/client_spec.rb
252
- - spec/g5_authentication_client/configuration_spec.rb
253
- - spec/g5_authentication_client/token_info_spec.rb
254
- - spec/g5_authentication_client/user_spec.rb
255
- - spec/g5_authentication_client_spec.rb
256
- - spec/spec_helper.rb
257
- - spec/support/module_configured_attribute.rb
258
- - spec/support/oauth_protected_resource.rb
250
+ test_files: []
259
251
  has_rdoc: