bouncer-client 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 284e65e35d8e30fe0dd576664e52fe91399a38ad
4
- data.tar.gz: e03e637d06317538278c9c2b01813e4e592a752b
3
+ metadata.gz: 83c7547cc0455dedc3b0e335ec4ed3947929c251
4
+ data.tar.gz: 582dfcc1a9e43ca10f94f4bcaa1da2a044220a2c
5
5
  SHA512:
6
- metadata.gz: b51b67910d070fe49117b6862315e37d1693b9421330dbc5a249c626cbf0b86adfce90c19231125fa565581a93aea1c2f0c9c42d0bda3726d62fd1eb8992f050
7
- data.tar.gz: 88f163cf07fa042db7f8e9905a2d8b7381865898c77e4fb891dc2e6e2e033e8155f03b35d3d34034079c1f159067b8bba382dedee5d7edd8d2cfbeedab6f2912
6
+ metadata.gz: ee79644b7406739aa651d8a87410e7e890a5daa84552da502ddebc458acdbbc34e4d5e888a5a72a88573e3c17f6550c01b5a0e4a52bb78f07d048d6956437fbb
7
+ data.tar.gz: c964178c31e5f10057946ecff4cafd25549f2f11c867f6c9257f2f7a77fa8b28a94e2eaf5e79c9da88db43f5b6259ae664e58279994250eccbb8c907945d317a
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .env
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
@@ -16,23 +16,19 @@ module Bouncer
16
16
  end
17
17
 
18
18
  def id
19
- if device?
20
- @payload["devices"]["id"]
21
- else
22
- @payload["users"]["id"]
23
- end
19
+ model['id']
24
20
  end
25
21
 
26
22
  def email
27
- @payload["users"]["email"] if user?
23
+ model["email"] if user?
28
24
  end
29
25
 
30
26
  def phone
31
- @payload["users"]["phone"] if user?
27
+ model["phone"] if user?
32
28
  end
33
29
 
34
30
  def image
35
- @payload["users"]["image"] if user?
31
+ model["image"] if user?
36
32
  end
37
33
 
38
34
  def validate!
@@ -41,7 +37,7 @@ module Bouncer
41
37
  end
42
38
 
43
39
  def super_admin?
44
- @payload["users"]["super_admin"] == true
40
+ model["super_admin"] == true
45
41
  end
46
42
 
47
43
  def device?
@@ -82,6 +78,14 @@ module Bouncer
82
78
  redis.del("TOKEN:#{@token}")
83
79
  end
84
80
 
81
+ def model
82
+ if device?
83
+ @payload['devices'][0]
84
+ else
85
+ @payload['users'][0]
86
+ end
87
+ end
88
+
85
89
  def redis
86
90
  Redis.current
87
91
  end
@@ -1,3 +1,3 @@
1
1
  module Bouncer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -7,8 +7,16 @@ http_interactions:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
+ Content-Type:
11
+ - application/json
10
12
  Authorization:
11
- - Bearer 5d9680a671c060d08836940e50ded28d361944767a9436fe6df5e7462087a8ee
13
+ - Bearer <ADMIN_TOKEN>
14
+ User-Agent:
15
+ - Faraday v0.9.1
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
12
20
  response:
13
21
  status:
14
22
  code: 200
@@ -19,7 +27,7 @@ http_interactions:
19
27
  Connection:
20
28
  - close
21
29
  Date:
22
- - Tue, 03 Feb 2015 16:09:42 GMT
30
+ - Thu, 19 Feb 2015 15:25:06 GMT
23
31
  Status:
24
32
  - 200 OK
25
33
  X-Frame-Options:
@@ -31,20 +39,20 @@ http_interactions:
31
39
  Content-Type:
32
40
  - application/json; charset=utf-8
33
41
  Etag:
34
- - W/"6f76c9ea61a57b7e2683af4672bdf138"
42
+ - W/"059ee065b4ee4df76ac3ab9d05708e89"
35
43
  Cache-Control:
36
44
  - max-age=0, private, must-revalidate
37
45
  X-Request-Id:
38
- - d6709999-7ff6-4b9c-bdf7-6cceb4672c23
46
+ - 000d0e52-7733-4d51-868d-53b169dc38d7
39
47
  X-Runtime:
