gris_accounts 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +13 -4
- data/lib/gris_accounts/authorization_helpers.rb +3 -3
- data/lib/gris_accounts/version.rb +1 -1
- data/spec/authorization_helpers_spec.rb +10 -11
- data/spec/spec_helper.rb +2 -0
- data/spec/support/spec_api_error_helper.rb +13 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f085c9f1964c38a7660ebd4be7cd6d642b36fb1e
|
4
|
+
data.tar.gz: 9a8ffd3cabd774027dd0199bd2ca7502214b671c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec30a91cc7ff902a671285befb50eb7dc0debaaa6233ac93d88bb481cbbe5c923d6ff4efa5f11ec8382b8ee6bde488a4ca7df6f9a76edbdeb94428d53e00d606
|
7
|
+
data.tar.gz: 8c39854c5522e3f4306a49e94602947b225731bdfc339a04daf8ef229ffccbfa75ddb880c3ca6d407b7e3a3155c0da2b731e5e6753064153de0fe1e29f61f629
|
data/.rubocop_todo.yml
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
#
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-10-08 15:58:27 -0400 using RuboCop version 0.34.2.
|
3
4
|
# The point is for the user to remove these configuration records
|
4
5
|
# one by one as the offenses are removed from the code base.
|
5
6
|
# Note that changes in the inspected code, or installation of new
|
6
7
|
# versions of RuboCop, may require this file to be generated again.
|
7
8
|
|
8
|
-
# Offense count:
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowURI, URISchemes.
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 83
|
13
|
+
|
14
|
+
# Offense count: 2
|
15
|
+
# Configuration parameters: Exclude.
|
9
16
|
Style/Documentation:
|
10
|
-
|
17
|
+
Exclude:
|
18
|
+
- 'lib/gris_accounts/authorization_helpers.rb'
|
19
|
+
- 'lib/gris_accounts/version.rb'
|
@@ -2,13 +2,13 @@ module GrisAccounts
|
|
2
2
|
module AuthorizationHelpers
|
3
3
|
def require_access_to_account(account_id)
|
4
4
|
@account_ids = payload_content['account_ids'] if payload_content
|
5
|
-
|
6
|
-
|
5
|
+
gris_error!('Forbidden.', 403) unless @account_ids &&
|
6
|
+
(@account_ids.include? account_id.to_i)
|
7
7
|
end
|
8
8
|
|
9
9
|
def user_id_from_payload
|
10
10
|
@user_id = payload_content['id'] if payload_content
|
11
|
-
|
11
|
+
gris_error!('Forbidden.', 403) unless @user_id
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'gris/grape_extensions/error_helpers'
|
2
3
|
|
3
4
|
describe GrisAccounts::AuthorizationHelpers do
|
4
|
-
|
5
|
-
include GrisAccounts::AuthorizationHelpers
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:helper) { EndpointClass.new }
|
5
|
+
let(:helper) { SpecApiErrorHelper.new }
|
9
6
|
|
10
7
|
context 'require_access_to_account' do
|
11
8
|
let(:account_id) { 1 }
|
@@ -37,9 +34,10 @@ describe GrisAccounts::AuthorizationHelpers do
|
|
37
34
|
end
|
38
35
|
|
39
36
|
it 'raises Forbidden error' do
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
helper.require_access_to_account(account_id)
|
38
|
+
expect(helper.message)
|
39
|
+
.to eq(message: { message: 'Forbidden.', status: 403 }, status: 403)
|
40
|
+
expect(helper.thrown).to eq(:error)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
@@ -68,9 +66,10 @@ describe GrisAccounts::AuthorizationHelpers do
|
|
68
66
|
end
|
69
67
|
|
70
68
|
it 'raises Forbidden error' do
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
helper.user_id_from_payload
|
70
|
+
expect(helper.message)
|
71
|
+
.to eq(message: { message: 'Forbidden.', status: 403 }, status: 403)
|
72
|
+
expect(helper.thrown).to eq(:error)
|
74
73
|
end
|
75
74
|
end
|
76
75
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Mock API helper
|
2
|
+
class SpecApiErrorHelper
|
3
|
+
include Gris::ErrorHelpers
|
4
|
+
include GrisAccounts::AuthorizationHelpers
|
5
|
+
|
6
|
+
attr_accessor :message
|
7
|
+
attr_accessor :thrown
|
8
|
+
|
9
|
+
def throw(thrown, message)
|
10
|
+
@message = message
|
11
|
+
@thrown = thrown
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gris_accounts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Fareed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gris
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/gris_accounts/version.rb
|
117
117
|
- spec/authorization_helpers_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
119
|
+
- spec/support/spec_api_error_helper.rb
|
119
120
|
homepage: https://github.com/dylanfareed/gris_accounts
|
120
121
|
licenses:
|
121
122
|
- MIT
|
@@ -136,10 +137,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
139
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.4.5
|
140
|
+
rubygems_version: 2.4.5.1
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: Gris JWT Account resource authorization helpers.
|
143
144
|
test_files:
|
144
145
|
- spec/authorization_helpers_spec.rb
|
145
146
|
- spec/spec_helper.rb
|
147
|
+
- spec/support/spec_api_error_helper.rb
|