zendesk_remote_auth 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -3,11 +3,16 @@
3
3
  zendesk_remote_auth is a simple gem providing help with Zendesk's SSO
4
4
  functionality (see http://www.zendesk.com/api/remote_authentication).
5
5
 
6
+ == HEY YOU!
7
+
8
+ Do you actually use this gem? Are you interested in taking it over?
9
+ I no longer use this, so don't have a lot of interest in maintaining it.
10
+ If you do, get in touch.
11
+
6
12
  == Installation and Setup
7
13
 
8
14
  * Install:
9
-
10
- gem install tobias-zendesk_remote_auth
15
+ gem install zendesk_remote_auth
11
16
 
12
17
  * Setup:
13
18
  You will need to give the gem your token and authentication url,
@@ -16,10 +21,12 @@ perhaps in an initializer:
16
21
  Zendesk::RemoteAuth.auth_url = 'https://yourcompany.zendesk.com/access/remote/'
17
22
 
18
23
  and config the gem in environment.rb (if using rails):
19
- config.gem 'tobias-zendesk_remote_auth', :lib => 'zendesk_remote_auth', :source => http://gems.github.com'
24
+ config.gem 'zendesk_remote_auth'
20
25
 
21
26
  == Usage
22
27
 
28
+ Note: The latest release requires ActiveSupport 3.0 or greater.
29
+
23
30
  Mixin the Zendesk::RemoteAuthHelper module wherever needed, then call:
24
31
  zendesk_remote_auth_url(:name => 'user name',
25
32
  :email => 'user email',
@@ -86,4 +93,4 @@ zendesk:
86
93
 
87
94
  == Copyright
88
95
 
89
- Copyright (c) 2009 Tobias Crawley. See LICENSE for details.
96
+ Copyright (c) 2011 Tobias Crawley. See LICENSE for details.
data/Rakefile CHANGED
@@ -10,9 +10,8 @@ begin
10
10
  gem.email = "tcrawley@gmail.com"
11
11
  gem.homepage = "http://github.com/tobias/zendesk_remote_auth"
12
12
  gem.authors = ["Tobias Crawley"]
13
- gem.add_development_dependency "thoughtbot-shoulda"
14
- gem.add_development_dependency "mocha"
15
- gem.add_development_dependency "matchy"
13
+ gem.add_dependency "active_support", ">= 3.0.0"
14
+ gem.add_development_dependency "rspec", ">= 2.6.0"
16
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
16
  end
18
17
  Jeweler::GemcutterTasks.new
@@ -20,29 +19,18 @@ rescue LoadError
20
19
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
20
  end
22
21
 
23
- require 'rake/testtask'
24
- Rake::TestTask.new(:test) do |test|
25
- test.libs << 'lib' << 'test'
26
- test.pattern = 'test/**/*_test.rb'
27
- test.verbose = true
22
+ require 'rspec/core'
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new(:spec) do |spec|
25
+ spec.pattern = FileList['spec/**/*_spec.rb']
28
26
  end
29
27
 
30
- begin
31
- require 'rcov/rcovtask'
32
- Rcov::RcovTask.new do |test|
33
- test.libs << 'test'
34
- test.pattern = 'test/**/*_test.rb'
35
- test.verbose = true
36
- end
37
- rescue LoadError
38
- task :rcov do
39
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
- end
28
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
41
31
  end
42
32
 
43
- task :test => :check_dependencies
44
-
45
- task :default => :test
33
+ task :default => :spec
46
34
 
47
35
  begin
48
36
  require 'yard'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 1.0.0
@@ -1,5 +1,5 @@
1
1
  require 'digest/md5'
2
- require 'active_support' #gives us Hash.to_query
2
+ require 'active_support/core_ext/object' #gives us Hash.to_query
3
3
 
4
4
  ##
5
5
  # Provides a helper to use Zendesk's SSO/remote auth service.
@@ -73,6 +73,7 @@ module Zendesk
73
73
  str_to_hash << params[:email]
74
74
  str_to_hash << params[:external_id].to_s if params[:external_id]
75
75
  str_to_hash << params[:organization].to_s if params[:organization]
76
+ str_to_hash << params[:remote_photo_url].to_s if params[:remote_photo_url]
76
77
  str_to_hash << token
77
78
  str_to_hash << params[:timestamp].to_s
78
79
  Digest::MD5.hexdigest(str_to_hash)
@@ -1,12 +1,4 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
- require 'matchy'
6
-
7
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
3
  require 'zendesk_remote_auth'
10
4
 
11
- class Test::Unit::TestCase
12
- end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zendesk::RemoteAuth do
4
+
5
+ before(:each) do
6
+ @auth = Object.new
7
+ @auth.extend(Zendesk::RemoteAuthHelper)
8
+ end
9
+
10
+ context 'RemoteAuth' do
11
+ before(:each) do
12
+ Zendesk::RemoteAuth.token = Zendesk::RemoteAuth.auth_url = nil
13
+ end
14
+
15
+ it 'should raise exception if token is not set' do
16
+ lambda{ Zendesk::RemoteAuth.token }.should raise_error(ArgumentError)
17
+ end
18
+
19
+ it 'should return the token without exception if it is set' do
20
+ Zendesk::RemoteAuth.token = 'blah'
21
+ Zendesk::RemoteAuth.token.should == 'blah'
22
+ end
23
+
24
+
25
+ it 'should raise exception if auth_url is not set' do
26
+ lambda { Zendesk::RemoteAuth.auth_url }.should raise_error(ArgumentError)
27
+ end
28
+
29
+ it 'should return the auth_url without exception if it is set' do
30
+ Zendesk::RemoteAuth.auth_url = 'blah'
31
+ Zendesk::RemoteAuth.auth_url.should == 'blah'
32
+ end
33
+ end
34
+
35
+
36
+ context 'url generation' do
37
+ before(:each) do
38
+ Zendesk::RemoteAuth.token = 'the_token'
39
+ Zendesk::RemoteAuth.auth_url = 'the_url'
40
+ @valid_params = { :email => 'test@example.com', :name => 'blah'}
41
+ end
42
+
43
+ context 'required fields' do
44
+ it 'should raise an argument error the name is not provided' do
45
+ lambda {
46
+ @valid_params.delete(:name)
47
+ @auth.zendesk_remote_auth_url(@valid_params)
48
+ }.should raise_error(ArgumentError)
49
+ end
50
+
51
+ it 'should raise an argument error the email is not provided' do
52
+ lambda {
53
+ @valid_params.delete(:email)
54
+ @auth.zendesk_remote_auth_url(@valid_params)
55
+ }.should raise_error(ArgumentError)
56
+ end
57
+
58
+ end
59
+
60
+ it 'should return a url that starts with the auth_url' do
61
+ @auth.zendesk_remote_auth_url(@valid_params)
62
+ end
63
+
64
+ it 'should have an empty hash param if external_id not provided' do
65
+ @auth.zendesk_remote_auth_url(@valid_params).should =~ /hash=(&|$)/
66
+ end
67
+
68
+ it 'should have a hash param if external_id provided' do
69
+ @auth.zendesk_remote_auth_url(@valid_params.merge(:external_id => 'id')).should_not =~ /hash=(&|$)/
70
+ end
71
+
72
+ it 'should have a different hash param if external_id and remote_photo_url provided ' do
73
+ a=@auth.zendesk_remote_auth_url(@valid_params.merge(:external_id => 'id')).match(/(hash=[^&]*)/)[1]
74
+ b=@auth.zendesk_remote_auth_url(@valid_params.merge(:external_id => 'id', :remote_photo_url => 'photo_url')).match(/(hash=[^&]*)/)[1]
75
+ a.should_not == b
76
+ end
77
+
78
+ context 'given a user object' do
79
+ before(:each) do
80
+ @user = mock
81
+ @user.should_receive(:name).and_return('a_name')
82
+ @user.should_receive(:email).and_return('an_email')
83
+ end
84
+
85
+ it 'should pull the name from the user' do
86
+ @auth.zendesk_remote_auth_url(@user).should =~ /name=a_name/
87
+ end
88
+
89
+ it 'should pull the email from the user' do
90
+ @auth.zendesk_remote_auth_url(@user).should =~ /email=an_email/
91
+ end
92
+
93
+ it 'should pull the id from the user' do
94
+ @user.should_receive(:id).and_return('an_id')
95
+ @auth.zendesk_remote_auth_url(@user).should =~ /external_id=an_id/
96
+ end
97
+
98
+ it 'should pull the organization from the user if available' do
99
+ @user.should_receive(:zendesk_organization).and_return('org')
100
+ @auth.zendesk_remote_auth_url(@user).should =~ /organization=org/
101
+ end
102
+
103
+ end
104
+ end
105
+ end
@@ -1,59 +1,48 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zendesk_remote_auth}
8
- s.version = "0.9.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tobias Crawley"]
12
- s.date = %q{2009-10-01}
11
+ s.authors = [%q{Tobias Crawley}]
12
+ s.date = %q{2011-09-11}
13
13
  s.description = %q{See the README.}
