omniauth-bookingsync 0.3.1 → 0.4.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: df17b738000344d67445ce81236c1ec2e068cf4e
4
- data.tar.gz: c8a9705d350b64234ea4d4e7de76ce6b6a108dfb
3
+ metadata.gz: bae9c4da86dca7f00aaad6b49d0e0186238f7aa7
4
+ data.tar.gz: 79f7916e128c0a8caacf5d6db9aabb61fcd2bc7d
5
5
  SHA512:
6
- metadata.gz: 8a48828bfdb7baa312b046daac5e22a5a3f9f7baa5bf1152f73d8f1558e13dbe926cbfce98de79fc7150cd8572dafb0236297ab70433209b1ac5c7a57c3b1bc4
7
- data.tar.gz: e04b5c0986428aecc1d542a7e0340594d05f03860fb1040179bcec02fe92b1f05c37264ad959a9b13162d6a888d70837b7a09f29b28a7a44cf5bbdcafe969b3f
6
+ metadata.gz: f9252f455c913e3ef984340dfa1b57f31dfc13d201717006148e8e05fedb57cf9b952dee7cdeedcfd9e1a2108baf43ce802956546552e4033959cb7eb16e2b98
7
+ data.tar.gz: 7627343b15c0af7b6f07ccbb44b72ea218ac34adb2385f4955fa37ed27a1a4ed0856179cc7a16925da4b758ccbd449bf70e8bf990e1fd28d04f42a0a7bd612f5
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  .rbx
7
7
  .rvmrc
8
8
  .yardoc
9
+ .ruby-version
9
10
  bin
10
11
  coverage*
11
12
  doc
@@ -15,3 +16,4 @@ rdoc
15
16
  rerun.txt
16
17
  tags
17
18
  tmp
19
+ example/.powenv
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ before_install:
4
+ - gem install bundler
5
+ - gem update bundler
3
6
  rvm:
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
+ - 2.2.5
8
+ - 2.3.1
7
9
  - ruby-head
8
- - jruby
10
+ - jruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  #master
2
2
 
3
+ * bump oauth2 to 1.2
4
+ * add Ruby 2.3.1 to travis, drop Ruby 2.0 and 2.1 (end of maintenance)
5
+ * Update example application to work over SSL
6
+
3
7
  # 0.3.1
4
8
 
5
9
  * Lock oauth2 version to 1.0 due to 1.1 having some breaking changes
data/Gemfile.lock CHANGED
@@ -1,63 +1,62 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-bookingsync (0.3.1)
5
- oauth2 (= 1.0)
4
+ omniauth-bookingsync (0.4.0)
5
+ oauth2 (~> 1.2.0)
6
6
  omniauth (~> 1.1)
7
7
  omniauth-oauth2 (< 1.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- ast (2.1.0)
13
- astrolabe (1.3.1)
14
- parser (~> 2.2)
12
+ ast (2.3.0)
15
13
  diff-lcs (1.2.5)
16
14
  faraday (0.9.2)
17
15
  multipart-post (>= 1.2, < 3)
18
- hashie (3.4.3)
19
- jwt (1.5.2)
20
- multi_json (1.11.2)
16
+ hashie (3.4.4)
17
+ jwt (1.5.4)
18
+ multi_json (1.12.1)
21
19
  multi_xml (0.5.5)
22
20
  multipart-post (2.0.0)
23
- oauth2 (1.0.0)
21
+ oauth2 (1.2.0)
24
22
  faraday (>= 0.8, < 0.10)
25
23
  jwt (~> 1.0)
26
24
  multi_json (~> 1.3)
27
25
  multi_xml (~> 0.5)
28
- rack (~> 1.2)
26
+ rack (>= 1.2, < 3)
29
27
  omniauth (1.3.1)
30
28
  hashie (>= 1.2, < 4)
31
29
  rack (>= 1.0, < 3)
32
30
  omniauth-oauth2 (1.3.1)
33
31
  oauth2 (~> 1.0)
34
32
  omniauth (~> 1.2)
35
- parser (2.2.2.6)
36
- ast (>= 1.1, < 3.0)
33
+ parser (2.3.1.2)
34
+ ast (~> 2.2)
37
35
  powerpack (0.1.1)
38
- rack (1.6.4)
39
- rainbow (2.0.0)
40
- rake (10.4.2)
41
- rspec (3.3.0)
42
- rspec-core (~> 3.3.0)
43
- rspec-expectations (~> 3.3.0)
44
- rspec-mocks (~> 3.3.0)
45
- rspec-core (3.3.2)
46
- rspec-support (~> 3.3.0)
47
- rspec-expectations (3.3.1)
36
+ rack (2.0.1)
37
+ rainbow (2.1.0)
38
+ rake (11.2.2)
39
+ rspec (3.5.0)
40
+ rspec-core (~> 3.5.0)
41
+ rspec-expectations (~> 3.5.0)
42
+ rspec-mocks (~> 3.5.0)
43
+ rspec-core (3.5.2)
44
+ rspec-support (~> 3.5.0)
45
+ rspec-expectations (3.5.0)
48
46
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.3.0)
50
- rspec-mocks (3.3.2)
47
+ rspec-support (~> 3.5.0)
48
+ rspec-mocks (3.5.0)
51
49
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.3.0)
53
- rspec-support (3.3.0)
54
- rubocop (0.34.1)
55
- astrolabe (~> 1.3)
56
- parser (>= 2.2.2.5, < 3.0)
50
+ rspec-support (~> 3.5.0)
51
+ rspec-support (3.5.0)
52
+ rubocop (0.42.0)
53
+ parser (>= 2.3.1.1, < 3.0)
57
54
  powerpack (~> 0.1)