40
- - '0.011506'
48
+ - '0.012449'
41
49
  Via:
42
50
  - 1.1 vegur
43
51
  body:
44
52
  encoding: UTF-8
45
- string: '{"resource_owner_id":"54bff1bcd43b8d0009000001","scopes":["user"],"expires_in_seconds":5436,"application":{"uid":null},"created_at":1422978018}'
53
+ string: '{"resource_owner_id":"960dd380-85db-43c7-b79b-ed3f3c7d4a88","scopes":["user"],"expires_in_seconds":6265,"application":{"uid":null},"created_at":1424358570}'
46
54
  http_version:
47
- recorded_at: Tue, 03 Feb 2015 16:09:41 GMT
55
+ recorded_at: Thu, 19 Feb 2015 15:25:05 GMT
48
56
  - request:
49
57
  method: get
50
58
  uri: https://mbouncer.herokuapp.com/me
@@ -52,8 +60,16 @@ http_interactions:
52
60
  encoding: US-ASCII
53
61
  string: ''
54
62
  headers:
63
+ Content-Type:
64
+ - application/json
55
65
  Authorization:
56
- - Bearer 5d9680a671c060d08836940e50ded28d361944767a9436fe6df5e7462087a8ee
66
+ - Bearer <ADMIN_TOKEN>
67
+ User-Agent:
68
+ - Faraday v0.9.1
69
+ Accept-Encoding:
70
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
71
+ Accept:
72
+ - "*/*"
57
73
  response:
58
74
  status:
59
75
  code: 200
@@ -64,7 +80,7 @@ http_interactions:
64
80
  Connection:
65
81
  - close
66
82
  Date:
67
- - Tue, 03 Feb 2015 16:09:45 GMT
83
+ - Thu, 19 Feb 2015 15:25:06 GMT
68
84
  Status:
69
85
  - 200 OK
70
86
  X-Frame-Options:
@@ -76,18 +92,18 @@ http_interactions:
76
92
  Content-Type:
77
93
  - application/json; charset=utf-8
78
94
  Etag:
79
- - W/"7c3d209db250608abd463fb92610674c"
95
+ - W/"f3b0c963380b198b62bf64cc73b32e13"
80
96
  Cache-Control:
81
97
  - max-age=0, private, must-revalidate
82
98
  X-Request-Id:
83
- - 5023277a-bf93-4ba0-a7ff-b5d6ae4e3fe2
99
+ - 266192c3-9a4b-4374-952f-a500b9e764af
84
100
  X-Runtime:
85
- - '0.406796'
101
+ - '0.018491'
86
102
  Via:
87
103
  - 1.1 vegur
88
104
  body:
89
105
  encoding: UTF-8
90
- string: '{"users":{"id":"54bff1bcd43b8d0009000001","email":"kurtisnelson@gmail.com","image":"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p50x50/1422503_10201617485134756_581959844_n.jpg?oh=3c43c2d34d7d47e80db7fa70bb785d25\u0026oe=5520E205\u0026__gda__=1431516611_892762dead4a80879480e80af6e218cb","super_admin": true, "phone":"4075120689","confirmed_at":"2015-01-21T18:36:44.270Z"},"links":{"self":{"href":"https://bouncer.monsieur.co/users/54bff1bcd43b8d0009000001"}}}'
106
+ string: '{"users":[{"id":"960dd380-85db-43c7-b79b-ed3f3c7d4a88","image":"https://secure.gravatar.com/avatar/ebfcbe366c47be18e8d3d6eb13d51d17?d=mm\u0026s=50","phone":"4075120689","email":"kurt@monsieur.co","name":null,"super_admin":true,"confirmed_at":"2000-01-01T18:46:46.786Z"}]}'
91
107
  http_version:
92
- recorded_at: Tue, 03 Feb 2015 16:09:44 GMT
108
+ recorded_at: Thu, 19 Feb 2015 15:25:05 GMT
93
109
  recorded_with: VCR 2.9.3
@@ -7,8 +7,16 @@ http_interactions:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
+ Content-Type:
11
+ - application/json
10
12
  Authorization:
