omniauth-producthunt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +16 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +63 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +10 -0
- data/lib/omniauth-producthunt.rb +2 -0
- data/lib/omniauth-producthunt/version.rb +5 -0
- data/lib/omniauth/strategies/product_hunt.rb +55 -0
- data/omniauth-producthunt.gemspec +26 -0
- data/test/me.json +45 -0
- data/test/omniauth/strategies/authorize_params_test.rb +28 -0
- data/test/omniauth/strategies/client_options_test.rb +37 -0
- data/test/omniauth/strategies/data_test.rb +36 -0
- data/test/test_helper.rb +8 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd0a28c9d7a57e784287acc16f6b9f3591d811b9cf7ce9bfb1d19630dfef4e4a
|
4
|
+
data.tar.gz: 69574cb978594d9dc4d5807c84a3bd6f19a1d4500ab3af97e16d9b3444aa4900
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c570438b50fd98d0e6b6d584ea87593315a503b3b558454fd252ca6291d9b7ef77060af3d37ebcfe7bb276d3873dc2d8227b1b7d56484c114a1cfdca90e07d2
|
7
|
+
data.tar.gz: 59a3f8be0b14dd5520c3d34f49f20d79ef995bcd4f0dbc9c69abce3a7aa8d527b9b13ca5f91e969185becfe0464afcc00af62307bf2ba35f19e8a596e935d92e
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/*.gemspec'
|
4
|
+
- '**/*.podspec'
|
5
|
+
- '**/*.jbuilder'
|
6
|
+
- '**/*.rake'
|
7
|
+
- '**/*.opal'
|
8
|
+
- '**/config.ru'
|
9
|
+
- '**/Gemfile'
|
10
|
+
- '**/Rakefile'
|
11
|
+
- '**/Capfile'
|
12
|
+
- '**/Guardfile'
|
13
|
+
- '**/Podfile'
|
14
|
+
- '**/Thorfile'
|
15
|
+
- '**/Vagrantfile'
|
16
|
+
- '**/Berksfile'
|
17
|
+
- '**/Cheffile'
|
18
|
+
- '**/Vagabondfile'
|
19
|
+
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Style/StringLiterals:
|
24
|
+
EnforcedStyle: double_quotes
|
25
|
+
|
26
|
+
Layout/SpaceInsideBlockBraces:
|
27
|
+
EnforcedStyle: space
|
28
|
+
EnforcedStyleForEmptyBraces: space
|
29
|
+
SpaceBeforeBlockParameters: false
|
30
|
+
|
31
|
+
Layout/SpaceInsideHashLiteralBraces:
|
32
|
+
EnforcedStyle: no_space
|
33
|
+
EnforcedStyleForEmptyBraces: no_space
|
34
|
+
|
35
|
+
Layout/FirstArrayElementLineBreak:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Layout/FirstHashElementLineBreak:
|
39
|
+
Enabled: true
|
40
|
+
|
41
|
+
Style/SymbolArray:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Style/PercentLiteralDelimiters:
|
45
|
+
PreferredDelimiters:
|
46
|
+
'%': []
|
47
|
+
'%i': []
|
48
|
+
'%q': []
|
49
|
+
'%Q': []
|
50
|
+
'%r': '{}'
|
51
|
+
'%s': []
|
52
|
+
'%w': []
|
53
|
+
'%W': []
|
54
|
+
'%x': []
|
55
|
+
|
56
|
+
Metrics/LineLength:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/EmptyMethod:
|
60
|
+
EnforcedStyle: expanded
|
61
|
+
|
62
|
+
Naming/FileName:
|
63
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
4
|
+
notifications:
|
5
|
+
email: false
|
6
|
+
rvm:
|
7
|
+
- 2.5.3
|
8
|
+
before_script:
|
9
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
|
+
- chmod +x ./cc-test-reporter
|
11
|
+
- "./cc-test-reporter before-build"
|
12
|
+
after_script:
|
13
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
14
|
+
env:
|
15
|
+
global:
|
16
|
+
secure: uuHC3W2OCFGR+3dKChzYpnz2qGiZeA3shk2845Wonh4IJ9WsFnormHNSaByvQRMgR/13fO11BtwCF0z7w9nrJu+oXsLUs4wyQAy/hJSynexR6wpk7uWyvMjLcInZALUo9KQg4Mo3NOfZufXKYAo+gwDqzGPDngqtkhBRdnuxvNHZagATEtal0lGrQ6zXCNKKUbKBy+o9V5TCWoqAJdBo6m3YUCRInjziXCGCLg2c+08uYQAXt4xxD+7JwpmJKeShJZgcBjiIsyuIAX7NWKNQQ4SCVK7/Cg+og3LMNDrgsaSXjtMmZAx0v19R+rQG1BtILBoD46W+GGbabFmaDmGRk8BRQj/UzN5WXvQXIgn2nUpEQ9DBrLxni6i/lnD7K/bzlvrShladrHXcT8uF1EOR9w75K08/DaOY4PqKbW/MXWWFj2/ddvErYKWEIilAsDS312QkJ4xqbXQVXDqinta6pDKP2b2WXfBdBnN1i8ACmZVMN8KxDDHy3CwhUUZyMSmyvYqJhmAfopqsD8X9tolw24rMYVsthPdKu4Hp5kh1QTXt+leNztijYcH82iUH1J0UuJ558WXCKmU2dvmvunHD/uADgzAH79XuviQnJeprWNKQB8Q/e3Anb9HU/VC4bLbUIXvwvpuw4W72vvsAPgbl29hFY/2lNTY3/A35px/A9Kc=
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 Nando Vieira
|
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,51 @@
|
|
1
|
+
# Omniauth::ProductHunt
|
2
|
+
|
3
|
+
[![Travis-CI](https://travis-ci.org/fnando/omniauth-producthunt.svg)](https://travis-ci.org/fnando/omniauth-producthunt)
|
4
|
+
[![CodeClimate](https://codeclimate.com/github/fnando/omniauth-producthunt.svg)](https://codeclimate.com/github/fnando/omniauth-producthunt)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/fnando/omniauth-producthunt/badges/coverage.svg)](https://codeclimate.com/github/fnando/omniauth-producthunt/coverage)
|
6
|
+
[![Gem](https://img.shields.io/gem/v/omniauth-producthunt.svg)](https://rubygems.org/gems/omniauth-producthunt)
|
7
|
+
[![Gem](https://img.shields.io/gem/dt/omniauth-producthunt.svg)](https://rubygems.org/gems/omniauth-producthunt)
|
8
|
+
|
9
|
+
[ProductHunt](http://producthunt.com)'s OAuth Strategy for OmniAuth.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'omniauth-producthunt'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install omniauth-producthunt
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
`OmniAuth::Strategies::ProductHunt` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: <https://github.com/intridea/omniauth>.
|
28
|
+
|
29
|
+
First, create a new application at <https://api.producthunt.com/v1/oauth/applications>. Your callback URL must be something like `https://example.com/auth/producthunt/callback`. ProductHunt requires https even for development, so make sure you set up something that can support it.
|
30
|
+
|
31
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`. This example assumes you're exporting your credentials as environment variables.
|
32
|
+
|
33
|
+
Notice that omniauth-producthunt will always inject `public` and `private` scopes, so it can retrieve the required information.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
|
+
provider :producthunt,
|
38
|
+
ENV["PRODUCTHUNT_CLIENT_ID"],
|
39
|
+
ENV["PRODUCTHUNT_CLIENT_SECRET"]
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Now visit `/auth/producthunt` to start authentication against ProductHunt.
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork [omniauth-producthunt](https://github.com/fnando/omniauth-producthunt/fork)
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "omniauth"
|
2
|
+
require "omniauth-oauth2"
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class ProductHunt < OmniAuth::Strategies::OAuth2
|
7
|
+
DEFAULT_SCOPES = %w[public private].freeze
|
8
|
+
|
9
|
+
option :name, "producthunt"
|
10
|
+
|
11
|
+
option :client_options,
|
12
|
+
site: "https://api.producthunt.com",
|
13
|
+
authorize_url: "/v1/oauth/authorize",
|
14
|
+
token_url: "/v1/oauth/token"
|
15
|
+
|
16
|
+
def callback_url
|
17
|
+
options[:redirect_uri] || full_host + script_name + callback_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize_params
|
21
|
+
super.tap do |params|
|
22
|
+
scope = params[:scope].to_s.split(/\s+/)
|
23
|
+
scope = scope.concat(DEFAULT_SCOPES.reject {|s| scope.include?(s) })
|
24
|
+
params[:scope] = scope.join(" ")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
uid do
|
29
|
+
raw_info[:user][:id]
|
30
|
+
end
|
31
|
+
|
32
|
+
info do
|
33
|
+
identity = raw_info[:user]
|
34
|
+
|
35
|
+
{
|
36
|
+
name: identity[:name],
|
37
|
+
nickname: identity[:username],
|
38
|
+
email: identity[:email],
|
39
|
+
description: identity[:headline],
|
40
|
+
image: identity[:image_url][:"100px"],
|
41
|
+
urls: {
|
42
|
+
site: identity[:website_url],
|
43
|
+
profile: identity[:profile_url]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def raw_info
|
49
|
+
@raw_info ||= deep_symbolize(access_token.get("/v1/me").parsed)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Producthunt = ProductHunt
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "./lib/omniauth-producthunt/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "omniauth-producthunt"
|
5
|
+
spec.version = Omniauth::ProductHunt::VERSION
|
6
|
+
spec.authors = ["Nando Vieira"]
|
7
|
+
spec.email = ["fnando.vieira@gmail.com"]
|
8
|
+
spec.summary = "OmniAuth strategy for ProductHunt (https://producthunt.com)."
|
9
|
+
spec.description = spec.summary
|
10
|
+
spec.homepage = "https://github.com/fnando/omniauth-producthunt"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_runtime_dependency "omniauth-oauth2"
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "minitest-utils"
|
21
|
+
spec.add_development_dependency "mocha"
|
22
|
+
spec.add_development_dependency "pry-meta"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "simplecov"
|
25
|
+
spec.add_development_dependency "webmock"
|
26
|
+
end
|
data/test/me.json
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"user": {
|
3
|
+
"id": 40304,
|
4
|
+
"created_at": "2014-08-07T17:08:13.305-07:00",
|
5
|
+
"name": "Nando Vieira",
|
6
|
+
"email": "email@example.com",
|
7
|
+
"username": "fnando",
|
8
|
+
"headline": "Web Developer",
|
9
|
+
"twitter_username": "fnando",
|
10
|
+
"website_url": "http://nandovieira.com",
|
11
|
+
"profile_url": "https://www.producthunt.com/@fnando",
|
12
|
+
"image_url": {
|
13
|
+
"30px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=30&h=30",
|
14
|
+
"32px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=32&h=32",
|
15
|
+
"40px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=40&h=40",
|
16
|
+
"44px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=44&h=44",
|
17
|
+
"48px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=48&h=48",
|
18
|
+
"50px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=50&h=50",
|
19
|
+
"60px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=60&h=60",
|
20
|
+
"64px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=64&h=64",
|
21
|
+
"73px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=73&h=73",
|
22
|
+
"80px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=80&h=80",
|
23
|
+
"88px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=88&h=88",
|
24
|
+
"96px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=96&h=96",
|
25
|
+
"100px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=100&h=100",
|
26
|
+
"110px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=110&h=110",
|
27
|
+
"120px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=120&h=120",
|
28
|
+
"132px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=132&h=132",
|
29
|
+
"146px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=146&h=146",
|
30
|
+
"160px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=160&h=160",
|
31
|
+
"176px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=176&h=176",
|
32
|
+
"220px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=220&h=220",
|
33
|
+
"264px": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=264&h=264",
|
34
|
+
"32px@2X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=64&h=64",
|
35
|
+
"40px@2X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=80&h=80",
|
36
|
+
"44px@2X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=88&h=88",
|
37
|
+
"88px@2X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=176&h=176",
|
38
|
+
"32px@3X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=96&h=96",
|
39
|
+
"40px@3X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=120&h=120",
|
40
|
+
"44px@3X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=132&h=132",
|
41
|
+
"88px@3X": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=264&h=264",
|
42
|
+
"original": "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=original&h=original"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class AuthorizeParamsTest < Minitest::Test
|
4
|
+
let(:app) { ->(env) { } }
|
5
|
+
|
6
|
+
let(:strategy) do
|
7
|
+
OmniAuth::Strategies::ProductHunt.new(app, "consumer_id", "consumer_secret")
|
8
|
+
end
|
9
|
+
|
10
|
+
test "sets defaults scopes" do
|
11
|
+
strategy.stubs(:session).returns({})
|
12
|
+
assert_equal "public private", strategy.authorize_params.scope
|
13
|
+
end
|
14
|
+
|
15
|
+
test "injects required scopes" do
|
16
|
+
strategy = OmniAuth::Strategies::ProductHunt.new(nil, "ID", "SECRET", scope: "team")
|
17
|
+
strategy.stubs(:session).returns({})
|
18
|
+
|
19
|
+
assert_equal "team public private", strategy.authorize_params.scope
|
20
|
+
end
|
21
|
+
|
22
|
+
test "sets unique scopes" do
|
23
|
+
strategy = OmniAuth::Strategies::ProductHunt.new(nil, "ID", "SECRET", scope: "private")
|
24
|
+
strategy.stubs(:session).returns({})
|
25
|
+
|
26
|
+
assert_equal "private public", strategy.authorize_params.scope
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ClientOptionsTest < Minitest::Test
|
4
|
+
let(:app) { -> env { [200, {}, []] } }
|
5
|
+
|
6
|
+
let(:strategy) do
|
7
|
+
OmniAuth::Strategies::ProductHunt.new(app, "consumer_id", "consumer_secret")
|
8
|
+
end
|
9
|
+
|
10
|
+
test "sets name" do
|
11
|
+
assert_equal "producthunt", strategy.options.name
|
12
|
+
end
|
13
|
+
|
14
|
+
test "sets site" do
|
15
|
+
assert_equal "https://api.producthunt.com", strategy.options.client_options.site
|
16
|
+
end
|
17
|
+
|
18
|
+
test "sets authorize url" do
|
19
|
+
assert_equal "/v1/oauth/authorize", strategy.options.client_options.authorize_url
|
20
|
+
end
|
21
|
+
|
22
|
+
test "sets token url" do
|
23
|
+
assert_equal "/v1/oauth/token", strategy.options.client_options.token_url
|
24
|
+
end
|
25
|
+
|
26
|
+
test "sets callback" do
|
27
|
+
strategy.expects(:full_host).returns("https://example.com")
|
28
|
+
strategy.expects(:script_name).returns("")
|
29
|
+
|
30
|
+
assert_equal "https://example.com/auth/producthunt/callback", strategy.callback_url
|
31
|
+
end
|
32
|
+
|
33
|
+
test "sets callback url via options" do
|
34
|
+
strategy = OmniAuth::Strategies::ProductHunt.new(app, "consumer_id", "consumer_secret", redirect_uri: "REDIRECT_URI")
|
35
|
+
assert_equal "REDIRECT_URI", strategy.callback_url
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class DataTest < Minitest::Test
|
4
|
+
let(:app) { ->(env) { } }
|
5
|
+
|
6
|
+
let(:strategy) do
|
7
|
+
OmniAuth::Strategies::ProductHunt.new(app, "consumer_id", "consumer_secret")
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:payload) do
|
11
|
+
JSON.parse(File.read("./test/me.json"))
|
12
|
+
end
|
13
|
+
|
14
|
+
setup do
|
15
|
+
access_token = mock("access_token")
|
16
|
+
response = mock("response", parsed: payload)
|
17
|
+
access_token.expects(:get).with("/v1/me").returns(response)
|
18
|
+
strategy.stubs(:access_token).returns(access_token)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "returns info" do
|
22
|
+
info = strategy.info
|
23
|
+
|
24
|
+
assert_equal "Nando Vieira", info[:name]
|
25
|
+
assert_equal "fnando", info[:nickname]
|
26
|
+
assert_equal "email@example.com", info[:email]
|
27
|
+
assert_equal "Web Developer", info[:description]
|
28
|
+
assert_equal "http://nandovieira.com", info.dig(:urls, :site)
|
29
|
+
assert_equal "https://www.producthunt.com/@fnando", info.dig(:urls, :profile)
|
30
|
+
assert_equal "https://ph-avatars.imgix.net/40304/original?auto=format&fit=crop&crop=faces&w=100&h=100", info[:image]
|
31
|
+
end
|
32
|
+
|
33
|
+
test "returns uid" do
|
34
|
+
assert_equal 40_304, strategy.uid
|
35
|
+
end
|
36
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-producthunt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nando Vieira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-26 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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: minitest-utils
|
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: mocha
|
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: pry-meta
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: OmniAuth strategy for ProductHunt (https://producthunt.com).
|
126
|
+
email:
|
127
|
+
- fnando.vieira@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".codeclimate.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/omniauth-producthunt.rb
|
141
|
+
- lib/omniauth-producthunt/version.rb
|
142
|
+
- lib/omniauth/strategies/product_hunt.rb
|
143
|
+
- omniauth-producthunt.gemspec
|
144
|
+
- test/me.json
|
145
|
+
- test/omniauth/strategies/authorize_params_test.rb
|
146
|
+
- test/omniauth/strategies/client_options_test.rb
|
147
|
+
- test/omniauth/strategies/data_test.rb
|
148
|
+
- test/test_helper.rb
|
149
|
+
homepage: https://github.com/fnando/omniauth-producthunt
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.7.6
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: OmniAuth strategy for ProductHunt (https://producthunt.com).
|
173
|
+
test_files:
|
174
|
+
- test/me.json
|
175
|
+
- test/omniauth/strategies/authorize_params_test.rb
|
176
|
+
- test/omniauth/strategies/client_options_test.rb
|
177
|
+
- test/omniauth/strategies/data_test.rb
|
178
|
+
- test/test_helper.rb
|