aptible-auth 0.11.2 → 0.11.3

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: 6e402ddd5ca9cb30e1a4c52eab79ec6447a4f16b
4
- data.tar.gz: fc28cb16dc80c9d45f4bd27bace7b5926345eed0
3
+ metadata.gz: 93d75943842f3e5ed625c2da64dc0c7ee83ffd69
4
+ data.tar.gz: 84e6d466d82a90fb85060294a5b93f1a9702925d
5
5
  SHA512:
6
- metadata.gz: 01aa4ff7eb490715c1c0777cbc1aa967b6f4a365b72165ee1dfc2a0cb0e89b5e70230e63059fe6719f0e265bd64270894874aa8d96696480fb1c9e82ef637ca1
7
- data.tar.gz: 39f2f647e6648ab8c349af53d690222a83b0dce107c212140d042a416033ce0f9c3aee0687154cc72df4f73fa09161c32c28edb8a1fb554d21e28f4cef4887c5
6
+ metadata.gz: 73d27eeac4954a579d97e8148f23f1a96316825e7b95c6641870db5296b6a5bdbf789e0ff12a587fc3e7cb0536c6a4d457ca2fb8a58b15f9e7950f47657a8a86
7
+ data.tar.gz: bd1bf9f3fd30a2d2196807507a754c9183d85a9fc0f6cdf424f465caf837b30958e13a6793fc7fcf94b5dc0fa28024fb98361e2f4ccac5b878624c6eb40a8412
@@ -26,7 +26,7 @@ module Aptible
26
26
  parse_oauth_response(response)
27
27
  end
28
28
 
29
- def authenticate_impersonate(user_href, options)
29
+ def authenticate_impersonate(subject_token, subject_token_type, options)
30
30
  # TODO: This duplicates aptible-resource, is it worth extracting?
31
31
  token = case token = options.delete(:token)
32
32
  when Aptible::Resource::Base then token.access_token
@@ -39,7 +39,7 @@ module Aptible
39
39
  options[:scope] ||= 'manage'
40
40
  response = oauth.token_exchange.get_token(
41
41
  token, 'urn:ietf:params:oauth:token-type:jwt',
42
- user_href, 'aptible:user:href', options)
42
+ subject_token, subject_token_type, options)
43
43
  parse_oauth_response(response)
44
44
  end
45
45
 
@@ -49,6 +49,7 @@ module Aptible
49
49
  end
50
50
 
51
51
  def process_options(options)
52
+ options = options.dup
52
53
  if (email = options.delete(:email)) &&
53
54
  (password = options.delete(:password))
54
55
  authenticate_user(email, password, options)
@@ -56,8 +57,12 @@ module Aptible
56
57
  (client_secret = options.delete(:client_secret)) &&
57
58
  (subject = options.delete(:subject))
58
59
  authenticate_client(client_id, client_secret, subject, options)
59
- elsif (user_href = options.delete(:user_href))
60
- authenticate_impersonate(user_href, options)
60
+ elsif (href = options.delete(:user_href))
61
+ authenticate_impersonate(href, 'aptible:user:href', options)
62
+ elsif (href = options.delete(:organization_href))
63
+ authenticate_impersonate(href, 'aptible:organization:href', options)
64
+ elsif (email = options.delete(:user_email))
65
+ authenticate_impersonate(email, 'aptible:user:email', options)
61
66
  else
62
67
  fail 'Unrecognized options'
63
68
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Auth
3
- VERSION = '0.11.2'
3
+ VERSION = '0.11.3'
4
4
  end
5
5
  end
@@ -27,6 +27,13 @@ describe Aptible::Auth::Token do
27
27
  subject: 'user@example.com'
28
28
  )
29
29
  end
30
+
31
+ it 'should not alter the hash it receives' do
32
+ options = { email: 'some email' }
33
+ options_before = options.dup
34
+ expect { described_class.create options }.to raise_error(/Unrecognized/)
35
+ expect(options).to eq(options_before)
36
+ end
30
37
  end
31
38
 
32
39
  describe '#initialize' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-billing