11
- - Bearer 0f99d628d2ae1d20ebe02dc794348dcd351e322a920df3bf0de6929987c8c59f
13
+ - Bearer <DEVICE_TOKEN>
14
+ User-Agent:
15
+ - Faraday v0.9.1
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
12
20
  response:
13
21
  status:
14
22
  code: 200
@@ -19,7 +27,7 @@ http_interactions:
19
27
  Connection:
20
28
  - close
21
29
  Date:
22
- - Wed, 28 Jan 2015 15:59:40 GMT
30
+ - Thu, 19 Feb 2015 15:25:06 GMT
23
31
  Status:
24
32
  - 200 OK
25
33
  X-Frame-Options:
@@ -31,20 +39,20 @@ http_interactions:
31
39
  Content-Type:
32
40
  - application/json; charset=utf-8
33
41
  Etag:
34
- - W/"f5d4810748f6c26c7b4df2173a949a31"
42
+ - W/"4fb3c8dc402f680c9198a329b07f0755"
35
43
  Cache-Control:
36
44
  - max-age=0, private, must-revalidate
37
45
  X-Request-Id:
38
- - 53bbf8a3-4f0e-4782-8854-3d99a23cd69d
46
+ - f7c8ab25-7bf1-4804-8f95-3b1cbffcccfb
39
47
  X-Runtime:
40
- - '0.004567'
48
+ - '0.012130'
41
49
  Via:
42
50
  - 1.1 vegur
43
51
  body:
44
52
  encoding: UTF-8
45
- string: '{"resource_owner_id":"54c904b2773db80010000001","scopes":["machine"],"expires_in_seconds":85702,"application":{"uid":null},"created_at":1422460082}'
53
+ string: '{"resource_owner_id":"e6b89f6d-fc60-4001-b666-8a5a7bb8b369","scopes":["device"],"expires_in_seconds":86366,"application":{"uid":null},"created_at":1424359472}'
46
54
  http_version:
47
- recorded_at: Wed, 28 Jan 2015 15:59:42 GMT
55
+ recorded_at: Thu, 19 Feb 2015 15:25:05 GMT
48
56
  - request:
49
57
  method: get
50
58
  uri: https://mbouncer.herokuapp.com/me
@@ -52,8 +60,16 @@ http_interactions:
52
60
  encoding: US-ASCII
53
61
  string: ''
54
62
  headers:
63
+ Content-Type:
64
+ - application/json
55
65
  Authorization:
56
- - Bearer 0f99d628d2ae1d20ebe02dc794348dcd351e322a920df3bf0de6929987c8c59f
66
+ - Bearer <DEVICE_TOKEN>
67
+ User-Agent:
68
+ - Faraday v0.9.1
69
+ Accept-Encoding:
70
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
71
+ Accept:
72
+ - "*/*"
57
73
  response:
58
74
  status:
59
75
  code: 200
@@ -64,7 +80,7 @@ http_interactions:
64
80
  Connection:
65
81
  - close
66
82
  Date:
67
- - Wed, 28 Jan 2015 15:59:44 GMT
83
+ - Thu, 19 Feb 2015 15:25:06 GMT
68
84
  Status:
69
85
  - 200 OK
70
86
  X-Frame-Options:
@@ -76,18 +92,18 @@ http_interactions:
76
92
  Content-Type:
77
93
  - application/json; charset=utf-8
78
94
  Etag:
79
- - W/"54fec5a35fa28357fdad8184627a1bbf"
95
+ - W/"5fe875d6bad419d51fb0de4ea009162d"
80
96
  Cache-Control:
81
97
  - max-age=0, private, must-revalidate
82
98
  X-Request-Id:
83
- - b55a5f05-bd6c-41fa-aad7-d4468a5b3836
99
+ - c827cf49-c8db-4b22-b101-89e5b1e6e30f
84
100
  X-Runtime:
85
- - '0.031087'
101
+ - '0.149730'
86
102
  Via:
87
103
  - 1.1 vegur
88
104
  body:
89
105
  encoding: UTF-8
