redbooth-ruby 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redbooth-ruby/session.rb +11 -9
- data/lib/redbooth-ruby/version.rb +1 -1
- data/redbooth-ruby.gemspec +1 -1
- data/spec/redbooth-ruby/session_spec.rb +35 -10
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3cb643a0b5277bd0811041afd475eee458fbc6
|
4
|
+
data.tar.gz: 3c3bcb50e38e37f3c3daa8f4e4725e11829c5532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f2aa1ccaf85f45a6c33c6da9c73999cff96e118fa5fb1b415ce10bcc40e0719bea46416ae826591b91d1e51143a5e8ba288e4429ef5ebbaa496ffc72c44173
|
7
|
+
data.tar.gz: ebc579951c1754a24cdef20f53fab98cd1c62ee48e84b13108ab812886157f65df4995a5da1affb21504c93f90ca7802b302ef5d7546286b75580d2fadbb5d9e
|
@@ -7,12 +7,7 @@ module RedboothRuby
|
|
7
7
|
attr_accessor :refresh_token, :expires_in, :auto_refresh_token, :on_token_refresh
|
8
8
|
attr_accessor :consumer_key, :consumer_secret
|
9
9
|
attr_accessor :oauth_verifier, :oauth_token
|
10
|
-
|
11
|
-
OAUTH_URLS = {
|
12
|
-
site: 'https://redbooth.com/api/3',
|
13
|
-
authorize_url: 'https://redbooth.com/oauth2/authorize',
|
14
|
-
token_url: 'https://redbooth.com/oauth2/token'
|
15
|
-
}
|
10
|
+
attr_accessor :oauth_urls
|
16
11
|
|
17
12
|
def initialize(opts = {})
|
18
13
|
@token = opts[:token]
|
@@ -24,6 +19,13 @@ module RedboothRuby
|
|
24
19
|
@consumer_secret = opts[:consumer_secret] || RedboothRuby.configuration[:consumer_secret]
|
25
20
|
@oauth_verifier = opts[:oauth_verifier]
|
26
21
|
@oauth_token = opts[:oauth_token]
|
22
|
+
oauth2_base = opts[:oauth2_base] || RedboothRuby.configuration[:oauth2_base] || 'redbooth.com'
|
23
|
+
oauth_site = "https://#{oauth2_base}/api/3"
|
24
|
+
@oauth_urls = {
|
25
|
+
site: "https://#{oauth2_base}/api/3",
|
26
|
+
authorize_url: "https://#{oauth2_base}/oauth2/authorize",
|
27
|
+
token_url: "https://#{oauth2_base}/oauth2/token"
|
28
|
+
}
|
27
29
|
end
|
28
30
|
|
29
31
|
def valid?
|
@@ -32,11 +34,11 @@ module RedboothRuby
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def client
|
35
|
-
@client ||= OAuth2::Client.new(consumer_key, consumer_secret,
|
37
|
+
@client ||= OAuth2::Client.new(consumer_key, consumer_secret, @oauth_urls)
|
36
38
|
end
|
37
39
|
|
38
40
|
def get_access_token_url
|
39
|
-
uri = URI.parse(
|
41
|
+
uri = URI.parse(@oauth_urls[:token_url])
|
40
42
|
params = URI.decode_www_form(uri.query.to_s)
|
41
43
|
params << ['oauth_verifier', oauth_verifier] if oauth_verifier
|
42
44
|
params << ['oauth_token', oauth_token] if oauth_token
|
@@ -69,4 +71,4 @@ module RedboothRuby
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
72
|
-
end
|
74
|
+
end
|
data/redbooth-ruby.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'redbooth-ruby/version'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'redbooth-ruby'
|
8
8
|
s.version = RedboothRuby::VERSION
|
9
|
-
s.authors = ['Andres Bravo', 'Carlos Saura', 'Bruno Pedro']
|
9
|
+
s.authors = ['Andres Bravo', 'Carlos Saura', 'Bruno Pedro', 'Oscar Ferrer']
|
10
10
|
s.email = ['support@redbooth.com']
|
11
11
|
s.homepage = 'https://github.com/teambox/redbooth-ruby'
|
12
12
|
s.summary = %q{API wrapper for Redbooth.}
|
@@ -7,21 +7,36 @@ describe RedboothRuby::Session, vcr: 'session' do
|
|
7
7
|
let(:auto_refresh_token) { true }
|
8
8
|
let(:consumer_key) { '_your_consumer_key_' }
|
9
9
|
let(:consumer_secret) { '_your_consumer_secret_' }
|
10
|
+
let(:oauth2_base) { nil }
|
10
11
|
let(:session) do
|
11
12
|
RedboothRuby::Session.new(token: token, refresh_token: refresh_token,
|
12
13
|
expires_in: expires_in, auto_refresh_token: auto_refresh_token,
|
13
|
-
consumer_key: consumer_key, consumer_secret: consumer_secret)
|
14
|
+
consumer_key: consumer_key, consumer_secret: consumer_secret, oauth2_base: oauth2_base)
|
14
15
|
end
|
15
16
|
|
16
17
|
describe '#initialize' do
|
17
18
|
subject { session }
|
18
|
-
|
19
19
|
it { expect(session.token).to eql token }
|
20
20
|
it { expect(session.refresh_token).to eql refresh_token }
|
21
21
|
it { expect(session.expires_in).to eql expires_in }
|
22
22
|
it { expect(session.auto_refresh_token).to eql auto_refresh_token }
|
23
23
|
it { expect(session.consumer_key).to eql consumer_key }
|
24
24
|
it { expect(session.consumer_secret).to eql consumer_secret }
|
25
|
+
|
26
|
+
context 'with default values' do
|
27
|
+
let(:oauth2_base) { nil }
|
28
|
+
it { expect(session.oauth_urls[:site]).to eql "https://redbooth.com/api/3" }
|
29
|
+
it { expect(session.oauth_urls[:authorize_url]).to eql "https://redbooth.com/oauth2/authorize" }
|
30
|
+
it { expect(session.oauth_urls[:token_url]).to eql "https://redbooth.com/oauth2/token"}
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with configurable values' do
|
34
|
+
let(:oauth2_base) { 'foo.bar' }
|
35
|
+
it { expect(session.oauth_urls[:site]).to eql "https://#{oauth2_base}/api/3" }
|
36
|
+
it { expect(session.oauth_urls[:authorize_url]).to eql "https://#{oauth2_base}/oauth2/authorize" }
|
37
|
+
it { expect(session.oauth_urls[:token_url]).to eql "https://#{oauth2_base}/oauth2/token"}
|
38
|
+
end
|
39
|
+
|
25
40
|
end
|
26
41
|
|
27
42
|
describe '#valid?' do
|
@@ -43,25 +58,35 @@ describe RedboothRuby::Session, vcr: 'session' do
|
|
43
58
|
|
44
59
|
describe '#get_access_token_url' do
|
45
60
|
subject { session.get_access_token_url }
|
46
|
-
|
61
|
+
let(:oauth2_base) { 'foo.bar' }
|
47
62
|
|
48
|
-
context 'when
|
63
|
+
context 'when oauth2_base is default' do
|
64
|
+
let(:oauth2_base) { nil }
|
65
|
+
it { should eql 'https://redbooth.com/oauth2/token' }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when oauth2_base is custom' do
|
69
|
+
it { should eql "https://#{oauth2_base}/oauth2/token" }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when oauth_verifier is present and default oauth endpoint' do
|
49
73
|
before { session.oauth_verifier = '_your_user_oauth_verifier_token_' }
|
50
|
-
it { should eql
|
74
|
+
it { should eql "https://#{oauth2_base}/oauth2/token?oauth_verifier=_your_user_oauth_verifier_token_" }
|
51
75
|
end
|
52
76
|
|
53
|
-
context 'when oauth_token is present' do
|
77
|
+
context 'when oauth_token is present and default oauth endpoint' do
|
54
78
|
before { session.oauth_token = '_your_user_oauth_token_' }
|
55
|
-
it { should eql
|
79
|
+
it { should eql "https://#{oauth2_base}/oauth2/token?oauth_token=_your_user_oauth_token_" }
|
56
80
|
end
|
57
81
|
|
58
|
-
context 'when oauth_verifier and oauth_token are present' do
|
82
|
+
context 'when oauth_verifier and oauth_token are present and default oauth endpoint' do
|
59
83
|
before do
|
60
84
|
session.oauth_verifier = '_your_user_oauth_verifier_token_'
|
61
85
|
session.oauth_token = '_your_user_oauth_token_'
|
62
86
|
end
|
63
|
-
it { should eql
|
87
|
+
it { should eql "https://#{oauth2_base}/oauth2/token?oauth_verifier=_your_user_oauth_verifier_token_&oauth_token=_your_user_oauth_token_" }
|
64
88
|
end
|
89
|
+
|
65
90
|
end
|
66
91
|
|
67
92
|
describe '#access_token' do
|
@@ -102,4 +127,4 @@ describe RedboothRuby::Session, vcr: 'session' do
|
|
102
127
|
session.refresh_access_token!
|
103
128
|
end
|
104
129
|
end
|
105
|
-
end
|
130
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redbooth-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andres Bravo
|
8
8
|
- Carlos Saura
|
9
9
|
- Bruno Pedro
|
10
|
+
- Oscar Ferrer
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2015-07-
|
14
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: json
|
@@ -393,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
393
394
|
version: '0'
|
394
395
|
requirements: []
|
395
396
|
rubyforge_project:
|
396
|
-
rubygems_version: 2.
|
397
|
+
rubygems_version: 2.2.2
|
397
398
|
signing_key:
|
398
399
|
specification_version: 4
|
399
400
|
summary: API wrapper for Redbooth.
|
@@ -596,4 +597,3 @@ test_files:
|
|
596
597
|
- spec/redbooth_spec.rb
|
597
598
|
- spec/shared/authentication_context.rb
|
598
599
|
- spec/spec_helper.rb
|
599
|
-
has_rdoc:
|