New upstream snapshot.
Debian Janitor
1 year, 10 months ago
0 | name: Ruby | |
1 | ||
2 | on: [push, pull_request] | |
3 | ||
4 | jobs: | |
5 | test: | |
6 | runs-on: ${{ matrix.os }}-latest | |
7 | strategy: | |
8 | fail-fast: false | |
9 | matrix: | |
10 | os: | |
11 | - ubuntu | |
12 | ruby: | |
13 | - "2.5" | |
14 | - "2.6" | |
15 | - "2.7" | |
16 | - "3.0" | |
17 | steps: | |
18 | - uses: actions/checkout@v2 | |
19 | - name: Set up Ruby | |
20 | uses: ruby/setup-ruby@v1 | |
21 | with: | |
22 | ruby-version: ${{ matrix.ruby }} | |
23 | bundler-cache: true | |
24 | - name: Install dependencies | |
25 | run: bundle install | |
26 | - name: Run tests | |
27 | run: bundle exec rake |
0 | name: Mark stale issues and pull requests | |
1 | ||
2 | on: | |
3 | schedule: | |
4 | - cron: "0 0 * * *" | |
5 | ||
6 | jobs: | |
7 | stale: | |
8 | ||
9 | runs-on: ubuntu-latest | |
10 | ||
11 | steps: | |
12 | - uses: actions/stale@v1 | |
13 | with: | |
14 | repo-token: ${{ secrets.GITHUB_TOKEN }} | |
15 | stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' | |
16 | stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' | |
17 | stale-issue-label: 'no-issue-activity' | |
18 | stale-pr-label: 'no-pr-activity' | |
19 | days-before-stale: 30 | |
20 | days-before-close: 5 | |
21 | exempt-pr-label: 'pinned' | |
22 | exempt-issue-label: 'pinned' |
0 | before_install: | |
1 | - gem update bundler | |
2 | - bundle --version | |
3 | - gem update --system | |
4 | - gem --version | |
5 | rvm: | |
6 | - 2.3.0 | |
7 | - 2.2 | |
8 | - 2.1 | |
9 | - 2.0 | |
10 | - 1.9.3 | |
11 | - jruby-19mode | |
12 | - rbx-2 |
0 | ## 8.0.0 (2020-10-20) | |
1 | ||
2 | Changes: | |
3 | ||
4 | - user profile picture link includes access token (#344, @anklos) | |
5 | ||
6 | ## 7.0.0 (2020-08-03) | |
7 | ||
8 | Changes: | |
9 | ||
10 | - bumped version of FB Graph API to v4.0 | |
11 | ||
12 | ## 6.0.0 (2020-01-27) | |
13 | ||
14 | Changes: | |
15 | ||
16 | - bumped version of FB Graph API to v3.0 | |
17 | ||
18 | ## 5.0.0 (2018-03-29) | |
19 | ||
20 | Changes: | |
21 | ||
22 | - bumped version of FB Graph API to v2.10 (#297, @piotrjaworski) | |
23 | - use only CRuby 2.0+ on CI (#298, @simi) | |
24 | ||
0 | 25 | ## 4.0.0 (2016-07-26) |
1 | 26 | |
2 | 27 | Changes: |
5 | 30 | - switch to versioned FB APIs, currently using v2.6 (#245, @printercu, @mkdynamic) |
6 | 31 | - remove deprecated :nickname field from README example (#223, @abelorian) |
7 | 32 | - add Ruby 2.2 + 2.3.0 to CI (#225, @tricknotes, @mkdynamic, @anoraak) |
8 | - update example app (@mkynamic) | |
33 | - update example app (@mkdynamic) | |
9 | 34 | |
10 | 35 | ## 3.0.0 (2015-10-26) |
11 | 36 |
0 | # OmniAuth Facebook [](https://travis-ci.org/mkdynamic/omniauth-facebook) [](https://rubygems.org/gems/omniauth-facebook) | |
0 | # OmniAuth Facebook [](https://travis-ci.org/simi/omniauth-facebook) [](https://rubygems.org/gems/omniauth-facebook) | |
1 | ||
2 | 📣 **NOTICE** We’re looking for maintainers to help keep this project up-to-date. If you are interested in helping please open an Issue expressing your interest. Thanks! 📣 | |
1 | 3 | |
2 | 4 | **These notes are based on master, please see tags for README pertaining to specific releases.** |
3 | 5 | |
23 | 25 | |
24 | 26 | ```ruby |
25 | 27 | Rails.application.config.middleware.use OmniAuth::Builder do |
26 | provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] | |
28 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'] | |
27 | 29 | end |
28 | 30 | ``` |
29 | 31 | |
30 | [See the example Sinatra app for full examples](https://github.com/mkdynamic/omniauth-facebook/blob/master/example/config.ru) of both the server and client-side flows (including using the Facebook Javascript SDK). | |
32 | [See the example Sinatra app for full examples](https://github.com/simi/omniauth-facebook/blob/master/example/config.ru) of both the server and client-side flows (including using the Facebook Javascript SDK). | |
31 | 33 | |
32 | 34 | ## Configuring |
33 | 35 | |
38 | 40 | `scope` | `email` | A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: https://developers.facebook.com/docs/reference/login/ |
39 | 41 | `display` | `page` | The display context to show the authentication page. Options are: `page`, `popup` and `touch`. Read the Facebook docs for more details: https://developers.facebook.com/docs/reference/dialogs/oauth/ |
40 | 42 | `image_size` | `square` | Set the size for the returned image url in the auth hash. Valid options include `square` (50x50), `small` (50 pixels wide, variable height), `normal` (100 pixels wide, variable height), or `large` (about 200 pixels wide, variable height). Additionally, you can request a picture of a specific size by setting this option to a hash with `:width` and `:height` as keys. This will return an available profile picture closest to the requested size and requested aspect ratio. If only `:width` or `:height` is specified, we will return a picture whose width or height is closest to the requested size, respectively. |
41 | `info_fields` | 'name,email' | Specify exactly which fields should be returned when getting the user's info. Value should be a comma-separated string as per https://developers.facebook.com/docs/graph-api/reference/user/ (only `/me` endpoint). | |
43 | `info_fields` | `name,email` | Specify exactly which fields should be returned when getting the user's info. Value should be a comma-separated string as per https://developers.facebook.com/docs/graph-api/reference/user/ (only `/me` endpoint). | |
42 | 44 | `locale` | | Specify locale which should be used when getting the user's info. Value should be locale string as per https://developers.facebook.com/docs/reference/api/locale/. |
43 | 45 | `auth_type` | | Optionally specifies the requested authentication features as a comma-separated list, as per https://developers.facebook.com/docs/facebook-login/reauthentication/. Valid values are `https` (checks for the presence of the secure cookie and asks for re-authentication if it is not present), and `reauthenticate` (asks the user to re-authenticate unconditionally). Use 'rerequest' when you want to request premissions. Default is `nil`. |
44 | `secure_image_url` | `false` | Set to `true` to use https for the avatar image url returned in the auth hash. | |
46 | `secure_image_url` | `true` | Set to `true` to use https for the avatar image url returned in the auth hash. SSL is mandatory as per https://developers.facebook.com/docs/facebook-login/security#surfacearea. | |
45 | 47 | `callback_url` / `callback_path` | | Specify a custom callback URL used during the server-side flow. Note this must be allowed by your app configuration on Facebook (see 'Valid OAuth redirect URIs' under the 'Advanced' settings section in the configuration for your Facebook app for more details). |
46 | 48 | |
47 | 49 | For example, to request `email`, `user_birthday` and `read_stream` permissions and display the authentication page in a popup window: |
48 | 50 | |
49 | 51 | ```ruby |
50 | 52 | Rails.application.config.middleware.use OmniAuth::Builder do |
51 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], | |
53 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], | |
52 | 54 | scope: 'email,user_birthday,read_stream', display: 'popup' |
53 | 55 | end |
54 | 56 | ``` |
55 | 57 | |
56 | 58 | ### API Version |
57 | 59 | |
58 | OmniAuth Facebook uses versioned API endpoints by default (current v2.6). You can configure a different version via `client_options` hash passed to `provider`, specifically you should change the version in the `site` and `authorize_url` parameters. For example, to change to v3.0 (assuming that exists): | |
60 | OmniAuth Facebook uses versioned API endpoints by default (current v4.0). You can configure a different version via `client_options` hash passed to `provider`, specifically you should change the version in the `site` and `authorize_url` parameters. For example, to change to v7.0 (assuming that exists): | |
59 | 61 | |
60 | 62 | ```ruby |
61 | 63 | use OmniAuth::Builder do |
62 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], | |
64 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], | |
63 | 65 | client_options: { |
64 | site: 'https://graph.facebook.com/v3.0', | |
65 | authorize_url: "https://www.facebook.com/v3.0/dialog/oauth" | |
66 | site: 'https://graph.facebook.com/v7.0', | |
67 | authorize_url: "https://www.facebook.com/v7.0/dialog/oauth" | |
66 | 68 | } |
67 | 69 | end |
68 | 70 | ``` |
84 | 86 | name: 'Joe Bloggs', |
85 | 87 | first_name: 'Joe', |
86 | 88 | last_name: 'Bloggs', |
87 | image: 'http://graph.facebook.com/1234567/picture?type=square', | |
88 | urls: { Facebook: 'http://www.facebook.com/jbloggs' }, | |
89 | location: 'Palo Alto, California', | |
89 | image: 'http://graph.facebook.com/1234567/picture?type=square&access_token=...', | |
90 | 90 | verified: true |
91 | 91 | }, |
92 | 92 | credentials: { |
151 | 151 | |
152 | 152 | ## Supported Rubies |
153 | 153 | |
154 | - Ruby MRI (1.9.3+) | |
155 | - JRuby (1.9 mode) | |
156 | - RBX (2.1.1+) | |
154 | - Ruby MRI (2.5, 2.6, 2.7, 3.0) | |
157 | 155 | |
158 | 156 | ## License |
159 | 157 |
0 | ruby-omniauth-facebook (4.0.0-3) UNRELEASED; urgency=medium | |
0 | ruby-omniauth-facebook (8.0.0+git20210209.1.853dce6-1) UNRELEASED; urgency=medium | |
1 | 1 | |
2 | 2 | [ Utkarsh Gupta ] |
3 | 3 | * Add salsa-ci.yml |
12 | 12 | Repository-Browse. |
13 | 13 | * Update Vcs-* headers from URL redirect. |
14 | 14 | * Use canonical URL in Vcs-Git. |
15 | * New upstream snapshot. | |
15 | 16 | |
16 | -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Tue, 13 Aug 2019 06:15:37 +0530 | |
17 | -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Wed, 21 Jul 2021 07:01:53 -0000 | |
17 | 18 | |
18 | 19 | ruby-omniauth-facebook (4.0.0-2) unstable; urgency=medium |
19 | 20 |
0 | 0 | PATH |
1 | remote: ../ | |
1 | remote: .. | |
2 | 2 | specs: |
3 | omniauth-facebook (3.0.0) | |
3 | omniauth-facebook (8.0.0) | |
4 | 4 | omniauth-oauth2 (~> 1.2) |
5 | 5 | |
6 | 6 | GEM |
7 | 7 | remote: https://rubygems.org/ |
8 | 8 | specs: |
9 | backports (3.6.8) | |
10 | faraday (0.9.2) | |
9 | backports (3.15.0) | |
10 | faraday (1.1.0) | |
11 | 11 | multipart-post (>= 1.2, < 3) |
12 | hashie (3.4.4) | |
13 | jwt (1.5.1) | |
14 | multi_json (1.12.1) | |
15 | multi_xml (0.5.5) | |
16 | multipart-post (2.0.0) | |
17 | oauth2 (1.1.0) | |
18 | faraday (>= 0.8, < 0.10) | |
19 | jwt (~> 1.0, < 1.5.2) | |
12 | ruby2_keywords | |
13 | hashie (4.1.0) | |
14 | jwt (2.2.2) | |
15 | multi_json (1.14.1) | |
16 | multi_xml (0.6.0) | |
17 | multipart-post (2.1.1) | |
18 | mustermann (1.1.1) | |
19 | ruby2_keywords (~> 0.0.1) | |
20 | oauth2 (1.4.4) | |
21 | faraday (>= 0.8, < 2.0) | |
22 | jwt (>= 1.0, < 3.0) | |
20 | 23 | multi_json (~> 1.3) |
21 | 24 | multi_xml (~> 0.5) |
22 | 25 | rack (>= 1.2, < 3) |
23 | omniauth (1.3.1) | |
24 | hashie (>= 1.2, < 4) | |
25 | rack (>= 1.0, < 3) | |
26 | omniauth-oauth2 (1.4.0) | |
27 | oauth2 (~> 1.0) | |
28 | omniauth (~> 1.2) | |
29 | rack (1.6.4) | |
30 | rack-protection (1.5.3) | |
26 | omniauth (1.9.1) | |
27 | hashie (>= 3.4.6) | |
28 | rack (>= 1.6.2, < 3) | |
29 | omniauth-oauth2 (1.7.0) | |
30 | oauth2 (~> 1.4) | |
31 | omniauth (~> 1.9) | |
32 | rack (2.2.3) | |
33 | rack-protection (2.0.8.1) | |
31 | 34 | rack |
32 | rack-test (0.6.3) | |
33 | rack (>= 1.0) | |
34 | sinatra (1.4.7) | |
35 | rack (~> 1.5) | |
36 | rack-protection (~> 1.4) | |
37 | tilt (>= 1.3, < 3) | |
38 | sinatra-contrib (1.4.7) | |
39 | backports (>= 2.0) | |
35 | ruby2_keywords (0.0.2) | |
36 | sinatra (2.0.8.1) | |
37 | mustermann (~> 1.0) | |
38 | rack (~> 2.0) | |
39 | rack-protection (= 2.0.8.1) | |
40 | tilt (~> 2.0) | |
41 | sinatra-contrib (2.0.8.1) | |
42 | backports (>= 2.8.2) | |
40 | 43 | multi_json |
41 | rack-protection | |
42 | rack-test | |
43 | sinatra (~> 1.4.0) | |
44 | tilt (>= 1.3, < 3) | |
44 | mustermann (~> 1.0) | |
45 | rack-protection (= 2.0.8.1) | |
46 | sinatra (= 2.0.8.1) | |
47 | tilt (~> 2.0) | |
45 | 48 | sinatra-reloader (1.0) |
46 | 49 | sinatra-contrib |
47 | tilt (2.0.5) | |
50 | tilt (2.0.10) | |
48 | 51 | |
49 | 52 | PLATFORMS |
50 | 53 | ruby |
54 | x64-mingw32 | |
51 | 55 | |
52 | 56 | DEPENDENCIES |
53 | 57 | omniauth-facebook! |
55 | 59 | sinatra-reloader |
56 | 60 | |
57 | 61 | BUNDLED WITH |
58 | 1.12.5 | |
62 | 1.17.3 |
0 | 0 | require 'sinatra' |
1 | 1 | require "sinatra/reloader" |
2 | 2 | require 'yaml' |
3 | require 'json' | |
3 | 4 | |
4 | 5 | # configure sinatra |
5 | 6 | set :run, false |
26 | 27 | <script type="text/javascript"> |
27 | 28 | window.fbAsyncInit = function() { |
28 | 29 | FB.init({ |
29 | appId: '#{ENV['APP_ID']}', | |
30 | version: 'v2.6', | |
30 | appId: '#{ENV['FACEBOOK_APP_ID']}', | |
31 | version: 'v4.0', | |
31 | 32 | cookie: true // IMPORTANT must enable cookies to allow the server to access the session |
32 | 33 | }); |
33 | 34 | console.log("fb init"); |
80 | 81 | # - ajax request made here for client-side flow |
81 | 82 | get '/auth/:provider/callback' do |
82 | 83 | content_type 'application/json' |
83 | MultiJson.encode(request.env) | |
84 | JSON.dump(request.env) | |
84 | 85 | end |
4 | 4 | use Rack::Session::Cookie, secret: 'abc123' |
5 | 5 | |
6 | 6 | use OmniAuth::Builder do |
7 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'] | |
7 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'] | |
8 | 8 | end |
9 | 9 | |
10 | 10 | run Sinatra::Application |
11 | 11 | DEFAULT_SCOPE = 'email' |
12 | 12 | |
13 | 13 | option :client_options, { |
14 | site: 'https://graph.facebook.com/v2.6', | |
15 | authorize_url: "https://www.facebook.com/v2.6/dialog/oauth", | |
14 | site: 'https://graph.facebook.com/v4.0', | |
15 | authorize_url: "https://www.facebook.com/v4.0/dialog/oauth", | |
16 | 16 | token_url: 'oauth/access_token' |
17 | 17 | } |
18 | 18 | |
21 | 21 | param_name: 'access_token' |
22 | 22 | } |
23 | 23 | |
24 | option :authorization_code_from_signed_request_in_cookie, nil | |
25 | ||
24 | 26 | option :authorize_options, [:scope, :display, :auth_type] |
27 | ||
28 | option :secure_image_url, true | |
25 | 29 | |
26 | 30 | uid { raw_info['id'] } |
27 | 31 | |
75 | 79 | # phase and it must match during the access_token phase: |
76 | 80 | # https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L477 |
77 | 81 | def callback_url |
78 | if @authorization_code_from_signed_request_in_cookie | |
82 | if options.authorization_code_from_signed_request_in_cookie | |
79 | 83 | '' |
80 | 84 | else |
81 | 85 | # Fixes regression in omniauth-oauth2 v1.4.0 by https://github.com/intridea/omniauth-oauth2/commit/85fdbe117c2a4400d001a6368cc359d88f40abc7 |
130 | 134 | yield |
131 | 135 | elsif code_from_signed_request = signed_request_from_cookie && signed_request_from_cookie['code'] |
132 | 136 | request.params['code'] = code_from_signed_request |
133 | @authorization_code_from_signed_request_in_cookie = true | |
137 | options.authorization_code_from_signed_request_in_cookie = true | |
134 | 138 | # NOTE The code from the signed fbsr_XXX cookie is set by the FB JS SDK will confirm that the identity of the |
135 | 139 | # user contained in the signed request matches the user loading the app. |
136 | 140 | original_provider_ignores_state = options.provider_ignores_state |
139 | 143 | yield |
140 | 144 | ensure |
141 | 145 | request.params.delete('code') |
142 | @authorization_code_from_signed_request_in_cookie = false | |
146 | options.authorization_code_from_signed_request_in_cookie = false | |
143 | 147 | options.provider_ignores_state = original_provider_ignores_state |
144 | 148 | end |
145 | 149 | else |
158 | 162 | uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP |
159 | 163 | site_uri = URI.parse(client.site) |
160 | 164 | url = uri_class.build({host: site_uri.host, path: "#{site_uri.path}/#{uid}/picture"}) |
165 | query = { access_token: access_token.token } | |
161 | 166 | |
162 | query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol) | |
163 | { type: options[:image_size] } | |
167 | if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol) | |
168 | query[:type] = options[:image_size] | |
164 | 169 | elsif options[:image_size].is_a?(Hash) |
165 | options[:image_size] | |
170 | query.merge!(options[:image_size]) | |
166 | 171 | end |
167 | url.query = Rack::Utils.build_query(query) if query | |
172 | ||
173 | url.query = Rack::Utils.build_query(query) | |
168 | 174 | |
169 | 175 | url.to_s |
170 | 176 | end |
7 | 7 | s.authors = ['Mark Dodwell', 'Josef Šimánek'] |
8 | 8 | s.email = ['mark@madeofcode.com', 'retro@ballgag.cz'] |
9 | 9 | s.summary = 'Facebook OAuth2 Strategy for OmniAuth' |
10 | s.homepage = 'https://github.com/mkdynamic/omniauth-facebook' | |
10 | s.homepage = 'https://github.com/simi/omniauth-facebook' | |
11 | 11 | s.license = 'MIT' |
12 | 12 | |
13 | 13 | s.files = `git ls-files`.split("\n") |
40 | 40 | |
41 | 41 | @client_id = '123' |
42 | 42 | @client_secret = '53cr3tz' |
43 | @options = {} | |
43 | 44 | end |
44 | 45 | |
45 | 46 | def strategy |
52 | 53 | end |
53 | 54 | end |
54 | 55 | |
55 | Dir[File.expand_path('../support/**/*', __FILE__)].each &method(:require) | |
56 | Dir[File.expand_path('../support/**/*', __FILE__)].each(&method(:require)) |
8 | 8 | |
9 | 9 | class ClientTest < StrategyTestCase |
10 | 10 | test 'has correct Facebook site' do |
11 | assert_equal 'https://graph.facebook.com/v2.6', strategy.client.site | |
11 | assert_equal 'https://graph.facebook.com/v4.0', strategy.client.site | |
12 | 12 | end |
13 | 13 | |
14 | 14 | test 'has correct authorize url' do |
15 | assert_equal 'https://www.facebook.com/v2.6/dialog/oauth', strategy.client.options[:authorize_url] | |
15 | assert_equal 'https://www.facebook.com/v4.0/dialog/oauth', strategy.client.options[:authorize_url] | |
16 | 16 | end |
17 | 17 | |
18 | 18 | test 'has correct token url with versioning' do |
94 | 94 | end |
95 | 95 | |
96 | 96 | class InfoTest < StrategyTestCase |
97 | test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do | |
97 | def setup | |
98 | super | |
99 | @access_token = stub('OAuth2::AccessToken') | |
100 | @access_token.stubs(:token).returns('test_access_token') | |
101 | end | |
102 | ||
103 | test 'returns the secure facebook avatar url when `secure_image_url` option is set to true' do | |
98 | 104 | @options = { secure_image_url: true } |
99 | 105 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
100 | 106 | strategy.stubs(:raw_info).returns(raw_info) |
101 | assert_equal 'https://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
107 | strategy.stubs(:access_token).returns(@access_token) | |
108 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
109 | end | |
110 | ||
111 | test 'returns the non-ssl facebook avatar url when `secure_image_url` option is set to false' do | |
112 | @options = { secure_image_url: false } | |
113 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } | |
114 | strategy.stubs(:raw_info).returns(raw_info) | |
115 | strategy.stubs(:access_token).returns(@access_token) | |
116 | assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
117 | end | |
118 | ||
119 | test 'returns the secure facebook avatar url when `secure_image_url` option is omitted' do | |
120 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } | |
121 | strategy.stubs(:raw_info).returns(raw_info) | |
122 | strategy.stubs(:access_token).returns(@access_token) | |
123 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
102 | 124 | end |
103 | 125 | |
104 | 126 | test 'returns the image_url based of the client site' do |
105 | 127 | @options = { secure_image_url: true, client_options: {site: "https://blah.facebook.com/v2.2"}} |
106 | 128 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
107 | 129 | strategy.stubs(:raw_info).returns(raw_info) |
108 | assert_equal 'https://blah.facebook.com/v2.2/321/picture', strategy.info['image'] | |
130 | strategy.stubs(:access_token).returns(@access_token) | |
131 | assert_equal "https://blah.facebook.com/v2.2/321/picture?access_token=test_access_token", strategy.info['image'] | |
109 | 132 | end |
110 | 133 | |
111 | 134 | test 'returns the image with size specified in the `image_size` option' do |
112 | 135 | @options = { image_size: 'normal' } |
113 | 136 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
114 | 137 | strategy.stubs(:raw_info).returns(raw_info) |
115 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
138 | strategy.stubs(:access_token).returns(@access_token) | |
139 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image'] | |
116 | 140 | end |
117 | 141 | |
118 | 142 | test 'returns the image with size specified as a symbol in the `image_size` option' do |
119 | 143 | @options = { image_size: :normal } |
120 | 144 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
121 | 145 | strategy.stubs(:raw_info).returns(raw_info) |
122 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
146 | strategy.stubs(:access_token).returns(@access_token) | |
147 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image'] | |
123 | 148 | end |
124 | 149 | |
125 | 150 | test 'returns the image with width and height specified in the `image_size` option' do |
126 | 151 | @options = { image_size: { width: 123, height: 987 } } |
127 | 152 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
128 | 153 | strategy.stubs(:raw_info).returns(raw_info) |
154 | strategy.stubs(:access_token).returns(@access_token) | |
129 | 155 | assert_match 'width=123', strategy.info['image'] |
130 | 156 | assert_match 'height=987', strategy.info['image'] |
131 | assert_match 'http://graph.facebook.com/v2.6/321/picture?', strategy.info['image'] | |
157 | assert_match 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
132 | 158 | end |
133 | 159 | end |
134 | 160 | |
137 | 163 | super |
138 | 164 | @raw_info ||= { 'name' => 'Fred Smith' } |
139 | 165 | strategy.stubs(:raw_info).returns(@raw_info) |
166 | ||
167 | access_token = stub('OAuth2::AccessToken') | |
168 | access_token.stubs(:token).returns('test_access_token') | |
169 | strategy.stubs(:access_token).returns(access_token) | |
140 | 170 | end |
141 | 171 | |
142 | 172 | test 'returns the name' do |
175 | 205 | |
176 | 206 | test 'returns the facebook avatar url' do |
177 | 207 | @raw_info['id'] = '321' |
178 | assert_equal 'http://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
208 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
179 | 209 | end |
180 | 210 | |
181 | 211 | test 'returns the Facebook link as the Facebook url' do |
214 | 244 | super |
215 | 245 | @raw_info ||= { 'name' => 'Fred Smith' } |
216 | 246 | strategy.stubs(:raw_info).returns(@raw_info) |
247 | ||
248 | access_token = stub('OAuth2::AccessToken') | |
249 | access_token.stubs(:token).returns('test_access_token') | |
250 | strategy.stubs(:access_token).returns(access_token) | |
217 | 251 | end |
218 | 252 | |
219 | 253 | test 'has no email key' do |
257 | 291 | @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'} |
258 | 292 | end |
259 | 293 | |
260 | test 'performs a GET to https://graph.facebook.com/v2.6/me' do | |
294 | test 'performs a GET to https://graph.facebook.com/v4.0/me' do | |
261 | 295 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
262 | 296 | strategy.stubs(:access_token).returns(@access_token) |
263 | 297 | params = {params: @options} |
265 | 299 | strategy.raw_info |
266 | 300 | end |
267 | 301 | |
268 | test 'performs a GET to https://graph.facebook.com/v2.6/me with locale' do | |
302 | test 'performs a GET to https://graph.facebook.com/v4.0/me with locale' do | |
269 | 303 | @options.merge!({ locale: 'cs_CZ' }) |
270 | 304 | strategy.stubs(:access_token).returns(@access_token) |
271 | 305 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
274 | 308 | strategy.raw_info |
275 | 309 | end |
276 | 310 | |
277 | test 'performs a GET to https://graph.facebook.com/v2.6/me with info_fields' do | |
311 | test 'performs a GET to https://graph.facebook.com/v4.0/me with info_fields' do | |
278 | 312 | @options.merge!({info_fields: 'about'}) |
279 | 313 | strategy.stubs(:access_token).returns(@access_token) |
280 | 314 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
283 | 317 | strategy.raw_info |
284 | 318 | end |
285 | 319 | |
286 | test 'performs a GET to https://graph.facebook.com/v2.6/me with default info_fields' do | |
320 | test 'performs a GET to https://graph.facebook.com/v4.0/me with default info_fields' do | |
287 | 321 | strategy.stubs(:access_token).returns(@access_token) |
288 | 322 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
289 | 323 | params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}} |
451 | 485 | end |
452 | 486 | |
453 | 487 | test 'empty param' do |
454 | assert_equal nil, strategy.send(:signed_request_from_cookie) | |
488 | assert_nil strategy.send(:signed_request_from_cookie) | |
455 | 489 | end |
456 | 490 | end |
457 | 491 |