bouncer-client 0.3 → 0.3.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/bouncer-client/user.rb +5 -7
- data/lib/bouncer-client/version.rb +1 -1
- data/spec/model/user_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71349750645c6431c2cc2885a822adf6407cc7a6
|
4
|
+
data.tar.gz: 30e979346953bb2420ce72113f753093dff91acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299e21f5dec93723d96d9d4000425d20392369409354bd1ff762bad1bea85088af809271e6d3ff1b019c1f0a6a5a59173fc064cc4e743f3b34091a4a1f9d3d49
|
7
|
+
data.tar.gz: 79683b32dba63e17e1c7105a0719e5f9dc30cc2d0f891d3ed6d190424ae9c905ef603798d06ab20c50e6d87cff3850129d294fec5736e96d46d02f18476a3591
|
data/lib/bouncer-client/user.rb
CHANGED
@@ -4,19 +4,17 @@ module Bouncer
|
|
4
4
|
|
5
5
|
def self.from_id id
|
6
6
|
client = Bouncer::Client.current
|
7
|
-
client.jwt
|
7
|
+
client.jwt(ENV['SERVICE_TOKEN'] || '')
|
8
8
|
raw = client.user id
|
9
9
|
from_json raw.body['users'][0]
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.from_json json
|
13
13
|
user = User.new
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
user.super_admin = json['super_admin']
|
19
|
-
user.created_at = json['created_at']
|
14
|
+
json.keys.map do |key|
|
15
|
+
user.class.class_eval { attr_accessor key.to_sym }
|
16
|
+
user.send("#{key}=", json[key])
|
17
|
+
end
|
20
18
|
user
|
21
19
|
end
|
22
20
|
|
data/spec/model/user_spec.rb
CHANGED
@@ -8,4 +8,15 @@ describe Bouncer::User do
|
|
8
8
|
expect(user.id).to eq uuid
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
it 'is created dynamically from a JSON payload' do
|
13
|
+
uuid = SecureRandom.uuid
|
14
|
+
VCR.use_cassette 'bouncer/user' do
|
15
|
+
user = Bouncer::User.from_json({ email: 'foo@example.com', super_admin: false, role: 'manager' })
|
16
|
+
expect(user).to respond_to :email
|
17
|
+
expect(user).to respond_to :super_admin
|
18
|
+
expect(user).to respond_to :role
|
19
|
+
expect(user).to_not respond_to :foo
|
20
|
+
end
|
21
|
+
end
|
11
22
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,8 @@ require 'bouncer-client'
|
|
20
20
|
# in ./support/ and its subdirectories.
|
21
21
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
22
22
|
|
23
|
+
ENV['BOUNCER_URL'] = 'https://bouncer-api.monsieur.co'
|
24
|
+
|
23
25
|
RSpec.configure do |config|
|
24
26
|
VCR.configure do |c|
|
25
27
|
c.cassette_library_dir = 'spec/cassettes'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bouncer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurt Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
276
|
version: '0'
|
277
277
|
requirements: []
|
278
278
|
rubyforge_project:
|
279
|
-
rubygems_version: 2.
|
279
|
+
rubygems_version: 2.4.6
|
280
280
|
signing_key:
|
281
281
|
specification_version: 4
|
282
282
|
summary: Allows Rails to easily use a Bouncer instance for authentication
|