14
14
  s.email = %q{tcrawley@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/zendesk_remote_auth.rb",
27
- "test/test_helper.rb",
28
- "test/zendesk_remote_auth_test.rb",
29
- "zendesk_remote_auth.gemspec"
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/zendesk_remote_auth.rb",
26
+ "zendesk_remote_auth.gemspec"
30
27
  ]
31
28
  s.homepage = %q{http://github.com/tobias/zendesk_remote_auth}
32
- s.rdoc_options = ["--charset=UTF-8"]
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.5}
29
+ s.require_paths = [%q{lib}]
30
+ s.rubygems_version = %q{1.8.4}
35
31
  s.summary = %q{Helper for Zendesk SSO/remote authentication}
36
- s.test_files = [
37
- "test/test_helper.rb",
38
- "test/zendesk_remote_auth_test.rb"
39
- ]
40
32
 
41
33
  if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
34
  s.specification_version = 3
44
35
 
45
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
- s.add_development_dependency(%q<mocha>, [">= 0"])
48
- s.add_development_dependency(%q<matchy>, [">= 0"])
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<active_support>, [">= 3.0.0"])
38
+ s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
49
39
  else
50
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
- s.add_dependency(%q<mocha>, [">= 0"])
52
- s.add_dependency(%q<matchy>, [">= 0"])
40
+ s.add_dependency(%q<active_support>, [">= 3.0.0"])
41
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
53
42
  end
