omniauth-zendesk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,15 +26,20 @@ module OmniAuth
26
26
  extra { { raw_info: identity } }
27
27
 
28
28
  def request_phase
29
- return callback_phase if site && username && password
30
- OmniAuth::Form.build(
31
- title: (options[:title] || "Zendesk Authentication"),
32
- url: callback_path
33
- ) do |f|
34
- f.text_field 'Username', options.params.username
35
- f.password_field 'Password', options.params.password
36
- f.text_field 'Zendesk Site', options.params.site
37
- end.to_response
29
+ if site && username && password
30
+ r = Rack::Response.new
31
+ r.redirect(callback_path, 307)
32
+ r.finish
33
+ else
34
+ OmniAuth::Form.build(
35
+ title: (options[:title] || "Zendesk Authentication"),
36
+ url: callback_path
37
+ ) do |f|
38
+ f.text_field 'Username', options.params.username
39
+ f.password_field 'Password', options.params.password
40
+ f.text_field 'Zendesk Site', options.params.site
41
+ end.to_response
42
+ end
38
43
  end
39
44
 
40
45
  def callback_phase
@@ -68,9 +73,7 @@ module OmniAuth
68
73
  def uri?(uri)
69
74
  uri = URI.parse(uri)
70
75
  uri.scheme == 'https'
71
- rescue URI::BadURIError
72
- false
73
- rescue URI::InvalidURIError
76
+ rescue
74
77
  false
75
78
  end
76
79
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Zendesk
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -39,7 +39,7 @@ describe OmniAuth::Strategies::Zendesk do
39
39
  end
40
40
 
41
41
  it 'should populate the auth hash' do
42
- auth_hash.should be_kind_of(Hash)
42
+ last_response.headers["Location"].should == '/auth/zendesk/callback'
43
43
  end
44
44
  end
45
45
  end
@@ -70,10 +70,15 @@ describe OmniAuth::Strategies::Zendesk do
70
70
  OmniAuth.config.on_failure = lambda{|env| [401, {}, [env['omniauth.error.type'].inspect]]}
71
71
  stub_request(:get, "https://wrong%40example.com:login@my.zendesk.com/api/v2/users/me").
72
72
  to_return(status: 200, body: File.new(File.dirname(__FILE__) + '/../../fixtures/anonymous.json'), headers: {content_type: "application/json; charset=utf-8"})
73
- post '/auth/zendesk/callback', email: 'wrong@example.com', password: 'login', site: 'my'
74
73
  end
75
-
74
+
76
75
  it 'should fail with :invalid_credentials' do
76
+ post '/auth/zendesk/callback', email: 'wrong@example.com', password: 'login', site: 'my'
77
+ last_response.body.should == ':invalid_credentials'
78
+ end
79
+
80
+ it 'should fail if no/wrong site provided' do
81
+ post '/auth/zendesk/callback', email: 'wrong@example.com', password: 'login'
77
82
  last_response.body.should == ':invalid_credentials'
78
83
  end
79
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-zendesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -3124490689275656540
145
+ hash: -1961441658039726598
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements:
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -3124490689275656540
154
+ hash: -1961441658039726598
155
155
  requirements: []
156
156
  rubyforge_project:
157
157
  rubygems_version: 1.8.24