90
- string: '{"devices":{"id":"54d104bfe920dcdb20000001","serial":"123456","user":"54c6acc0e920dc9956000007","token":"54d104bfe920dcdb20000002","created_at":"2015-02-03T17:26:23.218Z"},"links":{"self":{"href":"http://localhost:8000/devices/54d104bfe920dcdb20000001"}},"linked":{"tokens":[{"id":"54d104bfe920dcdb20000002","resource_owner_id":"54d104bfe920dcdb20000001","refresh_token":"a3db24a6b7e4acf9089f392bcee588d485ba43735bc80fadfc75b743707f5443","expires_in_seconds":86351,"access_token":"b23741cdc650666c1e3eaff8eb95cee0e120d65d61de25ff8e5d6ee64757b715"}],"users":[{"email":"kurt@monsieur.co","id":"54c6acc0e920dc9956000007","image":"https://secure.gravatar.com/avatar/ebfcbe366c47be18e8d3d6eb13d51d17?d=mm","super_admin":true}]}}'
106
+ string: '{"devices":[{"id":"e6b89f6d-fc60-4001-b666-8a5a7bb8b369","name":null,"serial":"uniquestuff","created_at":"2015-02-19T15:24:32.786Z","links":{"user":"960dd380-85db-43c7-b79b-ed3f3c7d4a88","device_token":"352"}}],"linked":{"device_tokens":[{"id":352,"resource_owner_id":"e6b89f6d-fc60-4001-b666-8a5a7bb8b369","refresh_token":"463384f6b4bf1d4f3c357cc1a29c27968ebf01fbc7af7de3fccae8beb25dca42","expires_in_seconds":86366,"access_token":"<DEVICE_TOKEN>"}]}}'
91
107
  http_version:
92
- recorded_at: Wed, 28 Jan 2015 15:59:45 GMT
108
+ recorded_at: Thu, 19 Feb 2015 15:25:05 GMT
93
109
  recorded_with: VCR 2.9.3
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bouncer::Token do
4
- let(:admin_token) { Bouncer::Token.new 'Bearer 5d9680a671c060d08836940e50ded28d361944767a9436fe6df5e7462087a8ee' }
5
- let(:device_token) { Bouncer::Token.new 'Bearer b23741cdc650666c1e3eaff8eb95cee0e120d65d61de25ff8e5d6ee64757b715'}
4
+ let(:admin_token) { Bouncer::Token.new('Bearer ' + ENV['ADMIN_TOKEN']) }
5
+ let(:device_token) { Bouncer::Token.new('Bearer ' + ENV['DEVICE_TOKEN'])}
6
6
  describe "#validate!" do
7
7
  it "validates admin tokens" do
8
8
  VCR.use_cassette 'bouncer/valid_admin' do
@@ -27,6 +27,32 @@ describe Bouncer::Token do
27
27
  end
28
28
  end
29
29
 
30
+ describe "#id" do
31
+ context "device token" do
32
+ it 'is correct' do
33
+ VCR.use_cassette('bouncer/valid_device') { expect(device_token.id).to eq "e6b89f6d-fc60-4001-b666-8a5a7bb8b369" }
34
+ end
35
+ end
36
+ context "user token" do
37
+ it 'is correct' do
38
+ VCR.use_cassette('bouncer/valid_admin') { expect(admin_token.id).to eq "960dd380-85db-43c7-b79b-ed3f3c7d4a88" }
39
+ end
40
+ end
41
+ end
42
+
43
+ describe "#email" do
44
+ context "user token" do
45
+ it 'is correct' do
46
+ VCR.use_cassette('bouncer/valid_admin') { expect(admin_token.email).to eq "kurt@monsieur.co" }
47
+ end
48
+ end
49
+ context "device token" do
50
+ it 'is nil' do
51
+ VCR.use_cassette('bouncer/valid_device') { expect(device_token.email).to eq nil }
52
+ end
53
+ end
54
+ end
55
+
30
56
  describe "#device?" do
31
57
  context "device token" do
32
58
  it "returns true" do
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: 0.1.1
4
+ version: 0.1.2
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-02-18 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -202,7 +202,6 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - ".coveralls.yml"
204
204
  - ".document"
205
- - ".env"
206
205
  - ".gitignore"
207
206
  - ".rspec"
208
207
  - ".travis.yml"
data/.env DELETED
@@ -1 +0,0 @@
1
- BOUNCER_URL="https://mbouncer.herokuapp.com"