54
43
  else
55
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
56
- s.add_dependency(%q<mocha>, [">= 0"])
57
- s.add_dependency(%q<matchy>, [">= 0"])
44
+ s.add_dependency(%q<active_support>, [">= 3.0.0"])
45
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
58
46
  end
59
47
  end
48
+
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_remote_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Tobias Crawley
@@ -9,39 +15,40 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-10-01 00:00:00 -04:00
13
- default_executable:
18
+ date: 2011-09-11 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
21
+ name: active_support
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
25
36
  - !ruby/object:Gem::Dependency
26
- name: mocha
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
37
+ name: rspec
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
30
41
  requirements:
31
42
  - - ">="
32
43
  - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: matchy
44
+ hash: 23
45
+ segments:
46
+ - 2
47
+ - 6
48
+ - 0
49
+ version: 2.6.0
37
50
  type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
51
+ version_requirements: *id002
45
52
  description: See the README.
46
53
  email: tcrawley@gmail.com
47
54
  executables: []
@@ -53,43 +60,46 @@ extra_rdoc_files:
53
60
  - README.rdoc
54
61
  files:
55
62
  - .document
56
- - .gitignore
57
63
  - LICENSE
58
64
  - README.rdoc
59
65
  - Rakefile
60
66
  - VERSION
61
67
  - lib/zendesk_remote_auth.rb
62
- - test/test_helper.rb
63
- - test/zendesk_remote_auth_test.rb
68
+ - spec/spec_helper.rb
69
+ - spec/zendesk_remote_auth_spec.rb
64
70
  - zendesk_remote_auth.gemspec
65
- has_rdoc: true
66
71
  homepage: http://github.com/tobias/zendesk_remote_auth
67
72
  licenses: []
68
73
 
69
74
  post_install_message:
70
- rdoc_options:
71
- - --charset=UTF-8
75
+ rdoc_options: []
76
+
72
77
  require_paths:
73
78
  - lib
