roqua-core-api 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/core_api.gemspec +1 -0
- data/lib/roqua/core_api/sessions/auth_session.rb +4 -4
- data/lib/roqua/core_api/sessions/basic_auth_session.rb +1 -1
- data/lib/roqua/core_api/sessions/oauth_session.rb +1 -1
- data/lib/roqua/core_api/version.rb +1 -1
- data/lib/roqua/omniauth/rails_initializer.rb +3 -3
- data/spec/fabricators/auth_session_fabricator.rb +1 -1
- data/spec/fabricators/basic_auth_session_fabricator.rb +1 -1
- data/spec/fabricators/oauth_session_fabricator.rb +1 -1
- data/spec/lib/roqua/core_api/sessions/auth_session_spec.rb +8 -8
- data/spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb +12 -12
- data/spec/lib/roqua/core_api/sessions/oauth_session_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c40344f6697004903f2952c40768b4dd5ce8e2
|
4
|
+
data.tar.gz: 31e41c1d5826c1a774c51a800aeb7aed08f1abd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dba8ce70e38185f9d35800e0f113e931fdc84a8fec4f3c90b96750f2617890fed0230b62b920db1c3c8665ea454508a13fcae9ec3600988f8ad4cb7c62b7df3
|
7
|
+
data.tar.gz: 608ee4473cab2d2612057584a938bf23793bbc5f1c2d5da59dd8825e8795d53f24dd0d50e566ede53871e427b60499c9dc8c13875164698865ad3f5b6e948792
|
data/ChangeLog.md
CHANGED
data/core_api.gemspec
CHANGED
@@ -2,12 +2,12 @@ module Roqua
|
|
2
2
|
module CoreApi
|
3
3
|
module Sessions
|
4
4
|
class AuthSession
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :core_site
|
6
6
|
attr_reader :default_timeout
|
7
7
|
|
8
8
|
# timeout for requests in seconds
|
9
|
-
def initialize(
|
10
|
-
@
|
9
|
+
def initialize(core_site: ENV.fetch('CORE_SITE'), timeout: nil)
|
10
|
+
@core_site = core_site
|
11
11
|
@default_timeout = timeout
|
12
12
|
end
|
13
13
|
|
@@ -52,7 +52,7 @@ module Roqua
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def full_url_for(path)
|
55
|
-
|
55
|
+
core_site + api_base + path + '.json'
|
56
56
|
end
|
57
57
|
|
58
58
|
def api_base
|
@@ -5,7 +5,7 @@ module Roqua
|
|
5
5
|
attr_reader :username
|
6
6
|
attr_reader :password
|
7
7
|
|
8
|
-
def initialize(username: ENV
|
8
|
+
def initialize(username: ENV.fetch('CORE_KEY'), password: ENV.fetch('CORE_SECRET'), **additional_arguments)
|
9
9
|
@username = username
|
10
10
|
@password = password
|
11
11
|
super additional_arguments
|
@@ -12,8 +12,8 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
12
12
|
client_options: {site: 'http://core.dev'}
|
13
13
|
else
|
14
14
|
provider :doorkeeper,
|
15
|
-
ENV
|
16
|
-
ENV
|
17
|
-
client_options: {site: ENV
|
15
|
+
ENV.fetch('CORE_OAUTH_CLIENT_ID'),
|
16
|
+
ENV.fetch('CORE_OAUTH_CLIENT_SECRET'),
|
17
|
+
client_options: {site: ENV.fetch('CORE_OAUTH_URL')}
|
18
18
|
end
|
19
19
|
end
|
@@ -2,6 +2,6 @@ Fabricator(:basic_auth_session, from: Roqua::CoreApi::Sessions::BasicAuthSession
|
|
2
2
|
initialize_with do
|
3
3
|
Roqua::CoreApi::Sessions::BasicAuthSession.new username: 'some_username',
|
4
4
|
password: 'some_password',
|
5
|
-
|
5
|
+
core_site: 'http://core.dev'
|
6
6
|
end
|
7
7
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Fabricator(:oauth_session, from: Roqua::CoreApi::Sessions::OAuthSession) do
|
2
2
|
initialize_with do
|
3
|
-
Roqua::CoreApi::Sessions::OAuthSession.new access_token: 'some_access_token',
|
3
|
+
Roqua::CoreApi::Sessions::OAuthSession.new access_token: 'some_access_token', core_site: 'http://core.dev'
|
4
4
|
end
|
5
5
|
end
|
@@ -6,17 +6,17 @@ describe AuthSession do
|
|
6
6
|
let(:response) { double('response', code: 201, parsed_response: 'some_response') }
|
7
7
|
|
8
8
|
describe '#initialize' do
|
9
|
-
it 'sets the
|
10
|
-
session = AuthSession.new
|
11
|
-
expect(session.
|
9
|
+
it 'sets the core_site instance attribute' do
|
10
|
+
session = AuthSession.new core_site: 'some_core_site'
|
11
|
+
expect(session.core_site).to eq('some_core_site')
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'defaults the
|
15
|
-
|
16
|
-
ENV['
|
14
|
+
it 'defaults the core_site to the CORE_SITE env variable' do
|
15
|
+
original_env_core_site = ENV['CORE_SITE']
|
16
|
+
ENV['CORE_SITE'] = 'some_env_core_site'
|
17
17
|
session = AuthSession.new
|
18
|
-
ENV['
|
19
|
-
expect(session.
|
18
|
+
ENV['CORE_SITE'] = original_env_core_site
|
19
|
+
expect(session.core_site).to eq('some_env_core_site')
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'sets the default timeout' do
|
@@ -8,10 +8,10 @@ describe BasicAuthSession do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'defaults the username to the CORE_KEY env variable' do
|
11
|
-
|
11
|
+
original_env_core_key = ENV['CORE_KEY']
|
12
12
|
ENV['CORE_KEY'] = 'some_env_core_key'
|
13
13
|
session = Roqua::CoreApi.basic_auth_session
|
14
|
-
ENV['CORE_KEY'] =
|
14
|
+
ENV['CORE_KEY'] = original_env_core_key
|
15
15
|
expect(session.username).to eq('some_env_core_key')
|
16
16
|
end
|
17
17
|
|
@@ -21,24 +21,24 @@ describe BasicAuthSession do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'defaults the password to the CORE_SECRET env variable' do
|
24
|
-
|
24
|
+
original_env_core_secret = ENV['CORE_SECRET']
|
25
25
|
ENV['CORE_SECRET'] = 'some_env_core_secret'
|
26
26
|
session = Roqua::CoreApi.basic_auth_session
|
27
|
-
ENV['CORE_SECRET'] =
|
27
|
+
ENV['CORE_SECRET'] = original_env_core_secret
|
28
28
|
expect(session.password).to eq('some_env_core_secret')
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'allows to override the
|
32
|
-
session = Roqua::CoreApi.basic_auth_session
|
33
|
-
expect(session.
|
31
|
+
it 'allows to override the core_site variable' do
|
32
|
+
session = Roqua::CoreApi.basic_auth_session core_site: 'some_core_site'
|
33
|
+
expect(session.core_site).to eq('some_core_site')
|
34
34
|
end
|
35
35
|
|
36
|
-
it 'defaults the AuthSession
|
37
|
-
|
38
|
-
ENV['
|
36
|
+
it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
|
37
|
+
orginal_env_core_site = ENV['CORE_SITE']
|
38
|
+
ENV['CORE_SITE'] = 'some_env_core_site'
|
39
39
|
session = Roqua::CoreApi.basic_auth_session
|
40
|
-
ENV['
|
41
|
-
expect(session.
|
40
|
+
ENV['CORE_SITE'] = orginal_env_core_site
|
41
|
+
expect(session.core_site).to eq('some_env_core_site')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -10,17 +10,17 @@ describe OAuthSession do
|
|
10
10
|
expect(session.access_token).to eq('some_access_token')
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'allows to override the
|
14
|
-
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token',
|
15
|
-
expect(session.
|
13
|
+
it 'allows to override the core_site variable' do
|
14
|
+
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_site: 'some_core_site'
|
15
|
+
expect(session.core_site).to eq('some_core_site')
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'defaults the AuthSession
|
19
|
-
|
20
|
-
ENV['
|
18
|
+
it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
|
19
|
+
original_env_core_site = ENV['CORE_SITE']
|
20
|
+
ENV['CORE_SITE'] = 'some_env_core_site'
|
21
21
|
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
|
22
|
-
ENV['
|
23
|
-
expect(session.
|
22
|
+
ENV['CORE_SITE'] = original_env_core_site
|
23
|
+
expect(session.core_site).to eq('some_env_core_site')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-core-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.17'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: dotenv
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.10'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.10'
|
153
167
|
description: Provides authenticated access to Core
|
154
168
|
email: marten@veldthuis.com
|
155
169
|
executables: []
|
@@ -220,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
234
|
version: '0'
|
221
235
|
requirements: []
|
222
236
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.2.
|
237
|
+
rubygems_version: 2.2.1
|
224
238
|
signing_key:
|
225
239
|
specification_version: 4
|
226
240
|
summary: API wrapper gem around Core's API
|