Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gems/omniauth-salesforce')
-rw-r--r--vendor/gems/omniauth-salesforce/.gitlab-ci.yml28
-rwxr-xr-xvendor/gems/omniauth-salesforce/Gemfile12
-rw-r--r--vendor/gems/omniauth-salesforce/Gemfile.lock124
-rwxr-xr-xvendor/gems/omniauth-salesforce/Guardfile10
-rw-r--r--vendor/gems/omniauth-salesforce/LICENSE.md5
-rwxr-xr-xvendor/gems/omniauth-salesforce/README.md60
-rwxr-xr-xvendor/gems/omniauth-salesforce/Rakefile12
-rwxr-xr-xvendor/gems/omniauth-salesforce/lib/omniauth-salesforce.rb2
-rwxr-xr-xvendor/gems/omniauth-salesforce/lib/omniauth-salesforce/version.rb5
-rwxr-xr-xvendor/gems/omniauth-salesforce/lib/omniauth/strategies/salesforce.rb97
-rwxr-xr-xvendor/gems/omniauth-salesforce/omniauth-salesforce.gemspec24
-rwxr-xr-xvendor/gems/omniauth-salesforce/spec/omniauth/strategies/salesforce_spec.rb219
-rwxr-xr-xvendor/gems/omniauth-salesforce/spec/spec_helper.rb16
13 files changed, 614 insertions, 0 deletions
diff --git a/vendor/gems/omniauth-salesforce/.gitlab-ci.yml b/vendor/gems/omniauth-salesforce/.gitlab-ci.yml
new file mode 100644
index 00000000000..4e18980d01c
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/.gitlab-ci.yml
@@ -0,0 +1,28 @@
+workflow:
+ rules:
+ - if: $CI_MERGE_REQUEST_ID
+
+.rspec:
+ cache:
+ key: omniauth-salesforce
+ paths:
+ - vendor/gems/omniauth-salesforce/vendor/ruby
+ before_script:
+ - cd vendor/gems/omniauth-salesforce
+ - ruby -v # Print out ruby version for debugging
+ - gem install bundler --no-document # Bundler is not installed with the image
+ - bundle config set --local path 'vendor' # Install dependencies into ./vendor/ruby
+ - bundle config set with 'development'
+ - bundle config set --local frozen 'true' # Disallow Gemfile.lock changes on CI
+ - bundle config # Show bundler configuration
+ - bundle install -j $(nproc)
+ script:
+ - bundle exec rspec
+
+rspec-2.7:
+ image: "ruby:2.7"
+ extends: .rspec
+
+rspec-3.0:
+ image: "ruby:3.0"
+ extends: .rspec
diff --git a/vendor/gems/omniauth-salesforce/Gemfile b/vendor/gems/omniauth-salesforce/Gemfile
new file mode 100755
index 00000000000..0ac6c2141a7
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/Gemfile
@@ -0,0 +1,12 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in omniauth-salesforce.gemspec
+gemspec
+
+group :development, :test do
+ gem 'guard'
+ gem 'guard-rspec'
+ gem 'guard-bundler'
+ gem 'rb-fsevent'
+ gem 'growl'
+end
diff --git a/vendor/gems/omniauth-salesforce/Gemfile.lock b/vendor/gems/omniauth-salesforce/Gemfile.lock
new file mode 100644
index 00000000000..0317b16dd9f
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/Gemfile.lock
@@ -0,0 +1,124 @@
+PATH
+ remote: .
+ specs:
+ omniauth-salesforce (1.0.5)
+ omniauth (~> 2.0)
+ omniauth-oauth2 (~> 1.0)
+
+GEM
+ remote: https://rubygems.org/
+ specs:
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
+ coderay (1.1.3)
+ crack (0.4.5)
+ rexml
+ diff-lcs (1.5.0)
+ docile (1.4.0)
+ faraday (2.5.2)
+ faraday-net_http (>= 2.0, < 3.1)
+ ruby2_keywords (>= 0.0.4)
+ faraday-net_http (3.0.0)
+ ffi (1.15.5)
+ formatador (1.1.0)
+ growl (1.0.3)
+ guard (2.18.0)
+ formatador (>= 0.2.4)
+ listen (>= 2.7, < 4.0)
+ lumberjack (>= 1.0.12, < 2.0)
+ nenv (~> 0.1)
+ notiffany (~> 0.0)
+ pry (>= 0.13.0)
+ shellany (~> 0.0)
+ thor (>= 0.18.1)
+ guard-bundler (3.0.0)
+ bundler (>= 2.1, < 3)
+ guard (~> 2.2)
+ guard-compat (~> 1.1)
+ guard-compat (1.2.1)
+ guard-rspec (4.7.3)
+ guard (~> 2.1)
+ guard-compat (~> 1.1)
+ rspec (>= 2.99.0, < 4.0)
+ hashdiff (1.0.1)
+ hashie (5.0.0)
+ jwt (2.4.1)
+ listen (3.7.1)
+ rb-fsevent (~> 0.10, >= 0.10.3)
+ rb-inotify (~> 0.9, >= 0.9.10)
+ lumberjack (1.2.8)
+ method_source (1.0.0)
+ multi_xml (0.6.0)
+ nenv (0.3.0)
+ notiffany (0.1.3)
+ nenv (~> 0.1)
+ shellany (~> 0.0)
+ oauth2 (2.0.3)
+ faraday (>= 0.17.3, < 3.0)
+ jwt (>= 1.0, < 3.0)
+ multi_xml (~> 0.5)
+ rack (>= 1.2, < 3)
+ rash_alt (>= 0.4, < 1)
+ version_gem (~> 1.0)
+ omniauth (2.1.0)
+ hashie (>= 3.4.6)
+ rack (>= 2.2.3)
+ rack-protection
+ omniauth-oauth2 (1.7.3)
+ oauth2 (>= 1.4, < 3)
+ omniauth (>= 1.9, < 3)
+ pry (0.14.1)
+ coderay (~> 1.1)
+ method_source (~> 1.0)
+ public_suffix (5.0.0)
+ rack (2.2.4)
+ rack-protection (2.2.2)
+ rack
+ rack-test (2.0.2)
+ rack (>= 1.3)
+ rash_alt (0.4.12)
+ hashie (>= 3.4)
+ rb-fsevent (0.11.1)
+ rb-inotify (0.10.1)
+ ffi (~> 1.0)
+ rexml (3.2.5)
+ rspec (2.99.0)
+ rspec-core (~> 2.99.0)
+ rspec-expectations (~> 2.99.0)
+ rspec-mocks (~> 2.99.0)
+ rspec-core (2.99.2)
+ rspec-expectations (2.99.2)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.99.4)
+ ruby2_keywords (0.0.5)
+ shellany (0.0.1)
+ simplecov (0.21.2)
+ docile (~> 1.1)
+ simplecov-html (~> 0.11)
+ simplecov_json_formatter (~> 0.1)
+ simplecov-html (0.12.3)
+ simplecov_json_formatter (0.1.4)
+ thor (1.2.1)
+ version_gem (1.1.0)
+ webmock (3.18.1)
+ addressable (>= 2.8.0)
+ crack (>= 0.3.2)
+ hashdiff (>= 0.4.0, < 2.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ growl
+ guard
+ guard-bundler
+ guard-rspec
+ omniauth-salesforce!
+ rack-test
+ rb-fsevent
+ rspec (~> 2.7)
+ simplecov
+ webmock
+
+BUNDLED WITH
+ 2.3.21
diff --git a/vendor/gems/omniauth-salesforce/Guardfile b/vendor/gems/omniauth-salesforce/Guardfile
new file mode 100755
index 00000000000..2aaba26cc43
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/Guardfile
@@ -0,0 +1,10 @@
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+end
+
+guard 'bundler' do
+ watch('Gemfile')
+ watch('omniauth-salesforce.gemspec')
+end
diff --git a/vendor/gems/omniauth-salesforce/LICENSE.md b/vendor/gems/omniauth-salesforce/LICENSE.md
new file mode 100644
index 00000000000..e662c786216
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/LICENSE.md
@@ -0,0 +1,5 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/vendor/gems/omniauth-salesforce/README.md b/vendor/gems/omniauth-salesforce/README.md
new file mode 100755
index 00000000000..df59e99bc55
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/README.md
@@ -0,0 +1,60 @@
+# omniauth-salesforce
+
+This is fork of [omniauth-salesforce](https://github.com/realdoug/omniauth-salesforce) to support:
+
+1. OmniAuth v1 and v2. OmniAuth v2 disables GET requests by default
+ and defaults to POST. GitLab already has patched v1 to use POST,
+ but other dependencies need to be updated:
+ https://gitlab.com/gitlab-org/gitlab/-/issues/30073.
+
+There is active discussion with the gem owner (via email) about adding some GitLab employees as gem
+authors so tha they can push changes. If that happens, the updated/canonical gem
+should be used in favor of this vendored fork.
+
+[OmniAuth](https://github.com/intridea/omniauth) Strategy for [salesforce.com](salesforce.com).
+
+Note: This is a fork of the [original](https://github.com/richardvanhook/omniauth-salesforce) project and is now the main repository for the omniauth-salesforce gem.
+
+## See it in action
+
+[http://omniauth-salesforce-example.herokuapp.com](http://omniauth-salesforce-example.herokuapp.com)
+
+[Source for above app](https://github.com/richardvanhook/omniauth-salesforce-example)
+
+## Basic Usage
+
+```ruby
+require "sinatra"
+require "omniauth"
+require "omniauth-salesforce"
+
+class MyApplication < Sinatra::Base
+ use Rack::Session
+ use OmniAuth::Builder do
+ provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
+ end
+end
+```
+
+## Including other sites
+
+```ruby
+use OmniAuth::Builder do
+ provider :salesforce,
+ ENV['SALESFORCE_KEY'],
+ ENV['SALESFORCE_SECRET']
+ provider OmniAuth::Strategies::SalesforceSandbox,
+ ENV['SALESFORCE_SANDBOX_KEY'],
+ ENV['SALESFORCE_SANDBOX_SECRET']
+ provider OmniAuth::Strategies::SalesforcePreRelease,
+ ENV['SALESFORCE_PRERELEASE_KEY'],
+ ENV['SALESFORCE_PRERELEASE_SECRET']
+ provider OmniAuth::Strategies::DatabaseDotCom,
+ ENV['DATABASE_DOT_COM_KEY'],
+ ENV['DATABASE_DOT_COM_SECRET']
+end
+```
+
+## Resources
+
+* [Article: Digging Deeper into OAuth 2.0 on Force.com](http://wiki.developerforce.com/index.php/Digging_Deeper_into_OAuth_2.0_on_Force.com)
diff --git a/vendor/gems/omniauth-salesforce/Rakefile b/vendor/gems/omniauth-salesforce/Rakefile
new file mode 100755
index 00000000000..ca978a9cf0d
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/Rakefile
@@ -0,0 +1,12 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
+require 'rspec/core/rake_task'
+
+desc 'Default: run specs.'
+task :default => :spec
+
+desc "Run specs"
+RSpec::Core::RakeTask.new
+
+desc 'Run specs'
+task :default => :spec
diff --git a/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce.rb b/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce.rb
new file mode 100755
index 00000000000..20a5937d762
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce.rb
@@ -0,0 +1,2 @@
+require "omniauth-salesforce/version"
+require 'omniauth/strategies/salesforce'
diff --git a/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce/version.rb b/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce/version.rb
new file mode 100755
index 00000000000..51f0084840e
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/lib/omniauth-salesforce/version.rb
@@ -0,0 +1,5 @@
+module OmniAuth
+ module Salesforce
+ VERSION = "1.0.5"
+ end
+end
diff --git a/vendor/gems/omniauth-salesforce/lib/omniauth/strategies/salesforce.rb b/vendor/gems/omniauth-salesforce/lib/omniauth/strategies/salesforce.rb
new file mode 100755
index 00000000000..f2d811aeb9e
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/lib/omniauth/strategies/salesforce.rb
@@ -0,0 +1,97 @@
+require 'omniauth-oauth2'
+require 'openssl'
+require 'base64'
+
+module OmniAuth
+ module Strategies
+ class Salesforce < OmniAuth::Strategies::OAuth2
+
+ MOBILE_USER_AGENTS = 'webos|ipod|iphone|ipad|android|blackberry|mobile'
+
+ option :client_options, {
+ :site => 'https://login.salesforce.com',
+ :authorize_url => '/services/oauth2/authorize',
+ :token_url => '/services/oauth2/token'
+ }
+ option :authorize_options, [
+ :scope,
+ :display,
+ :immediate,
+ :state,
+ :prompt
+ ]
+
+ def request_phase
+ req = Rack::Request.new(@env)
+ options.update(req.params)
+ ua = req.user_agent.to_s
+ if !options.has_key?(:display)
+ mobile_request = ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
+ options[:display] = mobile_request ? 'touch' : 'page'
+ end
+ super
+ end
+
+ def auth_hash
+ signed_value = access_token.params['id'] + access_token.params['issued_at']
+ raw_expected_signature = OpenSSL::HMAC.digest('sha256', options.client_secret.to_s, signed_value)
+ expected_signature = Base64.strict_encode64 raw_expected_signature
+ signature = access_token.params['signature']
+ fail! "Salesforce user id did not match signature!" unless signature == expected_signature
+ super
+ end
+
+ uid { raw_info['id'] }
+
+ info do
+ {
+ 'name' => raw_info['display_name'],
+ 'email' => raw_info['email'],
+ 'nickname' => raw_info['nick_name'],
+ 'first_name' => raw_info['first_name'],
+ 'last_name' => raw_info['last_name'],
+ 'location' => '',
+ 'description' => '',
+ 'image' => raw_info['photos']['thumbnail'] + "?oauth_token=#{access_token.token}",
+ 'phone' => '',
+ 'urls' => raw_info['urls']
+ }
+ end
+
+ credentials do
+ hash = {'token' => access_token.token}
+ hash.merge!('instance_url' => access_token.params["instance_url"])
+ hash.merge!('refresh_token' => access_token.refresh_token) if access_token.refresh_token
+ hash
+ end
+
+ def raw_info
+ access_token.options[:mode] = :header
+ @raw_info ||= access_token.post(access_token['id']).parsed
+ end
+
+ extra do
+ raw_info.merge({
+ 'instance_url' => access_token.params['instance_url'],
+ 'pod' => access_token.params['instance_url'],
+ 'signature' => access_token.params['signature'],
+ 'issued_at' => access_token.params['issued_at']
+ })
+ end
+
+ end
+
+ class SalesforceSandbox < OmniAuth::Strategies::Salesforce
+ default_options[:client_options][:site] = 'https://test.salesforce.com'
+ end
+
+ class DatabaseDotCom < OmniAuth::Strategies::Salesforce
+ default_options[:client_options][:site] = 'https://login.database.com'
+ end
+
+ class SalesforcePreRelease < OmniAuth::Strategies::Salesforce
+ default_options[:client_options][:site] = 'https://prerellogin.pre.salesforce.com/'
+ end
+
+ end
+end
diff --git a/vendor/gems/omniauth-salesforce/omniauth-salesforce.gemspec b/vendor/gems/omniauth-salesforce/omniauth-salesforce.gemspec
new file mode 100755
index 00000000000..9c87746e9fd
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/omniauth-salesforce.gemspec
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/omniauth-salesforce/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Richard Vanhook"]
+ gem.email = ["rvanhook@salesforce.com"]
+ gem.description = %q{OmniAuth strategy for salesforce.com.}
+ gem.summary = %q{OmniAuth strategy for salesforce.com.}
+ gem.homepage = "https://github.com/realdoug/omniauth-salesforce"
+
+ gem.files = Dir.glob("lib/**/*.*")
+ gem.test_files = Dir.glob("spec/**/**/*.*")
+ gem.name = "omniauth-salesforce"
+ gem.require_paths = ["lib"]
+ gem.version = OmniAuth::Salesforce::VERSION
+ gem.license = "MIT"
+
+ gem.add_dependency 'omniauth', '~> 2.0'
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
+ gem.add_development_dependency 'rspec', '~> 2.7'
+ gem.add_development_dependency 'rack-test'
+ gem.add_development_dependency 'simplecov'
+ gem.add_development_dependency 'webmock'
+end
diff --git a/vendor/gems/omniauth-salesforce/spec/omniauth/strategies/salesforce_spec.rb b/vendor/gems/omniauth-salesforce/spec/omniauth/strategies/salesforce_spec.rb
new file mode 100755
index 00000000000..9b5afbdbe25
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/spec/omniauth/strategies/salesforce_spec.rb
@@ -0,0 +1,219 @@
+require 'spec_helper'
+
+describe OmniAuth::Strategies::Salesforce do
+ strategy = nil
+ before do
+ OmniAuth.config.test_mode = true
+ rack_app = []
+ rack_app.stub :call
+ strategy = OmniAuth::Strategies::Salesforce.new rack_app, 'Consumer Key', 'Consumer Secret'
+ end
+ describe "request_phase" do
+ env = nil
+ before do
+ env = {
+ 'rack.session' => {},
+ 'HTTP_USER_AGENT' => 'unknown',
+ 'REQUEST_METHOD' => 'GET',
+ 'rack.input' => '',
+ 'rack.url_scheme' => 'http',
+ 'SERVER_NAME' => 'server.example',
+ 'QUERY_STRING' => 'code=xxxx',
+ 'SCRIPT_NAME' => '',
+ 'SERVER_PORT' => 80
+ }
+ end
+ context "when using a mobile browser" do
+ user_agents = {
+ :Pre => "Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1",
+ :iPod => "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3",
+ :iPhone => "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3",
+ :iPad => "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10",
+ :Nexus => "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ :myTouch => "Mozilla/5.0 (Linux; U; Android 1.6; en-us; WOWMobile myTouch 3G Build/unknown) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1",
+ :Storm => "BlackBerry9530/4.7.0.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105",
+ :Torch => "Mozilla/5.0 (BlackBerry; U; BlackBerry 9810; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+",
+ :generic_mobile => "some mobile device"
+ }
+ user_agents.each_pair do |name, agent|
+ context "with the user agent from a #{name.to_s}" do
+ before do
+ env['HTTP_USER_AGENT'] = agent
+ strategy.call!(env)
+ strategy.request_phase
+ end
+ subject {strategy.options}
+ it "sets the :display option to 'touch'" do
+ subject[:display].should == 'touch'
+ end
+ end
+ end
+ end
+ context "when using a desktop browser" do
+ user_agents = {
+ :Chrome => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21",
+ :Safari => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
+ :IE => "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
+ :anything_else => "unknown"
+ }
+ user_agents.each_pair do |name, agent|
+ context "with the user agent from #{name.to_s}" do
+ before do
+ env['HTTP_USER_AGENT'] = agent
+ strategy.call!(env)
+ strategy.request_phase
+ end
+ subject {strategy.options}
+ it "sets the :display option to 'page'" do
+ subject[:display].should == 'page'
+ end
+ end
+ end
+ end
+ end
+ describe "callback phase" do
+ raw_info = nil
+ before do
+ raw_info = {
+ 'id' => 'salesforce id',
+ 'display_name' => 'display name',
+ 'email' => 'email',
+ 'nick_name' => 'nick name',
+ 'first_name' => 'first name',
+ 'last_name' => 'last name',
+ 'photos' => {'thumbnail' => '/thumbnail/url'},
+ 'urls'=> {
+ "enterprise" => "https://salesforce.example/services",
+ "metadata" => "https://salesforce.example/services"
+ }
+ }
+ client = OAuth2::Client.new 'id', 'secret', {:site => 'example.com'}
+ access_token = OAuth2::AccessToken.from_hash client, {
+ 'access_token' => 'token',
+ 'instance_url' => 'http://instance.salesforce.example',
+ 'signature' => 'invalid',
+ 'issued_at' => '1296458209517'
+ }
+ strategy.stub(:raw_info) { raw_info }
+ strategy.stub(:access_token) { access_token }
+ end
+ describe "uid" do
+ it "sets the id" do
+ strategy.uid.should == raw_info['id']
+ end
+ end
+ describe "info" do
+ subject { strategy.info }
+ it "returns an info hash" do
+ subject.should_not be_nil
+ end
+ it "sets name" do
+ subject['name'].should == raw_info['display_name']
+ end
+ it "sets email" do
+ subject['email'].should == raw_info['email']
+ end
+ it "sets nickname" do
+ subject['nickname'].should == raw_info['nick_name']
+ end
+ it "sets first_name" do
+ subject['first_name'].should == raw_info['first_name']
+ end
+ it "sets last_name" do
+ subject['last_name'].should == raw_info['last_name']
+ end
+ it "sets location" do
+ subject['location'].should == ''
+ end
+ it "sets description" do
+ subject['description'].should == ''
+ end
+ it "sets image" do
+ subject['image'].should == raw_info['photos']['thumbnail'] + "?oauth_token=#{strategy.access_token.token}"
+ end
+ it "sets phone" do
+ subject['phone'].should == ''
+ end
+ it "sets urls" do
+ subject['urls'].should == raw_info['urls']
+ end
+ end
+ describe "credentials" do
+ subject { strategy.credentials }
+ it "sets token" do
+ subject['token'].should == strategy.access_token.token
+ end
+ it "sets instance_url" do
+ subject['instance_url'].should == strategy.access_token.params["instance_url"]
+ end
+ context "given a refresh token" do
+ it "sets refresh_token" do
+ subject['refresh_token'].should == strategy.access_token.refresh_token
+ end
+ end
+ context "when not given a refresh token" do
+ it "does not set a refresh token" do
+ subject['refresh_token'].should be_nil
+ end
+ end
+ end
+ describe "extra" do
+ subject { strategy.extra }
+ it "sets instance_url" do
+ subject['instance_url'].should == strategy.access_token.params['instance_url']
+ end
+ it "sets pod" do
+ subject['pod'].should == strategy.access_token.params['instance_url']
+ end
+ it "sets signature" do
+ subject['signature'].should == strategy.access_token.params['signature']
+ end
+ it "sets issued_at" do
+ subject['issued_at'].should == strategy.access_token.params['issued_at']
+ end
+ end
+ describe "user id validation" do
+ client_id = nil
+ issued_at = nil
+ signature = nil
+ instance_url = 'http://instance.salesforce.example'
+ before do
+ client_id = "https://login.salesforce.com/id/00Dd0000000d45TEBQ/005d0000000fyGPCCY"
+ issued_at = "1331142541514"
+ signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', strategy.options.client_secret.to_s, client_id + issued_at))
+ end
+ context "when the signature does not match" do
+ before do
+ access_token = OAuth2::AccessToken.from_hash strategy.access_token.client, {
+ 'id' => 'forged client id',
+ 'refresh_token' => 'anything',
+ 'issued_at' => issued_at,
+ 'instance_url' => 'http://instance.salesforce.example',
+ 'signature' => signature
+ }
+ strategy.stub(:access_token) { access_token }
+ end
+ it "should call fail!" do
+ strategy.should_receive(:fail!)
+ strategy.auth_hash
+ end
+ end
+ context "when the signature does match" do
+ before do
+ access_token = OAuth2::AccessToken.from_hash strategy.access_token.client, {
+ 'id' => client_id,
+ 'refresh_token' => 'anything',
+ 'issued_at' => issued_at,
+ 'instance_url' => 'http://instance.salesforce.example',
+ 'signature' => signature
+ }
+ strategy.stub(:access_token) { access_token }
+ end
+ it "should not fail" do
+ strategy.should_not_receive(:fail!)
+ strategy.auth_hash
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/gems/omniauth-salesforce/spec/spec_helper.rb b/vendor/gems/omniauth-salesforce/spec/spec_helper.rb
new file mode 100755
index 00000000000..0b00358fa05
--- /dev/null
+++ b/vendor/gems/omniauth-salesforce/spec/spec_helper.rb
@@ -0,0 +1,16 @@
+$:.unshift File.expand_path('..', __FILE__)
+$:.unshift File.expand_path('../../lib', __FILE__)
+require 'simplecov'
+SimpleCov.start
+require 'rspec'
+require 'rack/test'
+require 'webmock/rspec'
+require 'omniauth'
+require 'omniauth-salesforce'
+
+RSpec.configure do |config|
+ config.include WebMock::API
+ config.include Rack::Test::Methods
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
+end
+