58
55
  rainbow (>= 1.99.1, < 3.0)
59
- ruby-progressbar (~> 1.4)
60
- ruby-progressbar (1.7.5)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (~> 1.0, >= 1.0.1)
58
+ ruby-progressbar (1.8.1)
59
+ unicode-display_width (1.1.0)
61
60
 
62
61
  PLATFORMS
63
62
  ruby
@@ -69,4 +68,4 @@ DEPENDENCIES
69
68
  rubocop
70
69
 
71
70
  BUNDLED WITH
72
- 1.10.6
71
+ 1.12.5
data/README.md CHANGED
@@ -36,14 +36,14 @@ this will skip the account selection process and show the accept/deny page.
36
36
 
37
37
  ## Supported Rubies
38
38
 
39
- OmniAuth BookingSync is tested under 2.0, 2.1, 2.2, Ruby-head, JRuby.
39
+ OmniAuth BookingSync is tested under 2.2, 2.3, Ruby-head, JRuby.
40
40
 
41
41
  [![CI Build
42
42
  Status](https://secure.travis-ci.org/BookingSync/omniauth-bookingsync.png)](http://travis-ci.org/BookingSync/omniauth-bookingsync)
43
43
 
44
44
  ## License
45
45
 
46
- Copyright (c) 2014 Sébastien Grosjean and [BookingSync.com](http://www.bookingsync.com)
46
+ Copyright (c) 2014-present Sébastien Grosjean and [BookingSync.com](http://www.bookingsync.com)
47
47
 
48
48
  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:
49
49
 
@@ -0,0 +1,3 @@
1
+ export BOOKINGSYNC_CLIENT_ID=""
2
+ export BOOKINGSYNC_CLIENT_SECRET=""
3
+ export BOOKINGSYNC_SCOPE=""
@@ -0,0 +1,45 @@
1
+ GEM
2
+ specs:
3
+ faraday (0.9.2)
4
+ multipart-post (>= 1.2, < 3)
5
+ hashie (3.4.3)
6
+ json (1.8.3)
7
+ jwt (1.5.4)
8
+ multi_json (1.11.2)
9
+ multi_xml (0.5.5)
10
+ multipart-post (2.0.0)
11
+ oauth2 (1.0.0)
12
+ faraday (>= 0.8, < 0.10)
13
+ jwt (~> 1.0)
14
+ multi_json (~> 1.3)
15
+ multi_xml (~> 0.5)
16
+ rack (~> 1.2)
17
+ omniauth (1.3.1)
18
+ hashie (>= 1.2, < 4)
19
+ rack (>= 1.0, < 3)
20
+ omniauth-bookingsync (0.3.1)
21
+ oauth2 (= 1.0)
22
+ omniauth (~> 1.1)
23
+ omniauth-oauth2 (< 1.4)
24
+ omniauth-oauth2 (1.3.1)
25
+ oauth2 (~> 1.0)
26
+ omniauth (~> 1.2)
27
+ rack (1.6.4)
28
+ rack-protection (1.5.3)
29
+ rack
30
+ sinatra (1.4.6)
31
+ rack (~> 1.4)
32
+ rack-protection (~> 1.4)
33
+ tilt (>= 1.3, < 3)
34
+ tilt (2.0.5)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ json
41
+ omniauth-bookingsync
42
+ sinatra
43
+
44
+ BUNDLED WITH
45
+ 1.12.5
data/example/ReadMe.md CHANGED
@@ -5,12 +5,34 @@ This is specially useful to play around BookingSync API v3.
5
5
 
6
6
  ## Usage
7
7
 
8
+ ### Requirements:
9
+
10
+ [POW](http://pow.cx/) - To run this Sinatra application.
11
+ [Tunnelss](https://github.com/rchampourlier/tunnelss) - To use SSL
12
+
13
+ _Note: Tricks for [persiting SSL with Tunnelss over reboot](http://www.sebgrosjean.com/en/news/2014/2/9/rails-with-ssl-in-development-with-pow-and-tunnels)_
14
+
15
+ ### 1) Install dependencies
16
+
17
+ ```sh
18
+ bundle install
8
19
  ```
9
- $ bundle install
10
- $ bundle exec ruby bookingsync_oauth_helper.rb
20
+
21
+ ### 2) Setup your BookingSync Application credentials
22
+
23
+ ```sh
24
+ cp .powenv.sample .powenv
11
25
  ```
12
26
 
13
- Follow the guide until you get your OAuth Token back.
27
+ Edit the `BOOKINGSYNC_CLIENT_ID`, `BOOKINGSYNC_CLIENT_SECRET` and `BOOKINGSYNC_SCOPE` environment variables from the `.powenv` file.
28
+
29
+ ### 3) Restart Pow
30
+
31
+ Make sure to restart Pow, using:
32
+
33
+ ```sh
34
+ touch tmp/restart.txt
35
+ ```
14
36
 
15
37
  You can then use the [BookingSync API gem](https://github.com/BookingSync/bookingsync-api) to consume the API
16
38
 
@@ -25,7 +47,7 @@ api.rentals.first.name
25
47
 
26
48
  ## License
27
49
 
28
- Copyright (c) 2014 Sébastien Grosjean and [BookingSync.com](http://www.bookingsync.com)
50
+ Copyright (c) 2014-present Sébastien Grosjean and [BookingSync.com](http://www.bookingsync.com)
29
51
 
30
52
  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:
31
53
 
@@ -1,36 +1,13 @@
1
1
  require "sinatra"
2
- require "omniauth-bookingsync"
3
2
  require "json"
4
-
5
- puts "-" * 60
6
- puts "BookingSync OAuth helper for API v3".center(60)
7
- puts "-" * 60
8
- puts ""
9
- puts "Requirements:"
10
- puts " => Create a BookingSync Application from"
11
- puts " https://www.bookingsync.com/en/partners/applications"
12
- puts ""
13
- puts " => Use http://localhost:4567/auth/bookingsync/callback as return URL"
14
- puts ""
15
- puts "Enter your Application's Client ID"
16
- set :client_id, gets.strip
17
- puts ""
18
- puts "Enter your Application's Client Secret"
19
- set :client_secret, gets.strip
20
- puts ""
21
- puts "Enter your desired scopes (space separated)"
22
- set :scope, gets.strip
23
- puts "-" * 60
24
- puts "Visit http://localhost:4567".center(60)
25
- puts "-" * 60
26
- puts "Press CMD + C to stop"
27
- puts ""
3
+ require "omniauth-bookingsync"
28
4
 
29
5
  use Rack::Session::Cookie
30
6
 
31
7
  use OmniAuth::Builder do
32
- provider :bookingsync, settings.client_id, settings.client_secret,
33
- scope: settings.scope
8
+ provider :bookingsync, ENV['BOOKINGSYNC_CLIENT_ID'], ENV['BOOKINGSYNC_CLIENT_SECRET'], {
9
+ scope: ENV['BOOKINGSYNC_SCOPE']
10
+ }
34
11
  end
35
12
 
36
13
  get "/" do
@@ -66,7 +43,6 @@ HTML
66
43
  end
67
44
 
68
45
  get "/auth/:provider/callback" do
69
- content_type "application/json"
70
46
  request.env["omniauth.auth"].to_hash.to_json
71
47
  end
72
48
 
data/example/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require './bookingsync_oauth_helper'
6
+
7
+ run Sinatra::Application
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module BookingSync
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -30,6 +30,8 @@ module OmniAuth
30
30
  end
31
31
  end
32
32
 
33
- OAuth2::Response::CONTENT_TYPES["application/vnd.api+json"] ||= :json
33
+ OAuth2::Response.register_parser(:json, ["application/vnd.api+json"]) do |body|
34
+ MultiJson.load(body) rescue body # rubocop:disable RescueModifier
35
+ end
34
36
 
35
37
  OmniAuth.config.add_camelization "bookingsync", "BookingSync"
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  # this constraint is to change in 1.4 breaking redirect url generation
21
21
  # https://github.com/intridea/omniauth-oauth2/issues/81
22
22
  gem.add_dependency "omniauth-oauth2", "< 1.4"
23
- gem.add_dependency "oauth2", "1.0"
23
+ gem.add_dependency "oauth2", "~> 1.2.0"
24
24
 
25
25
  gem.add_development_dependency "rspec"
26
26
  gem.add_development_dependency "rake"
@@ -45,12 +45,37 @@ describe OmniAuth::Strategies::BookingSync do
45
45
  end
46
46
 
47
47
  describe '#raw_info' do
48
- it "fetches account info from api v3" do
48
+ let(:body) { '{"accounts": [{"id": 1}]}' }
49
+ let(:response) { double("response", headers: headers, status: 200, body: body) }
50
+
51
+ before do
49
52
  allow(subject).to receive(:access_token).and_return(double)
50
- response = double(parsed: { "accounts" => [{ "id" => 1 }] })
51
53
  expect(subject.access_token).to receive(:get).with("/api/v3/accounts")
52
- .and_return(response)
53
- expect(subject.raw_info).to eq("id" => 1)
54
+ .and_return(OAuth2::Response.new(response))
55
+ end
56
+
57
+ context "when Content-Type not supported" do
58
+ let(:headers) { { "Content-Type" => "application/foo-bar" } }
59
+
60
+ it "blows up with NoMethodError" do
61
+ expect { subject.raw_info }.to raise_error(NoMethodError)
62
+ end
63
+ end
64
+
65
+ context "when Content-Type supported" do
66
+ let(:headers) { { "Content-Type" => "application/vnd.api+json" } }
67
+
68
+ it "fetches account info from api v3" do
69
+ expect(subject.raw_info).to eq("id" => 1)
70
+ end
71
+ end
72
+
73
+ context "when Content-Type supported" do
74
+ let(:headers) { { "Content-Type" => "application/json" } }
75
+
76
+ it "fetches account info from api v3" do
77
+ expect(subject.raw_info).to eq("id" => 1)
78
+ end
54
79
  end
55
80
  end
56
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-bookingsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Grosjean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-02 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: oauth2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: 1.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: 1.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -111,9 +111,12 @@ files:
111
111
  - Gemfile.lock
112
112
  - README.md
113
113
  - Rakefile
114
+ - example/.powenv.sample
114
115
  - example/Gemfile
116
+ - example/Gemfile.lock
115
117
  - example/ReadMe.md
116
118
  - example/bookingsync_oauth_helper.rb
119
+ - example/config.ru
117
120
  - lib/omniauth-bookingsync.rb
118
121
  - lib/omniauth/bookingsync/version.rb
119
122
  - lib/omniauth/strategies/bookingsync.rb
@@ -140,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  version: '0'
141
144
  requirements: []
142
145
  rubyforge_project:
143
- rubygems_version: 2.4.3
146
+ rubygems_version: 2.5.1
144
147
  signing_key:
145
148
  specification_version: 4
146
149
  summary: An OmniAuth 1.0 strategy for BookingSync OAuth2 identification.