omniauth-hubspot-full 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +8 -0
- data/lib/omniauth-hubspot-full.rb +2 -0
- data/lib/omniauth-hubspot/version.rb +5 -0
- data/lib/omniauth/strategies/hubspot.rb +96 -0
- data/omniauth-hubspot-full.gemspec +25 -0
- data/test/helper.rb +57 -0
- data/test/support/shared_examples.rb +85 -0
- data/test/test.rb +118 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bba68321e58b233f0d7c03dee5fddd9e0ed3282
|
4
|
+
data.tar.gz: acc52268337f08654f3c9daa145914638b9e8c18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8964b02fd174693824cbe67b4857c3c4e3c47bb98b455486004242b1ef981764db46ad83daaa864b023686d890dac883f9d78aafabd84858b59467b193e94048
|
7
|
+
data.tar.gz: 00bc3a728afb06e17ad1b2dc205a313caea2c9a05f74f533ced3a92fbddc3255a784ddaf66f9c06fd8d4b3bba554c2e13a9fd42353b63e5dde2ff4be83e1689f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 romanos
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Omniauth::Hubspot
|
2
|
+
|
3
|
+
This Gem contains the Hubspot strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Before You Begin
|
6
|
+
|
7
|
+
You should have already installed OmniAuth into your app; if not, read the [OmniAuth README](https://github.com/omniauth/omniauth) to get started.
|
8
|
+
|
9
|
+
Now sign into the [Hubspot Developer Dashboard](https://developers.hubspot.com/) and create an application. Take note of your API keys.
|
10
|
+
|
11
|
+
|
12
|
+
## Using This Strategy
|
13
|
+
|
14
|
+
First start by adding this gem to your Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'omniauth-hubspot-full'
|
18
|
+
```
|
19
|
+
|
20
|
+
If you need to use the latest HEAD version, you can do so with:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'omniauth-hubspot-full', github: 'romanos/omniauth-hubspot'
|
24
|
+
```
|
25
|
+
|
26
|
+
Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
30
|
+
provider :hubspot, 'API_KEY', 'API_SECRET', scope: 'contacts timeline'
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Replace `'API_KEY'` and `'API_SECRET'` with the appropriate values you obtained earlier.
|
35
|
+
|
36
|
+
If you are using [Devise](https://github.com/plataformatec/devise) then it will look like this:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Devise.setup do |config|
|
40
|
+
# other stuff...
|
41
|
+
|
42
|
+
config.omniauth :hubspot, ENV['HUBSPOT_APP_ID'], ENV['HUBSPOT_APP_SECRET'], scope: 'contacts timeline'
|
43
|
+
|
44
|
+
# other stuff...
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
|
49
|
+
## Scopes
|
50
|
+
Hubspot lets you choose from a [few different scopes](https://developers.hubspot.com/docs/methods/oauth2/initiate-oauth-integration#scopes).
|
51
|
+
|
52
|
+
## Hubspot Information
|
53
|
+
|
54
|
+
Querying the access token endpoint as defined [here](https://developers.hubspot.com/docs/methods/oauth2/get-access-token-information) returns a basic hash of user info and allowed scopes.
|
55
|
+
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"token": "CJSP5qf1KhICAQEYs-gDIIGOBii1hQIyGQAf3xBKmlwHjX7OIpuIFEavB2-qYAGQsF4",
|
59
|
+
"user": "test@hubspot.com",
|
60
|
+
"hub_domain": "demo.hubapi.com",
|
61
|
+
"scopes": [
|
62
|
+
"contacts",
|
63
|
+
"automation",
|
64
|
+
"oauth"
|
65
|
+
],
|
66
|
+
"hub_id": 62515,
|
67
|
+
"app_id": 456,
|
68
|
+
"expires_in": 21588,
|
69
|
+
"user_id": 123,
|
70
|
+
"token_type": "access"
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
1. Fork it
|
77
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
78
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
79
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
80
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
require 'uri'
|
3
|
+
require 'rack/utils'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Hubspot < OmniAuth::Strategies::OAuth2
|
8
|
+
option :name, 'hubspot'
|
9
|
+
|
10
|
+
option :authorize_options, [:scope]
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
site: 'https://api.hubapi.com',
|
14
|
+
authorize_url: 'https://app.hubspot.com/oauth/authorize',
|
15
|
+
token_url: '/oauth/v1/token'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :auth_token_params, {
|
19
|
+
mode: :query,
|
20
|
+
param_name: 'token'
|
21
|
+
}
|
22
|
+
|
23
|
+
# User ID is not guaranteed to be globally unique across all Hubspot users.
|
24
|
+
# The combination of user ID and Hub ID, on the other hand, is guaranteed
|
25
|
+
# to be globally unique.
|
26
|
+
uid { "#{identity['user_id']}-#{identity['hub_id']}" }
|
27
|
+
|
28
|
+
# Make sure to record refresh token
|
29
|
+
credentials do
|
30
|
+
{
|
31
|
+
token: access_token.token,
|
32
|
+
refresh_token: access_token.refresh_token,
|
33
|
+
expires_at: access_token.expires_at,
|
34
|
+
expires_in: access_token.expires_in,
|
35
|
+
expires: access_token.expires?
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# {
|
40
|
+
# "token": "CJSP5qf1KhICAQEYs-gDIIGOBii1hQIyGQAf3xBKmlwHjX7OIpuIFEavB2-qYAGQsF4",
|
41
|
+
# "user": "test@hubspot.com",
|
42
|
+
# "hub_domain": "demo.hubapi.com",
|
43
|
+
# "scopes": [
|
44
|
+
# "contacts",
|
45
|
+
# "automation",
|
46
|
+
# "oauth"
|
47
|
+
# ],
|
48
|
+
# "hub_id": 62515,
|
49
|
+
# "app_id": 456,
|
50
|
+
# "expires_in": 21588,
|
51
|
+
# "user_id": 123,
|
52
|
+
# "token_type": "access"
|
53
|
+
# }
|
54
|
+
|
55
|
+
info do
|
56
|
+
{
|
57
|
+
user_id: identity['user_id'],
|
58
|
+
user: identity['user'],
|
59
|
+
hub_id: identity['hub_id'],
|
60
|
+
hub_domain: identity['image_48'],
|
61
|
+
app_id: identity['app_id'],
|
62
|
+
scopes: identity['scopes']
|
63
|
+
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
extra do
|
68
|
+
{
|
69
|
+
raw_info: {
|
70
|
+
identity: identity
|
71
|
+
}
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def authorize_params
|
76
|
+
super.tap do |params|
|
77
|
+
%w[scope].each do |v|
|
78
|
+
if request.params[v]
|
79
|
+
params[v.to_sym] = request.params[v]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def identity
|
86
|
+
@identity ||= access_token.get("/oauth/v1/access-tokens/#{access_token.token}").parsed
|
87
|
+
end
|
88
|
+
|
89
|
+
#private
|
90
|
+
|
91
|
+
def callback_url
|
92
|
+
full_host + script_name + callback_path
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path('../lib/omniauth-hubspot/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "omniauth-hubspot-full"
|
6
|
+
spec.version = Omniauth::Hubspot::VERSION
|
7
|
+
spec.authors = ["romanos"]
|
8
|
+
spec.email = ["romanos@jargon.ai"]
|
9
|
+
spec.description = %q{OmniAuth strategy for Hubspot (borrowed heavily from @kmrshntr)}
|
10
|
+
spec.summary = %q{OmniAuth strategy for Hubspot (borrowed heavily from @kmrshntr)}
|
11
|
+
spec.homepage = "https://github.com/romanos/omniauth-hubspot.git"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency 'omniauth-oauth2', "~> 1.5"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
spec.add_development_dependency "mocha"
|
25
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "mocha/setup"
|
4
|
+
require "omniauth/strategies/hubspot"
|
5
|
+
|
6
|
+
OmniAuth.config.test_mode = true
|
7
|
+
|
8
|
+
module BlockTestHelper
|
9
|
+
def test(name, &blk)
|
10
|
+
method_name = "test_#{name.gsub(/\s+/, "_")}"
|
11
|
+
raise "Method already defined: #{method_name}" if instance_methods.include?(method_name.to_sym)
|
12
|
+
define_method method_name, &blk
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module CustomAssertions
|
17
|
+
def assert_has_key(key, hash, msg = nil)
|
18
|
+
msg = message(msg) { "Expected #{hash.inspect} to have key #{key.inspect}" }
|
19
|
+
assert hash.has_key?(key), msg
|
20
|
+
end
|
21
|
+
|
22
|
+
def refute_has_key(key, hash, msg = nil)
|
23
|
+
msg = message(msg) { "Expected #{hash.inspect} not to have key #{key.inspect}" }
|
24
|
+
refute hash.has_key?(key), msg
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class TestCase < Minitest::Test
|
29
|
+
extend BlockTestHelper
|
30
|
+
include CustomAssertions
|
31
|
+
end
|
32
|
+
|
33
|
+
class StrategyTestCase < TestCase
|
34
|
+
def setup
|
35
|
+
@request = stub("Request")
|
36
|
+
@request.stubs(:params).returns({})
|
37
|
+
@request.stubs(:cookies).returns({})
|
38
|
+
@request.stubs(:env).returns({})
|
39
|
+
@request.stubs(:scheme).returns({})
|
40
|
+
@request.stubs(:ssl?).returns(false)
|
41
|
+
|
42
|
+
@client_id = "123"
|
43
|
+
@client_secret = "53cr3tz"
|
44
|
+
@options = {}
|
45
|
+
end
|
46
|
+
|
47
|
+
def strategy
|
48
|
+
@strategy ||= begin
|
49
|
+
args = [@client_id, @client_secret, @options].compact
|
50
|
+
OmniAuth::Strategies::Hubspot.new(nil, *args).tap do |strategy|
|
51
|
+
strategy.stubs(:request).returns(@request)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Dir[File.expand_path("../support/**/*", __FILE__)].each(&method(:require))
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
+
module OAuth2StrategyTests
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include ClientTests
|
6
|
+
include AuthorizeParamsTests
|
7
|
+
include CSRFAuthorizeParamsTests
|
8
|
+
include TokenParamsTests
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClientTests
|
13
|
+
extend BlockTestHelper
|
14
|
+
|
15
|
+
test "should be initialized with symbolized client_options" do
|
16
|
+
@options = { :client_options => { "authorize_url" => "https://example.com" } }
|
17
|
+
assert_equal "https://example.com", strategy.client.options[:authorize_url]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module AuthorizeParamsTests
|
22
|
+
extend BlockTestHelper
|
23
|
+
|
24
|
+
test "should include any authorize params passed in the :authorize_params option" do
|
25
|
+
@options = { :authorize_params => { :foo => "bar", :baz => "zip" } }
|
26
|
+
assert_equal "bar", strategy.authorize_params["foo"]
|
27
|
+
assert_equal "zip", strategy.authorize_params["baz"]
|
28
|
+
end
|
29
|
+
|
30
|
+
test "should include top-level options that are marked as :authorize_options" do
|
31
|
+
@options = { :authorize_options => [:scope, :foo], :scope => "bar", :foo => "baz" }
|
32
|
+
assert_equal "bar", strategy.authorize_params["scope"]
|
33
|
+
assert_equal "baz", strategy.authorize_params["foo"]
|
34
|
+
end
|
35
|
+
|
36
|
+
test "should exclude top-level options that are not passed" do
|
37
|
+
@options = { :authorize_options => [:bar] }
|
38
|
+
refute_has_key :bar, strategy.authorize_params
|
39
|
+
refute_has_key "bar", strategy.authorize_params
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module CSRFAuthorizeParamsTests
|
44
|
+
extend BlockTestHelper
|
45
|
+
|
46
|
+
test "should store random state in the session when none is present in authorize or request params" do
|
47
|
+
assert_includes strategy.authorize_params.keys, "state"
|
48
|
+
refute_empty strategy.authorize_params["state"]
|
49
|
+
refute_empty strategy.session["omniauth.state"]
|
50
|
+
assert_equal strategy.authorize_params["state"], strategy.session["omniauth.state"]
|
51
|
+
end
|
52
|
+
|
53
|
+
test "should not store state in the session when present in authorize params vs. a random one" do
|
54
|
+
@options = { :authorize_params => { :state => "bar" } }
|
55
|
+
refute_empty strategy.authorize_params["state"]
|
56
|
+
refute_equal "bar", strategy.authorize_params[:state]
|
57
|
+
refute_empty strategy.session["omniauth.state"]
|
58
|
+
refute_equal "bar", strategy.session["omniauth.state"]
|
59
|
+
end
|
60
|
+
|
61
|
+
test "should not store state in the session when present in request params vs. a random one" do
|
62
|
+
@request.stubs(:params).returns({ "state" => "foo" })
|
63
|
+
refute_empty strategy.authorize_params["state"]
|
64
|
+
refute_equal "foo", strategy.authorize_params[:state]
|
65
|
+
refute_empty strategy.session["omniauth.state"]
|
66
|
+
refute_equal "foo", strategy.session["omniauth.state"]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module TokenParamsTests
|
71
|
+
extend BlockTestHelper
|
72
|
+
|
73
|
+
test "should include any authorize params passed in the :token_params option" do
|
74
|
+
@options = { :token_params => { :foo => "bar", :baz => "zip" } }
|
75
|
+
assert_equal "bar", strategy.token_params["foo"]
|
76
|
+
assert_equal "zip", strategy.token_params["baz"]
|
77
|
+
end
|
78
|
+
|
79
|
+
test "should include top-level options that are marked as :token_options" do
|
80
|
+
@options = { :token_options => [:scope, :foo], :scope => "bar", :foo => "baz" }
|
81
|
+
assert_equal "bar", strategy.token_params["scope"]
|
82
|
+
assert_equal "baz", strategy.token_params["foo"]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/test/test.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "omniauth-hubspot-full"
|
3
|
+
|
4
|
+
class StrategyTest < StrategyTestCase
|
5
|
+
include OAuth2StrategyTests
|
6
|
+
end
|
7
|
+
|
8
|
+
class ClientTest < StrategyTestCase
|
9
|
+
test "has correct Hubspot API site" do
|
10
|
+
assert_equal "https://api.hubapi.com", strategy.client.site
|
11
|
+
end
|
12
|
+
|
13
|
+
test "has correct authorize url" do
|
14
|
+
assert_equal "https://app.hubspot.com/oauth/authorize", strategy.client.options[:authorize_url]
|
15
|
+
end
|
16
|
+
|
17
|
+
test "has correct token url" do
|
18
|
+
assert_equal "/oauth/v1/token", strategy.client.options[:token_url]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class CallbackUrlTest < StrategyTestCase
|
23
|
+
test "returns the default callback url" do
|
24
|
+
url_base = "http://auth.request.com"
|
25
|
+
@request.stubs(:url).returns("#{url_base}/some/page")
|
26
|
+
strategy.stubs(:script_name).returns("") # as not to depend on Rack env
|
27
|
+
assert_equal "#{url_base}/auth/hubspot/callback", strategy.callback_url
|
28
|
+
end
|
29
|
+
|
30
|
+
test "returns path from callback_path option" do
|
31
|
+
@options = { :callback_path => "/auth/hubspot/done"}
|
32
|
+
url_base = "http://auth.request.com"
|
33
|
+
@request.stubs(:url).returns("#{url_base}/page/path")
|
34
|
+
strategy.stubs(:script_name).returns("") # as not to depend on Rack env
|
35
|
+
assert_equal "#{url_base}/auth/hubspot/done", strategy.callback_url
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class UidTest < StrategyTestCase
|
40
|
+
def setup
|
41
|
+
super
|
42
|
+
strategy.stubs(:identity).returns({"user_id" => "U123", "hub_id" => "H456"})
|
43
|
+
end
|
44
|
+
|
45
|
+
test "returns the user ID from user_identity" do
|
46
|
+
assert_equal "U123-H456", strategy.uid
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class CredentialsTest < StrategyTestCase
|
51
|
+
def setup
|
52
|
+
super
|
53
|
+
@access_token = stub("OAuth2::AccessToken")
|
54
|
+
@access_token.stubs(:token)
|
55
|
+
@access_token.stubs(:expires?)
|
56
|
+
@access_token.stubs(:expires_at)
|
57
|
+
@access_token.stubs(:expires_in)
|
58
|
+
@access_token.stubs(:refresh_token)
|
59
|
+
strategy.stubs(:access_token).returns(@access_token)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "returns a Hash" do
|
63
|
+
assert_kind_of Hash, strategy.credentials
|
64
|
+
end
|
65
|
+
|
66
|
+
test "returns the token" do
|
67
|
+
@access_token.stubs(:token).returns("123")
|
68
|
+
assert_equal "123", strategy.credentials["token"]
|
69
|
+
end
|
70
|
+
|
71
|
+
test "returns the expiry status" do
|
72
|
+
@access_token.stubs(:expires?).returns(true)
|
73
|
+
assert strategy.credentials["expires"]
|
74
|
+
|
75
|
+
@access_token.stubs(:expires?).returns(false)
|
76
|
+
refute strategy.credentials["expires"]
|
77
|
+
end
|
78
|
+
|
79
|
+
test "returns the refresh token and expiry time when expiring" do
|
80
|
+
ten_mins_from_now = (Time.now + 600).to_i
|
81
|
+
@access_token.stubs(:expires?).returns(true)
|
82
|
+
@access_token.stubs(:refresh_token).returns("321")
|
83
|
+
@access_token.stubs(:expires_at).returns(ten_mins_from_now)
|
84
|
+
assert_equal "321", strategy.credentials["refresh_token"]
|
85
|
+
assert_equal ten_mins_from_now, strategy.credentials["expires_at"]
|
86
|
+
end
|
87
|
+
|
88
|
+
test "does not return the refresh token when test is nil and expiring" do
|
89
|
+
@access_token.stubs(:expires?).returns(true)
|
90
|
+
@access_token.stubs(:refresh_token).returns(nil)
|
91
|
+
assert_nil strategy.credentials["refresh_token"]
|
92
|
+
refute_has_key "refresh_token", strategy.credentials
|
93
|
+
end
|
94
|
+
|
95
|
+
test "does not return the refresh token when not expiring" do
|
96
|
+
@access_token.stubs(:expires?).returns(false)
|
97
|
+
@access_token.stubs(:refresh_token).returns("XXX")
|
98
|
+
assert_nil strategy.credentials["refresh_token"]
|
99
|
+
refute_has_key "refresh_token", strategy.credentials
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class UserInfoTest < StrategyTestCase
|
104
|
+
|
105
|
+
def setup
|
106
|
+
super
|
107
|
+
@access_token = stub("OAuth2::AccessToken")
|
108
|
+
@access_token.stubs(:token).returns("1234")
|
109
|
+
strategy.stubs(:access_token).returns(@access_token)
|
110
|
+
end
|
111
|
+
|
112
|
+
test "performs a GET to https://api.hubapi.com/oauth/v1/access-tokens/" do
|
113
|
+
@access_token.expects(:get).with("/oauth/v1/access-tokens/#{@access_token.token}")
|
114
|
+
.returns(stub_everything("OAuth2::Response"))
|
115
|
+
strategy.identity
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-hubspot-full
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- romanos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: OmniAuth strategy for Hubspot (borrowed heavily from @kmrshntr)
|
84
|
+
email:
|
85
|
+
- romanos@jargon.ai
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/omniauth-hubspot-full.rb
|
96
|
+
- lib/omniauth-hubspot/version.rb
|
97
|
+
- lib/omniauth/strategies/hubspot.rb
|
98
|
+
- omniauth-hubspot-full.gemspec
|
99
|
+
- test/helper.rb
|
100
|
+
- test/support/shared_examples.rb
|
101
|
+
- test/test.rb
|
102
|
+
homepage: https://github.com/romanos/omniauth-hubspot.git
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.6.13
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: OmniAuth strategy for Hubspot (borrowed heavily from @kmrshntr)
|
126
|
+
test_files:
|
127
|
+
- test/helper.rb
|
128
|
+
- test/support/shared_examples.rb
|
129
|
+
- test/test.rb
|