omniauth-flickr 0.0.17 → 0.0.18

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: 221681304d9f61f755b9444a982d5cabede6fade
4
- data.tar.gz: 9d3b57376604ef2d1c889971dcb910c366c7c1fa
3
+ metadata.gz: 6d043334971baaece4af66c2781a7dc2b6087d9f
4
+ data.tar.gz: 266c7eb02f5ebfd48f9fcd51cb29806d1df6f2f0
5
5
  SHA512:
6
- metadata.gz: e1963e3ccdbf635df694d673b623d7b7735628231c362031b5c3c28c15ff366c1fbd996681d7760ab014cf44471abd787864401f4e21e30d75bf86bd96f9d489
7
- data.tar.gz: 81bcfdd66bf67609c28dcdae3dae202dc1ce790894672fbc3162a47f66d900b4574151aa890115db933b46d3e510d6153037c4117f61b75cbd14bc97a0a459cc
6
+ metadata.gz: d5fac7139b4ecfa7bc47e612b976270ce89912562fea3e5aabac600bc6110c3dc220fd72649eba28929b28db32f9b7ed550e3adec633ce41afd714c474c38147
7
+ data.tar.gz: e3d4a91ebd6b47a887f794f15df6f2b058b6a0537b73a202c53455ee61a8fbf4662aed517d15cbd724a7845e3ba8eaf3350a11a1989809fcebb979e8f5a7baa9
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  coverage
6
+ logs/*.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/README.md CHANGED
@@ -47,6 +47,10 @@ credentials: !ruby/hash:OmniAuth::AuthHash
47
47
 
48
48
  ## Release notes:
49
49
 
50
+ * Version 0.0.18
51
+
52
+ - add test cases from Maxcal
53
+
50
54
  * Version 0.0.17
51
55
 
52
56
  - better examples and documentation, fix reversed name and nickname (thanks @maxcal)
@@ -83,18 +87,3 @@ credentials: !ruby/hash:OmniAuth::AuthHash
83
87
  * Version 0.0.6
84
88
 
85
89
  - Comply more closely to published Auth Hash Schema (https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema)
86
-
87
- * Version 0.0.5
88
-
89
- - Most available user information should now be available in the info hash - Still needs some testing and
90
- documentation--to come - Fixed a rescue so it is more contained
91
-
92
- * Version 0.0.4
93
-
94
- - Added more user info explicitly into the info hash
95
-
96
- * Version 0.0.1
97
-
98
- - First cut
99
-
100
-
@@ -22,23 +22,27 @@ module OmniAuth
22
22
  }
23
23
 
24
24
  info do
25
+
26
+ user_info_unwrapped = unwrap_hash_content(user_info.clone)
25
27
  {
26
28
  :name => access_token.params['fullname'],
27
29
  :nickname => access_token.params['username'],
28
- :ispro => user_info["ispro"],
29
- :iconserver => user_info["iconserver"],
30
- :iconfarm => user_info["iconfarm"],
31
- :path_alias => user_info["path_alias"],
30
+ :ispro => user_info_unwrapped["ispro"],
31
+ :iconserver => user_info_unwrapped["iconserver"],
32
+ :iconfarm => user_info_unwrapped["iconfarm"],
33
+ :path_alias => user_info_unwrapped["path_alias"],
32
34
  :urls => {
33
- "Photos" => user_info["photosurl"],
34
- "Profile" => user_info["profileurl"],
35
+ "Photos" => user_info_unwrapped["photosurl"],
36
+ "Profile" => user_info_unwrapped["profileurl"],
35
37
  },
36
- :mbox_sha1sum => user_info["mbox_sha1sum"],
37
- :location => user_info["location"],
38
+ :mbox_sha1sum => user_info_unwrapped["mbox_sha1sum"],
39
+ :location => user_info_unwrapped["location"],
38
40
  :image => image_info
39
41
  }
40
42
  end
41
43
 
44
+
45
+
42
46
  extra do
43
47
  {
44
48
  :raw_info => raw_info
@@ -73,6 +77,17 @@ module OmniAuth
73
77
  options[:authorize_params] = {:perms => options[:scope]} if options[:scope]
74
78
  super
75
79
  end
80
+
81
+ private
82
+ # Flickr has a really annoying habit of wrapping values in { "_content" : "something" }
83
+ # This loops through an auth hash and converts these values into simple key / val
84
+ def unwrap_hash_content(hash)
85
+ hash.each do |key, val|
86
+ if val.respond_to? :has_key?
87
+ hash[key] = val['_content'] if val.has_key?('_content')
88
+ end
89
+ end
90
+ end
76
91
  end
77
92
  end
78
93
  end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Flickr
3
- VERSION = "0.0.17"
3
+ VERSION = "0.0.18"
4
4
  end
5
5
  end
data/logs/.gitkeep ADDED
File without changes
@@ -19,4 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
22
- end
22
+ s.add_runtime_dependency 'multi_json', '~> 1.11.0'
23
+ s.add_development_dependency 'rspec', '~> 3.2.0'
24
+ s.add_development_dependency 'webmock', '~> 1.21.0'
25
+ s.add_development_dependency 'rack-test', '~> 0.6.3'
26
+ s.add_development_dependency 'rspec-its', '~> 1.2.0'
27
+ end
@@ -0,0 +1,28 @@
1
+ {
2
+ "person": {
3
+ "id": "ABC123",
4
+ "nsid": "ABC123",
5
+ "ispro": 0,
6
+ "can_buy_pro": 0,
7
+ "iconserver": "8061",
8
+ "iconfarm": 9,
9
+ "path_alias": "test string",
10
+ "has_stats": 0,
11
+ "username": "j.bloggs",
12
+ "realname": { "_content": "John Bloggs" },
13
+ "mbox_sha1sum": { "_content": "f9aa1a7919dea99ba86c773f58381aebc91e333d" },
14
+ "location": { "_content": "Gotham, USA" },
15
+ "timezone": { "label": "Pacific Time (US & Canada); Tijuana", "offset": "-08:00" },
16
+ "description": { "_content": "Amateur photographer from sweden.\n\nMost of my images are available with a creative commons licence for non-commercial usage. But i do appreciate if you contact me prior to publishing." },
17
+ "photosurl": { "_content": "https:\/\/www.flickr.com\/photos\/ABC123\/" },
18
+ "profileurl": { "_content": "https:\/\/www.flickr.com\/people\/ABC123\/" },
19
+ "mobileurl": { "_content": "https:\/\/m.flickr.com\/photostream.gne?id=ABC123" },
20
+ "photos": {
21
+ "firstdatetaken": { "_content": "2011-04-25 14:20:23" },
22
+ "firstdate": { "_content": "1305397528" },
23
+ "count": { "_content": "191" },
24
+ "views": { "_content": "156" }
25
+ }
26
+ },
27
+ "stat": "ok"
28
+ }
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+ require 'omniauth/strategies/flickr'
3
+ require "addressable/uri"
4
+
5
+ RSpec.describe OmniAuth::Strategies::Flickr, type: :strategy do
6
+
7
+ let(:app) do
8
+ Rack::Builder.new {
9
+ use OmniAuth::Test::PhonySession
10
+ use OmniAuth::Builder do
11
+ provider :flickr, ENV['FLICKR_KEY'], ENV['FLICKR_SECRET'], scope: 'read'
12
+ end
13
+ run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
14
+ }.to_app
15
+ end
16
+
17
+ let(:session) { last_request.env['rack.session'] }
18
+
19
+ before do
20
+ stub_request(:post, "https://www.flickr.com/services/oauth/request_token").
21
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
22
+ end
23
+
24
+ describe '/auth/flickr' do
25
+
26
+ before { get '/auth/flickr' }
27
+
28
+ it 'should redirect to authorize_url' do
29
+ expect(last_response.headers['Location']).to \
30
+ eq "https://www.flickr.com/services/oauth/authorize?perms=read&oauth_token=yourtoken"
31
+ end
32
+
33
+ it 'should set appropriate session variables' do
34
+ expect(session['oauth']['flickr']).to eq({
35
+ 'callback_confirmed' => true,
36
+ 'request_token' => 'yourtoken',
37
+ 'request_secret' => 'yoursecret'
38
+ })
39
+ end
40
+ end
41
+
42
+ describe '/auth/flickr/callback' do
43
+ let(:session) {
44
+ {
45
+ 'rack.session' => {
46
+ 'oauth' => {
47
+ "flickr" => {
48
+ 'callback_confirmed' => true,
49
+ 'request_token' => 'yourtoken',
50
+ 'request_secret' => 'yoursecret'
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ let(:auth_response) { last_request.env['omniauth.auth'] }
57
+ let(:get_info) {
58
+ IO.binread(File.dirname(__FILE__) + "/flickr.people.getInfo.json")
59
+ }
60
+
61
+ before do
62
+ stub_request(:post, 'https://www.flickr.com/services/oauth/access_token').
63
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&username=j.bloggs&fullname=John Bloggs&user_nsid=ABC123")
64
+
65
+ stub_request(:get, 'https://www.flickr.com/services/rest/?format=json&method=flickr.people.getInfo&nojsoncallback=1&user_id=ABC123')
66
+ .to_return(:body => get_info)
67
+
68
+ get '/auth/flickr/callback', {:oauth_verifier => 'dudeman'}, session
69
+ end
70
+
71
+ it 'calls through to the master app' do
72
+ expect(last_response.body).to eq 'true'
73
+ end
74
+
75
+ it 'exchanges the request token for an access token' do
76
+ expect(auth_response['provider']).to eq 'flickr'
77
+ expect(auth_response['extra']['access_token']).to be_kind_of(OAuth::AccessToken)
78
+ end
79
+
80
+ it "has the correct UID" do
81
+ expect(auth_response.uid).to eq "ABC123"
82
+ end
83
+
84
+ describe "auth_response.info" do
85
+ subject { auth_response['info'] }
86
+
87
+ its(:nickname) { should eq "j.bloggs" }
88
+ its(:name) { should eq "John Bloggs" }
89
+ its(:image) { should eq 'http://farm9.static.flickr.com/8061/buddyicons/ABC123.jpg' }
90
+ its(:ispro) { should eq 0 }
91
+ its(:iconserver) { should eq "8061" }
92
+ its(:iconfarm) { should eq 9 }
93
+ its(:path_alias) { should eq "test string" }
94
+ its(:urls) { should eq({
95
+ "Photos" => "https://www.flickr.com/photos/ABC123/",
96
+ "Profile" => "https://www.flickr.com/people/ABC123/",
97
+ })}
98
+ its(:mbox_sha1sum) { should eq "f9aa1a7919dea99ba86c773f58381aebc91e333d"}
99
+ its(:location) { should eq "Gotham, USA" }
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,70 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+
18
+ #
19
+
20
+
21
+ require 'rack/test'
22
+ require 'webmock/rspec'
23
+ require 'omniauth'
24
+ require 'logger'
25
+ require 'rspec/its'
26
+
27
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
28
+ RSpec.configure do |config|
29
+
30
+
31
+ # rspec-expectations config goes here. You can use an alternate
32
+ # assertion/expectation library such as wrong or the stdlib/minitest
33
+ # assertions if you prefer.
34
+
35
+ OmniAuth.config.logger = Logger.new(File.dirname(__FILE__) + '/../logs/test.log')
36
+
37
+ config.include WebMock::API
38
+ config.include Rack::Test::Methods
39
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
40
+
41
+ config.expect_with :rspec do |expectations|
42
+ # This option will default to `true` in RSpec 4. It makes the `description`
43
+ # and `failure_message` of custom matchers include text for helper methods
44
+ # defined using `chain`, e.g.:
45
+ # be_bigger_than(2).and_smaller_than(4).description
46
+ # # => "be bigger than 2 and smaller than 4"
47
+ # ...rather than:
48
+ # # => "be bigger than 2"
49
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
50
+ end
51
+
52
+ # rspec-mocks config goes here. You can use an alternate test double
53
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
54
+ config.mock_with :rspec do |mocks|
55
+ # Prevents you from mocking or stubbing a method that does not exist on
56
+ # a real object. This is generally recommended, and will default to
57
+ # `true` in RSpec 4.
58
+ mocks.verify_partial_doubles = true
59
+ end
60
+
61
+ # The settings below are suggested to provide a good initial experience
62
+ # with RSpec, but feel free to customize to your heart's content.
63
+
64
+ # These two settings work together to allow you to limit a spec run
65
+ # to individual examples or groups you care about by tagging them with
66
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
67
+ # get run.
68
+ config.filter_run :focus
69
+ config.run_all_when_everything_filtered = true
70
+ end
metadata CHANGED
@@ -1,29 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-flickr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Breitkreutz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.11.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.11.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.21.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.21.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-its
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.2.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.2.0
27
97
  description: OmniAuth strategy for Flickr
28
98
  email:
29
99
  - tim@sbrew.com
@@ -31,7 +101,8 @@ executables: []
31
101
  extensions: []
32
102
  extra_rdoc_files: []
33
103
  files:
34
- - ".gitignore"
104
+ - .gitignore
105
+ - .rspec
35
106
  - Gemfile
36
107
  - LICENSE
37
108
  - README.md
@@ -40,7 +111,11 @@ files:
40
111
  - lib/omniauth-flickr.rb
41
112
  - lib/omniauth-flickr/version.rb
42
113
  - lib/omniauth/strategies/flickr.rb
114
+ - logs/.gitkeep
43
115
  - omniauth-flickr.gemspec
116
+ - spec/omniauth/strategies/flickr.people.getInfo.json
117
+ - spec/omniauth/strategies/flickr_spec.rb
118
+ - spec/spec_helper.rb
44
119
  homepage: https://github.com/timbreitkreutz/omniauth-flickr
45
120
  licenses: []
46
121
  metadata: {}
@@ -50,19 +125,21 @@ require_paths:
50
125
  - lib
51
126
  required_ruby_version: !ruby/object:Gem::Requirement
52
127
  requirements:
53
- - - ">="
128
+ - - '>='
54
129
  - !ruby/object:Gem::Version
55
130
  version: '0'
56
131
  required_rubygems_version: !ruby/object:Gem::Requirement
57
132
  requirements:
58
- - - ">="
133
+ - - '>='
59
134
  - !ruby/object:Gem::Version
60
135
  version: '0'
61
136
  requirements: []
62
137
  rubyforge_project: omniauth-flickr
63
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.0.6
64
139
  signing_key:
65
140
  specification_version: 4
66
141
  summary: OmniAuth strategy for Flickr
67
- test_files: []
68
- has_rdoc:
142
+ test_files:
143
+ - spec/omniauth/strategies/flickr.people.getInfo.json
144
+ - spec/omniauth/strategies/flickr_spec.rb
145
+ - spec/spec_helper.rb