Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial working version

  • Loading branch information...
commit e4f43808b9d69c8611e7229e3626e296bf713797 1 parent d793201
@tobias authored
View
2  Rakefile
@@ -6,7 +6,7 @@ begin
Jeweler::Tasks.new do |gem|
gem.name = "zendesk_remote_auth"
gem.summary = %Q{Helper for ZenDesk remote authentication}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.description = %Q{description goes here}
gem.email = "tcrawley@gmail.com"
gem.homepage = "http://github.com/tobias/zendesk_remote_auth"
gem.authors = ["Tobias Crawley"]
View
37 lib/zendesk_remote_auth.rb
@@ -0,0 +1,37 @@
+require 'digest/md5'
+
+module ZenDesk
+ module RemoteAuth
+
+=begin
+ REQUIRED_PARAMETERS = [:n]
+ :name => :required,
+ :email => :required,
+ :external_id => false,
+ :organization => false
+ }
+=end
+
+ def generate_zendesk_remote_auth_url(return_url, token, params)
+ #check_parameters(params)
+ params[:timestamp] = Time.now.utc.to_i unless params[:timestamp]
+ params[:hash] = generate_hash(token, params)
+
+ "#{return_url}?#{params.to_query}"
+ end
+
+ private
+ def generate_hash(token, params)
+ str_to_hash = params[:name].clone
+ str_to_hash << params[:email]
+ str_to_hash << params[:external_id].to_s if params[:external_id]
+ str_to_hash << params[:organization].to_s if params[:organization]
+ str_to_hash << token
+ str_to_hash << params[:timestamp].to_s
+ Digest::MD5.hexdigest(str_to_hash)
+ end
+ def check_parameters(params)
+
+ end
+ end
+end
View
2  test/test_helper.rb
@@ -1,6 +1,8 @@
require 'rubygems'
require 'test/unit'
require 'shoulda'
+require 'mocha'
+require 'matchy'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
View
32 test/zendesk_remote_auth_test.rb
@@ -1,7 +1,35 @@
require 'test_helper'
class ZendeskRemoteAuthTest < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+
+ def setup
+ @auth = Object.new
+ @auth.extend(ZenDesk::RemoteAuth)
+ end
+
+ context 'url generation' do
+ should 'check parameters' do
+ params = { }
+ @auth.expects(:check_parameters).with(params)
+ @auth.generate_zendesk_remote_auth_url(params)
+ end
+ end
+
+ context 'required parameters' do
+ should 'require name' do
+ ZenDesk::RemoteAuth::PARAMETERS[:name].should == :required
+ end
+
+ should 'require email' do
+ ZenDesk::RemoteAuth::PARAMETERS[:email].should == :required
+ end
+ end
+
+ context 'check parameters' do
+ should 'raise error when required fields are not present' do
+ assert_raise ArgumentError do
+ @auth.send(:check_parameters, { })
+ end
+ end
end
end
View
55 zendesk_remote_auth.gemspec
@@ -0,0 +1,55 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE
+# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{zendesk_remote_auth}
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Tobias Crawley"]
+ s.date = %q{2009-08-20}
+ s.description = %q{description goes here}
+ s.email = %q{tcrawley@gmail.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "lib/zendesk_remote_auth.rb",
+ "test/test_helper.rb",
+ "test/zendesk_remote_auth_test.rb"
+ ]
+ s.homepage = %q{http://github.com/tobias/zendesk_remote_auth}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{Helper for ZenDesk remote authentication}
+ s.test_files = [
+ "test/test_helper.rb",
+ "test/zendesk_remote_auth_test.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ s.add_development_dependency(%q<yard>, [">= 0"])
+ else
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ s.add_dependency(%q<yard>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ s.add_dependency(%q<yard>, [">= 0"])
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.