74
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
75
81
  requirements:
76
82
  - - ">="
77
83
  - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
78
87
  version: "0"
79
- version:
80
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
81
90
  requirements:
82
91
  - - ">="
83
92
  - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
84
96
  version: "0"
85
- version:
86
97
  requirements: []
87
98
 
88
99
  rubyforge_project:
89
- rubygems_version: 1.3.5
100
+ rubygems_version: 1.8.4
90
101
  signing_key:
91
102
  specification_version: 3
92
103
  summary: Helper for Zendesk SSO/remote authentication
93
- test_files:
94
- - test/test_helper.rb
95
- - test/zendesk_remote_auth_test.rb
104
+ test_files: []
105
+
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg
@@ -1,103 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZendeskRemoteAuthTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @auth = Object.new
7
- @auth.extend(Zendesk::RemoteAuthHelper)
8
- end
9
-
10
- context 'RemoteAuth' do
11
- setup do
12
- Zendesk::RemoteAuth.token = Zendesk::RemoteAuth.auth_url = nil
13
- end
14
-
15
- should 'raise exception if token is not set' do
16
- assert_raise ArgumentError do
17
- Zendesk::RemoteAuth.token
18
- end
19
- end
20
-
21
- should 'return the token without exception if it is set' do
22
- Zendesk::RemoteAuth.token = 'blah'
23
- Zendesk::RemoteAuth.token.should == 'blah'
24
- end
25
-
26
-
27
- should 'raise exception if auth_url is not set' do
28
- assert_raise ArgumentError do
29
- Zendesk::RemoteAuth.auth_url
30
- end
31
- end
32
-
33
- should 'return the auth_url without exception if it is set' do
34
- Zendesk::RemoteAuth.auth_url = 'blah'
35
- Zendesk::RemoteAuth.auth_url.should == 'blah'
36
- end
37
- end
38
-
39
-
40
- context 'url generation' do
41
- setup do
42
- Zendesk::RemoteAuth.token = 'the_token'
43
- Zendesk::RemoteAuth.auth_url = 'the_url'
44
- @valid_params = { :email => 'test@example.com', :name => 'blah'}
45
- end
46
-
47
- context 'required fields' do
48
- should 'raise an argument error the name is not provided' do
49
- assert_raise ArgumentError do
50
- @valid_params.delete(:name)
51
- @auth.zendesk_remote_auth_url(@valid_params)
52
- end
53
- end
54
-
55
- should 'raise an argument error the email is not provided' do
56
- assert_raise ArgumentError do
57
- @valid_params.delete(:email)
58
- @auth.zendesk_remote_auth_url(@valid_params)
59
- end
60
- end
61
-
62
- end
63
-
64
- should 'return a url that starts with the auth_url' do
65
- @auth.zendesk_remote_auth_url(@valid_params)
66
- end
67
-
68
- should 'have an empty hash param if external_id not provided' do
69
- @auth.zendesk_remote_auth_url(@valid_params).should =~ /hash=(&|$)/
70
- end
71
-
72
- should 'have a hash param if external_id provided' do
73
- @auth.zendesk_remote_auth_url(@valid_params.merge(:external_id => 'id')).should_not =~ /hash=(&|$)/
74
- end
75
-
76
- context 'given a user object' do
77
- setup do
78
- @user = mock
79
- @user.expects(:name).returns('a_name')
80
- @user.expects(:email).returns('an_email')
81
- end
82
-
83
- should 'pull the name from the user' do
84
- @auth.zendesk_remote_auth_url(@user).should =~ /name=a_name/
85
- end
86
-
87
- should 'pull the email from the user' do
88
- @auth.zendesk_remote_auth_url(@user).should =~ /email=an_email/
89
- end
90
-
91
- should 'pull the id from the user' do
92
- @user.expects(:id).returns('an_id')
93
- @auth.zendesk_remote_auth_url(@user).should =~ /external_id=an_id/
94
- end
95
-
96
- should 'pull the organization from the user if available' do
97
- @user.expects(:zendesk_organization).returns('org')
98
- @auth.zendesk_remote_auth_url(@user).should =~ /organization=org/
99
- end
100
-
101
- end
102
- end
103
- end