omniauth-pge 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af072cabe954b7f763d22b4e0cf57b882fde7bc0
4
- data.tar.gz: d4258fffcb6778356abe41051aaa9fa9cc843fa5
3
+ metadata.gz: 3623ee8455d80086ff6da05391bbe8ae0b00056c
4
+ data.tar.gz: 22775c292283a1d6ade48b968a818dd113d7e3cc
5
5
  SHA512:
6
- metadata.gz: d8a0326eb43c1bba371b0cd0d300cc140ac7a11f4fb38c4e8e798df558e5d1e2f6f2d1997291b93d84cbc4892466bab853c1685855554107d6e497b4b7a0eeb9
7
- data.tar.gz: 2ff1ce82fbc114fbb35d12cfd8401f847e9a125e02f5388021f6a5caf405f37c404879b8cee57ea6199564207af0ba159b183895990e1d8ef36a379db9bba8b5
6
+ metadata.gz: bab1d3d894e10db3be9faeefb414cbbb7915c2282d8cd954c7a8a06addb82640d2f24f994c8187597c87771230b87f3e288c6a7c385d1b3457acf63bc4285dae
7
+ data.tar.gz: 166d79903fa14943a60362dabd2ca650e268e7e23ba476b5e28ca62f6f83df78abb33ed05ca308d91423462102253ed8a1652a5a4e71c131dc6aa5bd89cf81db
@@ -1,3 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.2
4
+ - 2.1.1
5
+ - 2.0.0
6
+ - ruby-head
7
+ script: bundle exec rspec
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module PGE
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -0,0 +1,34 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class PGE < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ site: 'https://api.pge.com',
8
+ authorize_url: 'https://api.pge.com/datacustodian/test/oauth/v2/authorize',
9
+ token_url: 'https://api.pge.com/datacustodian/test/oauth/v2/token'
10
+ }
11
+
12
+ def request_phase
13
+ super
14
+ end
15
+
16
+ def authorize_params
17
+ super.tap do |params|
18
+ %w[scope client_options].each do |v|
19
+ if request.params[v]
20
+ params[v.to_sym] = request.params[v]
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ uid { raw_info['id'].to_s }
27
+
28
+ info do
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ OmniAuth.config.add_camelization 'pge', 'PGE'
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Sean Callan']
10
10
  spec.email = ['sean@seancallan.com']
11
11
 
12
- spec.summary = %q{OmniAuth strategy for PG&E.}
12
+ spec.summary = 'OmniAuth strategy for PG&E.'
13
13
  spec.homepage = 'https://github.com/doomspork/omniauth-pge'
14
14
  spec.license = 'MIT'
15
15
 
@@ -17,12 +17,14 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
-
21
- spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.3'
22
20
 
23
- spec.add_development_dependency 'bundler', '~> 1.9'
24
- spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_dependency 'omniauth-oauth2', '~> 1.3'
22
+
23
+ spec.add_development_dependency 'bundler', '> 1.7'
25
24
  spec.add_development_dependency 'coveralls', '~> 0.8'
25
+ spec.add_development_dependency 'rack-test', '~> 0.6.3'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
26
27
  spec.add_development_dependency 'rspec', '~> 3.2'
27
28
  spec.add_development_dependency 'simplecov', '~> 0.10'
29
+ spec.add_development_dependency 'webmock', '~> 1.21'
28
30
  end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ describe PGE do
6
+ let(:access_token) { stub('AccessToken', options: {}) }
7
+ let(:parsed_response) { stub('ParsedResponse') }
8
+ let(:response) { stub('Response', parsed: parsed_response) }
9
+
10
+ let(:production_site) { 'https://some.other.site.com/api/v3' }
11
+ let(:production_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' }
12
+ let(:production_token_url) { 'https://some.other.site.com/login/oauth/access_token' }
13
+ let(:production) do
14
+ OmniAuth::Strategies::PGE.new('PGE_KEY', 'PGE_SECRET', {
15
+ client_options: {
16
+ site: production_site,
17
+ authorize_url: production_authorize_url,
18
+ token_url: production_token_url
19
+ }
20
+ })
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::PGE.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ allow(subject).to receive(:access_token) { access_token }
29
+ end
30
+
31
+ context 'client options' do
32
+ it 'should have correct site' do
33
+ expect(subject.options.client_options.site).to eq 'https://api.pge.com'
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ expect(subject.options.client_options.authorize_url).to eq 'https://api.pge.com/datacustodian/test/oauth/v2/authorize'
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ expect(subject.options.client_options.token_url).to eq 'https://api.pge.com/datacustodian/test/oauth/v2/token'
42
+ end
43
+
44
+ describe 'should be overrideable' do
45
+ it 'for site' do
46
+ expect(production.options.client_options.site).to eq production_site
47
+ end
48
+
49
+ it 'for authorize url' do
50
+ expect(production.options.client_options.authorize_url).to eq production_authorize_url
51
+ end
52
+
53
+ it 'for token url' do
54
+ expect(production.options.client_options.token_url).to eq production_token_url
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -4,6 +4,8 @@ ENV['RACK_ENV'] = 'test'
4
4
 
5
5
  require 'coveralls'
6
6
  require 'simplecov'
7
+ require 'rack/test'
8
+ require 'webmock/rspec'
7
9
 
8
10
  SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
9
11
 
@@ -12,11 +14,15 @@ SimpleCov.start do
12
14
  coverage_dir 'docs/coverage'
13
15
  end
14
16
 
15
- require 'omniauth/pge'
17
+ require 'omniauth'
18
+ require 'omniauth-pge'
16
19
 
17
20
  Dir['spec/support/**/*.rb'].each { |f| require f }
18
21
 
19
22
  RSpec.configure do |config|
20
23
  config.pattern = '**/*_spec.rb'
21
24
  config.mock_framework = :rspec
25
+ config.include WebMock::API
26
+ config.include Rack::Test::Methods
27
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
22
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-pge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Callan
@@ -26,46 +26,60 @@ dependencies:
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.9'
47
+ version: '0.8'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.9'
54
+ version: '0.8'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: rack-test
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
61
+ version: 0.6.3
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '10.0'
68
+ version: 0.6.3
55
69
  - !ruby/object:Gem::Dependency
56
- name: coveralls
70
+ name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0.8'
75
+ version: '10.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0.8'
82
+ version: '10.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.21'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.21'
97
125
  description:
98
126
  email:
99
127
  - sean@seancallan.com
@@ -111,8 +139,9 @@ files:
111
139
  - Rakefile
112
140
  - lib/omniauth-pge.rb
113
141
  - lib/omniauth-pge/version.rb
142
+ - lib/omniauth/strategies/pge.rb
114
143
  - omniauth-pge.gemspec
115
- - spec/omniauth/pge_spec.rb
144
+ - spec/omniauth/strategies/pge_spec.rb
116
145
  - spec/spec_helper.rb
117
146
  homepage: https://github.com/doomspork/omniauth-pge
118
147
  licenses:
@@ -139,6 +168,6 @@ signing_key:
139
168
  specification_version: 4
140
169
  summary: OmniAuth strategy for PG&E.
141
170
  test_files:
142
- - spec/omniauth/pge_spec.rb
171
+ - spec/omniauth/strategies/pge_spec.rb
143
172
  - spec/spec_helper.rb
144
173
  has_rdoc:
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Omniauth::Pge do
4
- it 'has a version number' do
5
- expect(Omniauth::Pge::VERSION).not_to be nil
6
- end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
- end