omniauth-tecnologiedemocratiche 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 794ce73849540f45f21bcb5f0d4c56458e71b9a5
4
+ data.tar.gz: 49fb23e5cbe81f220b94fc11ab74dfc5fe758a80
5
+ SHA512:
6
+ metadata.gz: 7db8379525c62cce0cb31b7bffd6822aac7da309eb3db73eb398253dfcde5fbe4a0c85c30d39476173da026a3366b43134f11c9dbf1defd1cf572f262df40786
7
+ data.tar.gz: 643ea4703faeef39815b238d5cc7bd473178f84a9840387146a37e09da188f2faa5d3972d390d2495be3cf81c46982734819f6f5f00524a52f54b999f9a4a232
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
data/.rubocop.yml ADDED
@@ -0,0 +1,32 @@
1
+ AllCops:
2
+ RunRailsCops: true
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/NonNilCheck:
11
+ IncludeSemanticChanges: true
12
+
13
+ Style/SpaceInsideHashLiteralBraces:
14
+ EnforcedStyle: no_space
15
+
16
+ Style/DotPosition:
17
+ EnforcedStyle: trailing
18
+
19
+ AllCops:
20
+ Include:
21
+ - '**/Rakefile'
22
+ - '**/config.ru'
23
+ Exclude:
24
+ - 'uploads/**/*'
25
+ - 'bin/**/*'
26
+ - 'script/**/*'
27
+ - 'log/**/*'
28
+ - 'public/**/*'
29
+ - 'tmp/**/*'
30
+ - 'config/unicorn.rb'
31
+ - 'db/**/*'
32
+ #- 'spec/**/*'
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ group :test do
6
+ gem 'coveralls'
7
+ gem 'json', :platforms => [:jruby, :ruby_18, :ruby_19]
8
+ gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
9
+ gem 'rack-test'
10
+ gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
11
+ gem 'rspec', '~> 3.2'
12
+ gem 'rubocop', '>= 0.30', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
13
+ gem 'simplecov', '>= 0.9'
14
+ gem 'webmock'
15
+ end
16
+
17
+ # Specify your gem's dependencies in omniauth-oauth2.gemspec
18
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alessandro Rodi
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,31 @@
1
+ # Omniauth::Tecnologiedemocratiche
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-tecnologiedemocratiche'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-tecnologiedemocratiche
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/coorasse/omniauth-tecnologiedemocratiche/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task :test => :spec
8
+
9
+ begin
10
+ require 'rubocop/rake_task'
11
+ RuboCop::RakeTask.new
12
+ rescue LoadError
13
+ task :rubocop do
14
+ $stderr.puts 'RuboCop is disabled'
15
+ end
16
+ end
17
+
18
+ task :default => [:spec, :rubocop]
@@ -0,0 +1,2 @@
1
+ require 'omniauth-tecnologiedemocratiche/version' # rubocop:disable FileName
2
+ require 'omniauth/strategies/tecnologiedemocratiche'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Tecnologiedemocratiche
3
+ VERSION = '1.3.0'
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Tecnologiedemocratiche < OmniAuth::Strategies::OAuth2
6
+ option :name, 'Tecnologie Democratiche'
7
+
8
+ option :client_options, {
9
+ site: 'https://tecnologiedemocratiche.herokuapp.com',
10
+ authorize_path: '/oauth/authorize'
11
+ }
12
+
13
+ uid do
14
+ raw_info['id']
15
+ end
16
+
17
+ info do
18
+ {
19
+ email: raw_info['email']
20
+ }
21
+ end
22
+
23
+ def raw_info
24
+ @raw_info ||= access_token.get('/api/v1/me.json').parsed
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-tecnologiedemocratiche/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-tecnologiedemocratiche'
8
+ spec.version = OmniAuth::Tecnologiedemocratiche::VERSION
9
+ spec.authors = ['Alessandro Rodi']
10
+ spec.email = ['alessandro.rodi@renuo.ch']
11
+ spec.summary = %q{Omniauth Strategy to connect via Tecnologie Democratiche}
12
+ spec.description = %q{Omniauth Strategy to connect via Tecnologie Democratiche}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
26
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ if RUBY_VERSION >= '1.9'
5
+ require 'simplecov'
6
+ require 'coveralls'
7
+
8
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
9
+
10
+ SimpleCov.start do
11
+ minimum_coverage(78.48)
12
+ end
13
+ end
14
+
15
+ require 'rspec'
16
+ require 'rack/test'
17
+ require 'webmock/rspec'
18
+ require 'omniauth'
19
+ require 'omniauth-tecnologiedemocratiche'
20
+
21
+ RSpec.configure do |config|
22
+ config.expect_with :rspec do |c|
23
+ c.syntax = :expect
24
+ end
25
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
26
+ config.include Rack::Test::Methods
27
+ config.include WebMock::API
28
+ end
@@ -0,0 +1,99 @@
1
+ require 'helper'
2
+
3
+ describe OmniAuth::Strategies::Tecnologiedemocratiche do
4
+ def app
5
+ lambda do |_env|
6
+ [200, {}, ['Hello.']]
7
+ end
8
+ end
9
+
10
+ let(:fresh_strategy) { Class.new(OmniAuth::Strategies::Tecnologiedemocratiche) }
11
+
12
+ before do
13
+ OmniAuth.config.test_mode = true
14
+ end
15
+
16
+ after do
17
+ OmniAuth.config.test_mode = false
18
+ end
19
+
20
+ describe '#client' do
21
+ subject { fresh_strategy }
22
+
23
+ it 'is initialized with symbolized client_options' do
24
+ instance = subject.new(app, client_options: {'authorize_url' => 'https://example.com'})
25
+ expect(instance.client.options[:authorize_url]).to eq('https://example.com')
26
+ end
27
+
28
+ it 'sets ssl options as connection options' do
29
+ instance = subject.new(app, client_options: {'ssl' => {'ca_path' => 'foo'}})
30
+ expect(instance.client.options[:connection_opts][:ssl]).to eq(ca_path: 'foo')
31
+ end
32
+ end
33
+
34
+ describe '#authorize_params' do
35
+ subject { fresh_strategy }
36
+
37
+ it 'includes any authorize params passed in the :authorize_params option' do
38
+ instance = subject.new('abc', 'def', authorize_params: {foo: 'bar', baz: 'zip'})
39
+ expect(instance.authorize_params['foo']).to eq('bar')
40
+ expect(instance.authorize_params['baz']).to eq('zip')
41
+ end
42
+
43
+ it 'includes top-level options that are marked as :authorize_options' do
44
+ instance = subject.new('abc', 'def', authorize_options: [:scope, :foo, :state], scope: 'bar', foo: 'baz')
45
+ expect(instance.authorize_params['scope']).to eq('bar')
46
+ expect(instance.authorize_params['foo']).to eq('baz')
47
+ end
48
+
49
+ it 'includes random state in the authorize params' do
50
+ instance = subject.new('abc', 'def')
51
+ expect(instance.authorize_params.keys).to eq(['state'])
52
+ expect(instance.session['omniauth.state']).not_to be_empty
53
+ end
54
+ end
55
+
56
+ describe '#token_params' do
57
+ subject { fresh_strategy }
58
+
59
+ it 'includes any authorize params passed in the :authorize_params option' do
60
+ instance = subject.new('abc', 'def', token_params: {foo: 'bar', baz: 'zip'})
61
+ expect(instance.token_params).to eq('foo' => 'bar', 'baz' => 'zip')
62
+ end
63
+
64
+ it 'includes top-level options that are marked as :authorize_options' do
65
+ instance = subject.new('abc', 'def', token_options: [:scope, :foo], scope: 'bar', foo: 'baz')
66
+ expect(instance.token_params).to eq('scope' => 'bar', 'foo' => 'baz')
67
+ end
68
+ end
69
+
70
+ describe '#callback_phase' do
71
+ subject { fresh_strategy }
72
+ it 'calls fail with the client error received' do
73
+ instance = subject.new('abc', 'def')
74
+ allow(instance).to receive(:request) do
75
+ double('Request', params: {'error_reason' => 'user_denied', 'error' => 'access_denied'})
76
+ end
77
+
78
+ expect(instance).to receive(:fail!).with('user_denied', anything)
79
+ instance.callback_phase
80
+ end
81
+ end
82
+ end
83
+
84
+ describe OmniAuth::Strategies::Tecnologiedemocratiche::CallbackError do
85
+ let(:error) { Class.new(OmniAuth::Strategies::Tecnologiedemocratiche::CallbackError) }
86
+ describe '#message' do
87
+ subject { error }
88
+ it 'includes all of the attributes' do
89
+ instance = subject.new('error', 'description', 'uri')
90
+ expect(instance.message).to match(/error/)
91
+ expect(instance.message).to match(/description/)
92
+ expect(instance.message).to match(/uri/)
93
+ end
94
+ it 'includes all of the attributes' do
95
+ instance = subject.new(nil, :symbol)
96
+ expect(instance.message).to eq('symbol')
97
+ end
98
+ end
99
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-tecnologiedemocratiche
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Alessandro Rodi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-25 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
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: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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
+ description: Omniauth Strategy to connect via Tecnologie Democratiche
70
+ email:
71
+ - alessandro.rodi@renuo.ch
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rubocop.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/omniauth-tecnologiedemocratiche.rb
83
+ - lib/omniauth-tecnologiedemocratiche/version.rb
84
+ - lib/omniauth/strategies/tecnologiedemocratiche.rb
85
+ - omniauth-tecnologiedemocratiche.gemspec
86
+ - spec/helper.rb
87
+ - spec/omniauth/strategies/tecnologiedemocratiche_spec.rb
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.1
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Omniauth Strategy to connect via Tecnologie Democratiche
112
+ test_files:
113
+ - spec/helper.rb
114
+ - spec/omniauth/strategies/tecnologiedemocratiche_spec.rb
115
+ has_rdoc: