diff --git a/vendor/mash-0.1.1/History.txt b/vendor/mash-0.1.1/History.txt new file mode 100644 index 000000000..3c8fb827a --- /dev/null +++ b/vendor/mash-0.1.1/History.txt @@ -0,0 +1,26 @@ +=== 0.0.5 / 2008-04-29 + +* [bugfix] Mashes do not infinite loop when initialized with another Mash. + +=== 0.0.4 / 2008-04-25 + +* Setting up for GitHub gem hosting instead of Rubyforge. + +=== 0.0.3 / 2008-04-19 + +* [] no longer defaults to a new Mash, will return nil if +* Attribute-esque method names will yield the default value if not set +* Hash extended with #to_mash and #stringify_keys +* Added #dup and #deep_merge +* Aliased the default Hash methods so they are still accessible +* Cleaned up the recursive conversion process + +=== 0.0.2 / 2008-04-12 + +* Added bang(!) method support +* No longer automatically multi-level assigning +* Hash conversion now calls methods instead of []= to allow for overrides + +=== 0.0.1 / 2008-04-12 + +* Initial release \ No newline at end of file diff --git a/vendor/mash-0.1.1/Manifest.txt b/vendor/mash-0.1.1/Manifest.txt new file mode 100644 index 000000000..fc58b19b6 --- /dev/null +++ b/vendor/mash-0.1.1/Manifest.txt @@ -0,0 +1,7 @@ +History.txt +Manifest.txt +README.txt +Rakefile +lib/mash.rb +spec/mash_spec.rb +spec/spec_helper.rb \ No newline at end of file diff --git a/vendor/mash-0.1.1/README.txt b/vendor/mash-0.1.1/README.txt new file mode 100644 index 000000000..b49937428 --- /dev/null +++ b/vendor/mash-0.1.1/README.txt @@ -0,0 +1,69 @@ += Mash (Mocking Hash) + +http://github.com/mbleigh/mash + +== DESCRIPTION: + +Mash is an extended Hash that gives simple pseudo-object functionality +that can be built from hashes and easily extended. It is designed to +be used in RESTful API libraries to provide easy object-like access +to JSON and XML parsed hashes. + +== SYNOPSIS: + + mash = Mash.new + mash.name? # => false + mash.name # => nil + mash.name = "My Mash" + mash.name # => "My Mash" + mash.name? # => true + mash.inspect # => + + mash = Mash.new + # use bang methods for multi-level assignment + mash.author!.name = "Michael Bleigh" + mash.author # => + +== INSTALL: + +Gem: + +Mash is hosted on the GitHub gem repository, so if you haven't already: + + gem sources -a http://gems.github.com/ + sudo gem install mbleigh-mash + +Git: + + git clone git://github.com/mbleigh/mash.git + +== RESOURCES + +If you encounter any problems or have ideas for new features +please report them at the Lighthouse project for Mash: + +http://mbleigh.lighthouseapp.com/projects/10112-mash + +== LICENSE: + +Copyright (c) 2008 Michael Bleigh (http://mbleigh.com/) +and Intridea Inc. (http://intridea.com/), released under the MIT license + +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. diff --git a/vendor/mash-0.1.1/Rakefile b/vendor/mash-0.1.1/Rakefile new file mode 100644 index 000000000..6a2fb6676 --- /dev/null +++ b/vendor/mash-0.1.1/Rakefile @@ -0,0 +1,26 @@ +require 'rubygems' +require './lib/mash.rb' +require 'spec/rake/spectask' + +begin + require 'jeweler' + Jeweler::Tasks.new do |gemspec| + gemspec.name = "mash" + gemspec.summary = "An extended Hash that gives simple pseudo-object functionality that can be built from hashes and easily extended." + gemspec.description = "Mash is an extended Hash that gives simple pseudo-object functionality that can be built from hashes and easily extended." + gemspec.email = "michael@intridea.com" + gemspec.homepage = "http://github.com/mbleigh/mash" + gemspec.authors = ["Michael Bleigh"] + gemspec.files = FileList["[A-Z]*", "{lib,spec}/**/*"] - FileList["**/*.log"] + end + Jeweler::GemcutterTasks.new +rescue LoadError + puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end + +task :default => :spec +desc "Run specs." +Spec::Rake::SpecTask.new("spec") do |t| + t.spec_files = "spec/*_spec.rb" + t.spec_opts = ['--colour', '--format specdoc'] +end \ No newline at end of file diff --git a/vendor/mash-0.1.1/VERSION b/vendor/mash-0.1.1/VERSION new file mode 100644 index 000000000..17e51c385 --- /dev/null +++ b/vendor/mash-0.1.1/VERSION @@ -0,0 +1 @@ +0.1.1 diff --git a/vendor/mash-0.1.1/lib/mash.rb b/vendor/mash-0.1.1/lib/mash.rb new file mode 100644 index 000000000..5cea9c5ef --- /dev/null +++ b/vendor/mash-0.1.1/lib/mash.rb @@ -0,0 +1,228 @@ +# Mash allows you to create pseudo-objects that have method-like +# accessors for hash keys. This is useful for such implementations +# as an API-accessing library that wants to fake robust objects +# without the overhead of actually doing so. Think of it as OpenStruct +# with some additional goodies. +# +# A Mash will look at the methods you pass it and perform operations +# based on the following rules: +# +# * No punctuation: Returns the value of the hash for that key, or nil if none exists. +# * Assignment (=): Sets the attribute of the given method name. +# * Existence (?): Returns true or false depending on whether that key has been set. +# * Bang (!): Forces the existence of this key, used for deep Mashes. Think of it as "touch" for mashes. +# +# == Basic Example +# +# mash = Mash.new +# mash.name? # => false +# mash.name = "Bob" +# mash.name # => "Bob" +# mash.name? # => true +# +# == Hash Conversion Example +# +# hash = {:a => {:b => 23, :d => {:e => "abc"}}, :f => [{:g => 44, :h => 29}, 12]} +# mash = Mash.new(hash) +# mash.a.b # => 23 +# mash.a.d.e # => "abc" +# mash.f.first.g # => 44 +# mash.f.last # => 12 +# +# == Bang Example +# +# mash = Mash.new +# mash.author # => nil +# mash.author! # => +# +# mash = Mash.new +# mash.author!.name = "Michael Bleigh" +# mash.author # => +# +class Mash < Hash + # If you pass in an existing hash, it will + # convert it to a Mash including recursively + # descending into arrays and hashes, converting + # them as well. + def initialize(source_hash = nil, &blk) + deep_update(source_hash) if source_hash + super(&blk) + end + + class << self; alias [] new; end + + def id #:nodoc: + self["id"] ? self["id"] : super + end + + # Borrowed from Merb's Mash object. + # + # ==== Parameters + # key:: The default value for the mash. Defaults to nil. + # + # ==== Alternatives + # If key is a Symbol and it is a key in the mash, then the default value will + # be set to the value matching the key. + def default(key = nil) + if key.is_a?(Symbol) && key?(key) + self[key] + else + key ? super : super() + end + end + + alias_method :regular_reader, :[] + alias_method :regular_writer, :[]= + + # Retrieves an attribute set in the Mash. Will convert + # any key passed in to a string before retrieving. + def [](key) + key = convert_key(key) + regular_reader(key) + end + + # Sets an attribute in the Mash. Key will be converted to + # a string before it is set. + def []=(key,value) #:nodoc: + key = convert_key(key) + regular_writer(key,convert_value(value)) + end + + # This is the bang method reader, it will return a new Mash + # if there isn't a value already assigned to the key requested. + def initializing_reader(key) + return self[key] if key?(key) + self[key] = Mash.new + end + + alias_method :regular_dup, :dup + # Duplicates the current mash as a new mash. + def dup + Mash.new(self) + end + + alias_method :picky_key?, :key? + def key?(key) + picky_key?(convert_key(key)) + end + + alias_method :regular_inspect, :inspect + # Prints out a pretty object-like string of the + # defined attributes. + def inspect + ret = "<#{self.class.to_s}" + keys.sort.each do |key| + ret << " #{key}=#{self[key].inspect}" + end + ret << ">" + ret + end + alias_method :to_s, :inspect + + # Performs a deep_update on a duplicate of the + # current mash. + def deep_merge(other_hash) + dup.deep_merge!(other_hash) + end + + # Recursively merges this mash with the passed + # in hash, merging each hash in the hierarchy. + def deep_update(other_hash) + other_hash = other_hash.to_hash if other_hash.is_a?(Mash) + other_hash = other_hash.stringify_keys + other_hash.each_pair do |k,v| + k = convert_key(k) + self[k] = self[k].to_mash if self[k].is_a?(Hash) unless self[k].is_a?(Mash) + if self[k].is_a?(Hash) && other_hash[k].is_a?(Hash) + self[k] = self[k].deep_merge(other_hash[k]).dup + else + self.send(k + "=", convert_value(other_hash[k],true)) + end + end + end + alias_method :deep_merge!, :deep_update + + # ==== Parameters + # other_hash:: + # A hash to update values in the mash with. Keys will be + # stringified and Hashes will be converted to Mashes. + # + # ==== Returns + # Mash:: The updated mash. + def update(other_hash) + other_hash.each_pair do |key, value| + if respond_to?(convert_key(key) + "=") + self.send(convert_key(key) + "=", convert_value(value)) + else + regular_writer(convert_key(key), convert_value(value)) + end + end + self + end + alias_method :merge!, :update + + # Converts a mash back to a hash (with stringified keys) + def to_hash + Hash.new(default).merge(self) + end + + def method_missing(method_name, *args) #:nodoc: + if (match = method_name.to_s.match(/(.*)=$/)) && args.size == 1 + self[match[1]] = args.first + elsif (match = method_name.to_s.match(/(.*)\?$/)) && args.size == 0 + key?(match[1]) + elsif (match = method_name.to_s.match(/(.*)!$/)) && args.size == 0 + initializing_reader(match[1]) + elsif key?(method_name) + self[method_name] + elsif match = method_name.to_s.match(/^([a-z][a-z0-9A-Z_]+)$/) + default(method_name) + else + super + end + end + + protected + + def convert_key(key) #:nodoc: + key.to_s + end + + def convert_value(value, dup=false) #:nodoc: + case value + when Hash + value = value.dup if value.is_a?(Mash) && dup + value.is_a?(Mash) ? value : value.to_mash + when Array + value.collect{ |e| convert_value(e) } + else + value + end + end +end + +class Hash + # Returns a new Mash initialized from this Hash. + def to_mash + mash = Mash.new(self) + mash.default = default + mash + end + + # Returns a duplicate of the current hash with + # all of the keys converted to strings. + def stringify_keys + dup.stringify_keys! + end + + # Converts all of the keys to strings + def stringify_keys! + keys.each{|k| + v = delete(k) + self[k.to_s] = v + v.stringify_keys! if v.is_a?(Hash) + v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array) + } + self + end +end \ No newline at end of file diff --git a/vendor/mash-0.1.1/spec/mash_spec.rb b/vendor/mash-0.1.1/spec/mash_spec.rb new file mode 100644 index 000000000..0ef6457e5 --- /dev/null +++ b/vendor/mash-0.1.1/spec/mash_spec.rb @@ -0,0 +1,139 @@ +require File.join(File.dirname(__FILE__),"..","lib","mash") +require File.join(File.dirname(__FILE__),"spec_helper") + +describe Mash do + before(:each) do + @mash = Mash.new + end + + it "should inherit from hash" do + @mash.is_a?(Hash).should be_true + end + + it "should be able to set hash values through method= calls" do + @mash.test = "abc" + @mash["test"].should == "abc" + end + + it "should be able to retrieve set values through method calls" do + @mash["test"] = "abc" + @mash.test.should == "abc" + end + + it "should test for already set values when passed a ? method" do + @mash.test?.should be_false + @mash.test = "abc" + @mash.test?.should be_true + end + + it "should make all [] and []= into strings for consistency" do + @mash["abc"] = 123 + @mash.key?('abc').should be_true + @mash["abc"].should == 123 + end + + it "should have a to_s that is identical to its inspect" do + @mash.abc = 123 + @mash.to_s.should == @mash.inspect + end + + it "should return nil instead of raising an error for attribute-esque method calls" do + @mash.abc.should be_nil + end + + it "should return a Mash when passed a bang method to a non-existenct key" do + @mash.abc!.is_a?(Mash).should be_true + end + + it "should return the existing value when passed a bang method for an existing key" do + @mash.name = "Bob" + @mash.name!.should == "Bob" + end + + it "#initializing_reader should return a Mash when passed a non-existent key" do + @mash.initializing_reader(:abc).is_a?(Mash).should be_true + end + + it "should allow for multi-level assignment through bang methods" do + @mash.author!.name = "Michael Bleigh" + @mash.author.should == Mash.new(:name => "Michael Bleigh") + @mash.author!.website!.url = "http://www.mbleigh.com/" + @mash.author.website.should == Mash.new(:url => "http://www.mbleigh.com/") + end + + it "#deep_update should recursively mash mashes and hashes together" do + @mash.first_name = "Michael" + @mash.last_name = "Bleigh" + @mash.details = {:email => "michael@asf.com"}.to_mash + @mash.deep_update({:details => {:email => "michael@intridea.com"}}) + @mash.details.email.should == "michael@intridea.com" + end + + it "should convert hash assignments into mashes" do + @mash.details = {:email => 'randy@asf.com', :address => {:state => 'TX'} } + @mash.details.email.should == 'randy@asf.com' + @mash.details.address.state.should == 'TX' + end + + context "#initialize" do + it "should convert an existing hash to a Mash" do + converted = Mash.new({:abc => 123, :name => "Bob"}) + converted.abc.should == 123 + converted.name.should == "Bob" + end + + it "should convert hashes recursively into mashes" do + converted = Mash.new({:a => {:b => 1, :c => {:d => 23}}}) + converted.a.is_a?(Mash).should be_true + converted.a.b.should == 1 + converted.a.c.d.should == 23 + end + + it "should convert hashes in arrays into mashes" do + converted = Mash.new({:a => [{:b => 12}, 23]}) + converted.a.first.b.should == 12 + converted.a.last.should == 23 + end + + it "should convert an existing Mash into a Mash" do + initial = Mash.new(:name => 'randy', :address => {:state => 'TX'}) + copy = Mash.new(initial) + initial.name.should == copy.name + initial.object_id.should_not == copy.object_id + copy.address.state.should == 'TX' + copy.address.state = 'MI' + initial.address.state.should == 'TX' + copy.address.object_id.should_not == initial.address.object_id + end + + it "should accept a default block" do + initial = Mash.new { |h,i| h[i] = []} + initial.default_proc.should_not be_nil + initial.default.should be_nil + initial.test.should == [] + initial.test?.should be_true + end + end +end + +describe Hash do + it "should be convertible to a Mash" do + mash = {:some => "hash"}.to_mash + mash.is_a?(Mash).should be_true + mash.some.should == "hash" + end + + it "#stringify_keys! should turn all keys into strings" do + hash = {:a => "hey", 123 => "bob"} + hash.stringify_keys! + hash.should == {"a" => "hey", "123" => "bob"} + end + + it "#stringify_keys should return a hash with stringified keys" do + hash = {:a => "hey", 123 => "bob"} + stringified_hash = hash.stringify_keys + hash.should == {:a => "hey", 123 => "bob"} + stringified_hash.should == {"a" => "hey", "123" => "bob"} + end + +end \ No newline at end of file diff --git a/vendor/mash-0.1.1/spec/spec_helper.rb b/vendor/mash-0.1.1/spec/spec_helper.rb new file mode 100644 index 000000000..755a5f735 --- /dev/null +++ b/vendor/mash-0.1.1/spec/spec_helper.rb @@ -0,0 +1 @@ +require File.join(File.dirname(__FILE__),"..","lib","mash") \ No newline at end of file diff --git a/vendor/oauth-0.3.2/History.txt b/vendor/oauth-0.3.2/History.txt deleted file mode 100644 index b8b9561a2..000000000 --- a/vendor/oauth-0.3.2/History.txt +++ /dev/null @@ -1,66 +0,0 @@ -== 0.3.2 2009-03-23 - -* 2xx statuses should be treated as success (Anders Conbere) -* Support applications using the MethodOverride Rack middleware (László Bácsi) -* `authorize` command for `oauth` CLI (Seth) -* Initial support for Problem Reporting extension (Seth) -* Verify SSL certificates if CA certificates are available (Seth) -* Fixed ActionController parameter escaping behavior (Thiago Arrais, László - Bácsi, Brett Gibson, et al) -* Fixed signature calculation when both options and a block were provided to - OAuth::Signature::Base#initialize (Seth) -* Added help to the 'oauth' CLI (Seth) -* Fixed a problem when attempting to normalize MockRequest URIs (Seth) - -== 0.3.1 2009-1-26 - -* Fixed a problem with relative and absolute token request paths. (Michael - Wood) - -== 0.3.0 2009-1-25 - -* Support ActionController::Request from Edge Rails (László Bácsi) -* Correctly handle multi-valued parameters (Seth) -* Added #normalized_parameters to OAuth::RequestProxy::Base (Pelle) -* OAuth::Signature.sign and friends now yield the RequestProxy instead of the - token when the passed block's arity is 1. (Seth) -* Token requests are made to the configured URL rather than generating a - potentially incorrect one. (Kellan Elliott-McCrea) -* Command-line app for generating signatures. (Seth) -* Improved test-cases and compatibility for encoding issues. (Pelle) - -== 0.2.7 2008-9-10 The lets fix the last release release - -* Fixed plain text signatures (Andrew Arrow) -* Fixed RSA requests using OAuthTokens. (Philip Lipu Tsai) - -== 0.2.6 2008-9-9 The lets RSA release - -* Improved support for Ruby 1.8.7 (Bill Kocik) -* Fixed RSA verification to support RSA providers - now using Ruby and RSA -* Improved RSA testing -* Omit token when signing with RSA -* Added support for 'private_key_file' option for RSA signatures (Chris Mear) -* Fixed several edge cases where params were being incorrectly signed (Scott - Hill) -* Fixed RSA signing (choonkeat) - -== 0.2.2 2008-2-22 Lets actually support SSL release - -* Use HTTPS when required. - -== 0.2 2008-1-19 All together now release - -This is a big release, where we have merged the efforts of various parties into one common library. This means there are definitely some API changes you should be aware of. They should be minimal but please have a look at the unit tests. - -== 0.1.2 2007-12-1 - -* Fixed checks for missing OAuth params to improve performance -* Includes Pat's fix for getting the realm out. - -== 0.1.1 2007-11-26 - -* First release as a GEM -* Moved all non-Rails functionality from the Rails plugin: - http://code.google.com/p/oauth-plugin/ diff --git a/vendor/oauth-0.3.2/Manifest.txt b/vendor/oauth-0.3.2/Manifest.txt deleted file mode 100644 index bf4ecdf32..000000000 --- a/vendor/oauth-0.3.2/Manifest.txt +++ /dev/null @@ -1,83 +0,0 @@ -History.txt -License.txt -Manifest.txt -README.rdoc -Rakefile -TODO -bin/oauth -examples/yql.rb -lib/oauth.rb -lib/oauth/oauth.rb -lib/oauth/cli.rb -lib/oauth/client.rb -lib/oauth/client/action_controller_request.rb -lib/oauth/client/helper.rb -lib/oauth/client/net_http.rb -lib/oauth/consumer.rb -lib/oauth/errors.rb -lib/oauth/errors/error.rb -lib/oauth/errors/problem.rb -lib/oauth/errors/unauthorized.rb -lib/oauth/helper.rb -lib/oauth/oauth_test_helper.rb -lib/oauth/request_proxy.rb -lib/oauth/request_proxy/action_controller_request.rb -lib/oauth/request_proxy/base.rb -lib/oauth/request_proxy/jabber_request.rb -lib/oauth/request_proxy/mock_request.rb -lib/oauth/request_proxy/net_http.rb -lib/oauth/request_proxy/rack_request.rb -lib/oauth/server.rb -lib/oauth/signature.rb -lib/oauth/signature/base.rb -lib/oauth/signature/hmac/base.rb -lib/oauth/signature/hmac/md5.rb -lib/oauth/signature/hmac/rmd160.rb -lib/oauth/signature/hmac/sha1.rb -lib/oauth/signature/hmac/sha2.rb -lib/oauth/signature/md5.rb -lib/oauth/signature/plaintext.rb -lib/oauth/signature/rsa/sha1.rb -lib/oauth/signature/sha1.rb -lib/oauth/token.rb -lib/oauth/tokens/access_token.rb -lib/oauth/tokens/consumer_token.rb -lib/oauth/tokens/request_token.rb -lib/oauth/tokens/server_token.rb -lib/oauth/tokens/token.rb -lib/oauth/version.rb -oauth.gemspec -script/destroy -script/generate -script/txt2html -setup.rb -tasks/deployment.rake -tasks/environment.rake -tasks/website.rake -test/cases/oauth_case.rb -test/cases/spec/1_0-final/test_construct_request_url.rb -test/cases/spec/1_0-final/test_normalize_request_parameters.rb -test/cases/spec/1_0-final/test_parameter_encodings.rb -test/cases/spec/1_0-final/test_signature_base_strings.rb -test/keys/rsa.cert -test/keys/rsa.pem -test/test_access_token.rb -test/test_action_controller_request_proxy.rb -test/test_consumer.rb -test/test_helper.rb -test/test_hmac_sha1.rb -test/test_net_http_client.rb -test/test_net_http_request_proxy.rb -test/test_rack_request_proxy.rb -test/test_request_token.rb -test/test_rsa_sha1.rb -test/test_server.rb -test/test_signature.rb -test/test_signature_base.rb -test/test_signature_plain_text.rb -test/test_token.rb -website/index.html -website/index.txt -website/javascripts/rounded_corners_lite.inc.js -website/stylesheets/screen.css -website/template.rhtml diff --git a/vendor/oauth-0.3.2/Rakefile b/vendor/oauth-0.3.2/Rakefile deleted file mode 100644 index 92c33c54e..000000000 --- a/vendor/oauth-0.3.2/Rakefile +++ /dev/null @@ -1,36 +0,0 @@ -%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f } -$LOAD_PATH << File.dirname(__FILE__) + '/lib' -require 'oauth' -require 'oauth/version' - -# Generate all the Rake tasks -# Run 'rake -T' to see list of generated tasks (from gem root directory) -$hoe = Hoe.new('oauth', OAuth::VERSION) do |p| - p.author = ['Pelle Braendgaard','Blaine Cook','Larry Halff','Jesse Clark','Jon Crosby', 'Seth Fitzsimmons'] - p.email = "pelleb@gmail.com" - p.description = "OAuth Core Ruby implementation" - p.summary = p.description - p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") - p.rubyforge_name = p.name # TODO this is default value - p.url = "http://oauth.rubyforge.org" - - p.extra_deps = [ - ['ruby-hmac','>= 0.3.1'] - ] - p.extra_dev_deps = [ - ['newgem', ">= #{::Newgem::VERSION}"], - ['actionpack'], - ['rack'] - ] - - p.clean_globs |= %w[**/.DS_Store tmp *.log **/.*.sw? *.gem .config **/.DS_Store] - path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}" - p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc') - p.rsync_args = '-av --delete --ignore-errors' -end - -require 'newgem/tasks' # load /tasks/*.rake -Dir['tasks/**/*.rake'].each { |t| load t } - -# TODO - want other tests/tasks run by default? Add them to the list -# task :default => [:spec, :features] diff --git a/vendor/oauth-0.3.2/bin/oauth b/vendor/oauth-0.3.2/bin/oauth deleted file mode 100755 index 45ee16fdd..000000000 --- a/vendor/oauth-0.3.2/bin/oauth +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require "oauth/cli" - -OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV) diff --git a/vendor/oauth-0.3.2/lib/oauth.rb b/vendor/oauth-0.3.2/lib/oauth.rb deleted file mode 100644 index f2aa99677..000000000 --- a/vendor/oauth-0.3.2/lib/oauth.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'oauth/oauth' -require 'oauth/client/helper' -require 'oauth/signature/hmac/sha1' -require 'oauth/request_proxy/mock_request' diff --git a/vendor/oauth-0.3.2/lib/oauth/client/net_http.rb b/vendor/oauth-0.3.2/lib/oauth/client/net_http.rb deleted file mode 100644 index 65a6f9fc4..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/client/net_http.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'oauth/helper' -require 'oauth/client/helper' -require 'oauth/request_proxy/net_http' - -class Net::HTTPRequest - include OAuth::Helper - - attr_reader :oauth_helper - - def oauth!(http, consumer = nil, token = nil, options = {}) - options = { :request_uri => oauth_full_request_uri(http), - :consumer => consumer, - :token => token, - :scheme => 'header', - :signature_method => nil, - :nonce => nil, - :timestamp => nil }.merge(options) - - @oauth_helper = OAuth::Client::Helper.new(self, options) - self.send("set_oauth_#{options[:scheme]}") - end - - def signature_base_string(http, consumer = nil, token = nil, options = {}) - options = { :request_uri => oauth_full_request_uri(http), - :consumer => consumer, - :token => token, - :scheme => 'header', - :signature_method => nil, - :nonce => nil, - :timestamp => nil }.merge(options) - - OAuth::Client::Helper.new(self, options).signature_base_string - end - -private - - def oauth_full_request_uri(http) - uri = URI.parse(self.path) - uri.host = http.address - uri.port = http.port - - if http.respond_to?(:use_ssl?) && http.use_ssl? - uri.scheme = "https" - else - uri.scheme = "http" - end - - uri.to_s - end - - def set_oauth_header - self['Authorization'] = @oauth_helper.header - end - - # FIXME: if you're using a POST body and query string parameters, using this - # method will convert those parameters on the query string into parameters in - # the body. this is broken, and should be fixed. - def set_oauth_body - self.set_form_data(@oauth_helper.parameters_with_oauth) - params_with_sig = @oauth_helper.parameters.merge(:oauth_signature => @oauth_helper.signature) - self.set_form_data(params_with_sig) - end - - def set_oauth_query_string - oauth_params_str = @oauth_helper.oauth_parameters.map { |k,v| [escape(k), escape(v)] * "=" }.join("&") - - uri = URI.parse(path) - if uri.query.to_s == "" - uri.query = oauth_params_str - else - uri.query = uri.query + "&" + oauth_params_str - end - - @path = uri.to_s - - @path << "&oauth_signature=#{escape(oauth_helper.signature)}" - end -end diff --git a/vendor/oauth-0.3.2/lib/oauth/helper.rb b/vendor/oauth-0.3.2/lib/oauth/helper.rb deleted file mode 100644 index 6050c4908..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/helper.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'openssl' -require 'base64' - -module OAuth - module Helper - extend self - - def escape(value) - URI::escape(value.to_s, OAuth::RESERVED_CHARACTERS) - end - - def generate_key(size=32) - Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/, '') - end - - alias_method :generate_nonce, :generate_key - - def generate_timestamp - Time.now.to_i.to_s - end - - def normalize(params) - params.sort.map do |k, values| - - if values.is_a?(Array) - # multiple values were provided for a single key - values.sort.collect do |v| - [escape(k),escape(v)] * "=" - end - else - [escape(k),escape(values)] * "=" - end - end * "&" - end - - # Parse an Authorization / WWW-Authenticate header into a hash - def parse_header(header) - # decompose - params = header[6,header.length].split(/[,=]/) - - # strip and unescape - params.map! { |v| unescape(v.strip) } - - # strip quotes - params.map! { |v| v =~ /^\".*\"$/ ? v[1..-2] : v } - - # convert into a Hash - Hash[*params.flatten] - end - - def unescape(value) - URI.unescape(value.gsub('+', '%2B')) - end - end -end \ No newline at end of file diff --git a/vendor/oauth-0.3.2/lib/oauth/oauth.rb b/vendor/oauth-0.3.2/lib/oauth/oauth.rb deleted file mode 100644 index 2b33e7f2b..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/oauth.rb +++ /dev/null @@ -1,7 +0,0 @@ -module OAuth - # required parameters, per sections 6.1.1, 6.3.1, and 7 - PARAMETERS = %w(oauth_consumer_key oauth_token oauth_signature_method oauth_timestamp oauth_nonce oauth_version oauth_signature) - - # reserved character regexp, per section 5.1 - RESERVED_CHARACTERS = /[^\w\d\-\.\_\~]/ -end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature.rb b/vendor/oauth-0.3.2/lib/oauth/signature.rb deleted file mode 100644 index b3e5a9519..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/signature.rb +++ /dev/null @@ -1,28 +0,0 @@ -module OAuth - module Signature - def self.available_methods - @available_methods ||= {} - end - - def self.build(request, options = {}, &block) - request = OAuth::RequestProxy.proxy(request, options) - klass = available_methods[(request.signature_method || "").downcase] - raise UnknownSignatureMethod, request.signature_method unless klass - klass.new(request, options, &block) - end - - def self.sign(request, options = {}, &block) - self.build(request, options, &block).signature - end - - def self.verify(request, options = {}, &block) - self.build(request, options, &block).verify - end - - def self.signature_base_string(request, options = {}, &block) - self.build(request, options, &block).signature_base_string - end - - class UnknownSignatureMethod < Exception; end - end -end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/base.rb b/vendor/oauth-0.3.2/lib/oauth/signature/hmac/base.rb deleted file mode 100644 index 0646bd949..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/base.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'oauth/signature/base' - -module OAuth::Signature::HMAC - class Base < OAuth::Signature::Base - - private - - def digest - self.class.digest_class.digest(secret, signature_base_string) - end - end -end diff --git a/vendor/oauth-0.3.2/lib/oauth/version.rb b/vendor/oauth-0.3.2/lib/oauth/version.rb deleted file mode 100644 index f7d9aad40..000000000 --- a/vendor/oauth-0.3.2/lib/oauth/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module OAuth #:nodoc: - VERSION = '0.3.2' -end diff --git a/vendor/oauth-0.3.2/oauth.gemspec b/vendor/oauth-0.3.2/oauth.gemspec deleted file mode 100644 index d1ab9cf64..000000000 --- a/vendor/oauth-0.3.2/oauth.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{oauth} - s.version = "0.3.2" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"] - s.date = %q{2009-03-23} - s.default_executable = %q{oauth} - s.description = %q{OAuth Core Ruby implementation} - s.email = %q{oauth-ruby@googlegroups.com} - s.executables = ["oauth"] - s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "website/index.txt"] - s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "bin/oauth", "examples/yql.rb", "lib/oauth.rb", "lib/oauth/oauth.rb", "lib/oauth/cli.rb", "lib/oauth/client.rb", "lib/oauth/client/action_controller_request.rb", "lib/oauth/client/helper.rb", "lib/oauth/client/net_http.rb", "lib/oauth/consumer.rb", "lib/oauth/errors.rb", "lib/oauth/errors/error.rb", "lib/oauth/errors/problem.rb", "lib/oauth/errors/unauthorized.rb", "lib/oauth/helper.rb", "lib/oauth/oauth_test_helper.rb", "lib/oauth/request_proxy.rb", "lib/oauth/request_proxy/action_controller_request.rb", "lib/oauth/request_proxy/base.rb", "lib/oauth/request_proxy/jabber_request.rb", "lib/oauth/request_proxy/mock_request.rb", "lib/oauth/request_proxy/net_http.rb", "lib/oauth/request_proxy/rack_request.rb", "lib/oauth/server.rb", "lib/oauth/signature.rb", "lib/oauth/signature/base.rb", "lib/oauth/signature/hmac/base.rb", "lib/oauth/signature/hmac/md5.rb", "lib/oauth/signature/hmac/rmd160.rb", "lib/oauth/signature/hmac/sha1.rb", "lib/oauth/signature/hmac/sha2.rb", "lib/oauth/signature/md5.rb", "lib/oauth/signature/plaintext.rb", "lib/oauth/signature/rsa/sha1.rb", "lib/oauth/signature/sha1.rb", "lib/oauth/token.rb", "lib/oauth/tokens/access_token.rb", "lib/oauth/tokens/consumer_token.rb", "lib/oauth/tokens/request_token.rb", "lib/oauth/tokens/server_token.rb", "lib/oauth/tokens/token.rb", "lib/oauth/version.rb", "oauth.gemspec", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/cases/oauth_case.rb", "test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/keys/rsa.cert", "test/keys/rsa.pem", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml"] - s.has_rdoc = true - s.homepage = %q{http://oauth.rubyforge.org} - s.rdoc_options = ["--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{oauth} - s.rubygems_version = %q{1.3.1} - s.summary = %q{OAuth Core Ruby implementation} - s.test_files = ["test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0.3.1"]) - s.add_development_dependency(%q, [">= 1.2.3"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 1.8.0"]) - else - s.add_dependency(%q, [">= 0.3.1"]) - s.add_dependency(%q, [">= 1.2.3"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 1.8.0"]) - end - else - s.add_dependency(%q, [">= 0.3.1"]) - s.add_dependency(%q, [">= 1.2.3"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 1.8.0"]) - end -end diff --git a/vendor/oauth-0.3.2/script/destroy b/vendor/oauth-0.3.2/script/destroy deleted file mode 100755 index 5fa7e10e7..000000000 --- a/vendor/oauth-0.3.2/script/destroy +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby -APP_ROOT = File.join(File.dirname(__FILE__), '..') - -begin - require 'rubigen' -rescue LoadError - require 'rubygems' - require 'rubigen' -end -require 'rubigen/scripts/destroy' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] -RubiGen::Scripts::Destroy.new.run(ARGV) diff --git a/vendor/oauth-0.3.2/script/generate b/vendor/oauth-0.3.2/script/generate deleted file mode 100755 index 230a18685..000000000 --- a/vendor/oauth-0.3.2/script/generate +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby -APP_ROOT = File.join(File.dirname(__FILE__), '..') - -begin - require 'rubigen' -rescue LoadError - require 'rubygems' - require 'rubigen' -end -require 'rubigen/scripts/generate' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] -RubiGen::Scripts::Generate.new.run(ARGV) diff --git a/vendor/oauth-0.3.2/script/txt2html b/vendor/oauth-0.3.2/script/txt2html deleted file mode 100755 index 382c8773d..000000000 --- a/vendor/oauth-0.3.2/script/txt2html +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env ruby - -require 'rubygems' -begin - require 'newgem' -rescue LoadError - puts "\n\nGenerating the website requires the newgem RubyGem" - puts "Install: gem install newgem\n\n" - exit(1) -end -require 'redcloth' -require 'syntax/convertors/html' -require 'erb' -require File.dirname(__FILE__) + '/../lib/oauth/version.rb' - -version = OAuth::VERSION::STRING -download = 'http://rubyforge.org/projects/oauth' - -class Fixnum - def ordinal - # teens - return 'th' if (10..19).include?(self % 100) - # others - case self % 10 - when 1: return 'st' - when 2: return 'nd' - when 3: return 'rd' - else return 'th' - end - end -end - -class Time - def pretty - return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}" - end -end - -def convert_syntax(syntax, source) - return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^
|
$!,'') -end - -if ARGV.length >= 1 - src, template = ARGV - template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml') - -else - puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html") - exit! -end - -template = ERB.new(File.open(template).read) - -title = nil -body = nil -File.open(src) do |fsrc| - title_text = fsrc.readline - body_text = fsrc.read - syntax_items = [] - body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)!m){ - ident = syntax_items.length - element, syntax, source = $1, $2, $3 - syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}" - "syntax-temp-#{ident}" - } - title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip - body = RedCloth.new(body_text).to_html - body.gsub!(%r!(?:
)?syntax-temp-(\d+)(?:
)?!){ syntax_items[$1.to_i] } -end -stat = File.stat(src) -created = stat.ctime -modified = stat.mtime - -$stdout << template.result(binding) diff --git a/vendor/oauth-0.3.2/setup.rb b/vendor/oauth-0.3.2/setup.rb deleted file mode 100644 index 424a5f37c..000000000 --- a/vendor/oauth-0.3.2/setup.rb +++ /dev/null @@ -1,1585 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2005 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU LGPL, Lesser General Public License version 2.1. -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -unless Errno.const_defined?(:ENOTEMPTY) # Windows? - module Errno - class ENOTEMPTY - # We do not raise this exception, implementation is not needed. - end - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted Windows' stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class ConfigTable - - include Enumerable - - def initialize(rbconfig) - @rbconfig = rbconfig - @items = [] - @table = {} - # options - @install_prefix = nil - @config_opt = nil - @verbose = true - @no_harm = false - end - - attr_accessor :install_prefix - attr_accessor :config_opt - - attr_writer :verbose - - def verbose? - @verbose - end - - attr_writer :no_harm - - def no_harm? - @no_harm - end - - def [](key) - lookup(key).resolve(self) - end - - def []=(key, val) - lookup(key).set val - end - - def names - @items.map {|i| i.name } - end - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or setup_rb_error "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def load_script(path, inst = nil) - if File.file?(path) - MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path - end - end - - def savefile - '.config' - end - - def load_savefile - begin - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - self[k] = v.strip - end - rescue Errno::ENOENT - setup_rb_error $!.message + "\n#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value? and i.value - end - } - end - - def load_standard_entries - standard_entries(@rbconfig).each do |ent| - add ent - end - end - - def standard_entries(rbconfig) - c = rbconfig - - rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - if c['rubylibdir'] - # V > 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = c['rubylibdir'] - librubyverarch = c['archdir'] - siteruby = c['sitedir'] - siterubyver = c['sitelibdir'] - siterubyverarch = c['sitearchdir'] - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = c['sitedir'] - siterubyver = "$siteruby/#{version}" - siterubyverarch = "$siterubyver/#{c['arch']}" - else - # V < 1.4.4 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" - siterubyver = siteruby - siterubyverarch = "$siterubyver/#{c['arch']}" - end - parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') - } - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - [ - ExecItem.new('installdirs', 'std/site/home', - 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ - {|val, table| - case val - when 'std' - table['rbdir'] = '$librubyver' - table['sodir'] = '$librubyverarch' - when 'site' - table['rbdir'] = '$siterubyver' - table['sodir'] = '$siterubyverarch' - when 'home' - setup_rb_error '$HOME was not set' unless ENV['HOME'] - table['prefix'] = ENV['HOME'] - table['rbdir'] = '$libdir/ruby' - table['sodir'] = '$libdir/ruby' - end - }, - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', parameterize.call(c['libdir']), - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for system configuration files'), - PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), - 'the directory for local state data'), - PathItem.new('libruby', 'path', libruby, - 'the directory for ruby libraries'), - PathItem.new('librubyver', 'path', librubyver, - 'the directory for standard ruby libraries'), - PathItem.new('librubyverarch', 'path', librubyverarch, - 'the directory for standard ruby extensions'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') - ] - end - private :standard_entries - - def load_multipackage_entries - multipackage_entries().each do |ent| - add ent - end - end - - def multipackage_entries - [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') - ] - end - private :multipackage_entries - - ALIASES = { - 'std-ruby' => 'librubyver', - 'stdruby' => 'librubyver', - 'rubylibdir' => 'librubyver', - 'archdir' => 'librubyverarch', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } - - def fixup - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - @items.freeze - @table.freeze - @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ - end - - def parse_opt(opt) - m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" - m.to_a[1,2] - end - - def dllext - @rbconfig['DLEXT'] - end - - def value_config?(name) - lookup(name).value? - end - - class Item - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value? - true - end - - def value - @value - end - - def resolve(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end - end - - class BoolItem < Item - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - case val - when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' - when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' - else - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - end - end - - class PathItem < Item - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end - end - - class ProgramItem < Item - def config_type - 'program' - end - end - - class SelectItem < Item - def initialize(name, selection, default, desc) - super - @ok = selection.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end - end - - class ExecItem < Item - def initialize(name, selection, desc, &block) - super name, selection, nil, desc - @ok = selection.split('/') - @action = block - end - - def config_type - 'exec' - end - - def value? - false - end - - def resolve(table) - setup_rb_error "$#{name()} wrongly used as option value" - end - - undef set - - def evaluate(val, table) - v = val.strip.downcase - unless @ok.include?(v) - setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" - end - @action.call v, table - end - end - - class PackageSelectionItem < Item - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end - end - - class MetaConfigEnvironment - def initialize(config, installer) - @config = config - @installer = installer - end - - def config_names - @config.names - end - - def config?(name) - @config.key?(name) - end - - def bool_config?(name) - @config.lookup(name).config_type == 'bool' - end - - def path_config?(name) - @config.lookup(name).config_type == 'path' - end - - def value_config?(name) - @config.lookup(name).config_type != 'exec' - end - - def add_config(item) - @config.add item - end - - def add_bool_config(name, default, desc) - @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - @config.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - @config.lookup(name).default = default - end - - def remove_config(name) - @config.remove(name) - end - - # For only multipackage - def packages - raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer - @installer.packages - end - - # For only multipackage - def declare_packages(list) - raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer - @installer.packages = list - end - end - -end # class ConfigTable - - -# This module requires: #verbose?, #no_harm? -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # Does not check '/', it's too abnormal. - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(path) - $stderr.puts "rm -f #{path}" if verbose? - return if no_harm? - force_remove_file path - end - - def rm_rf(path) - $stderr.puts "rm -rf #{path}" if verbose? - return if no_harm? - remove_tree path - end - - def remove_tree(path) - if File.symlink?(path) - remove_file path - elsif File.dir?(path) - remove_tree0 path - else - force_remove_file path - end - end - - def remove_tree0(path) - Dir.foreach(path) do |ent| - next if ent == '.' - next if ent == '..' - entpath = "#{path}/#{ent}" - if File.symlink?(entpath) - remove_file entpath - elsif File.dir?(entpath) - remove_tree0 entpath - else - force_remove_file entpath - end - end - begin - Dir.rmdir path - rescue Errno::ENOTEMPTY - # directory may not be empty - end - end - - def move_file(src, dest) - force_remove_file dest - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| - f.write File.binread(src) - } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def force_remove_file(path) - begin - remove_file path - rescue - end - end - - def remove_file(path) - File.chmod 0777, path - File.unlink path - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(*args) - $stderr.puts args.join(' ') if verbose? - system(*args) or raise RuntimeError, - "system(#{args.map{|a| a.inspect }.join(' ')}) failed" - end - - def ruby(*args) - command config('rubyprog'), *args - end - - def make(task = nil) - command(*[config('makeprog'), task].compact) - end - - def extdir?(dir) - File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") - end - - def files_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.file?("#{dir}/#{ent}") } - } - end - - DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) - - def directories_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT - } - end - -end - - -# This module requires: #srcdir_root, #objdir_root, #relpath -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - # obsolete: use metaconfig to change configuration - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file?(srcfile(path)) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.4.1' - Copyright = 'Copyright (c) 2000-2005 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'test', 'run all tests in test/' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - config = ConfigTable.new(load_rbconfig()) - config.load_standard_entries - config.load_multipackage_entries if multipackage? - config.fixup - klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) - klass.new(File.dirname($0), config).invoke - end - - def ToplevelInstaller.multipackage? - File.dir?(File.dirname($0) + '/packages') - end - - def ToplevelInstaller.load_rbconfig - if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - load File.expand_path(arg.split(/=/, 2)[1]) - $".push 'rbconfig.rb' - else - require 'rbconfig' - end - ::Config::CONFIG - end - - def initialize(ardir_root, config) - @ardir = File.expand_path(ardir_root) - @config = config - # cache - @valid_task_re = nil - end - - def config(key) - @config[key] - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - case task - when 'config', 'test' - ; - when 'clean', 'distclean' - @config.load_savefile if File.exist?(@config.savefile) - else - @config.load_savefile - end - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig" - end - - def init_installers - @installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) - return arg - when '-q', '--quiet' - @config.verbose = false - when '--verbose' - @config.verbose = true - when '--help' - print_usage $stdout - exit 0 - when '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - when '--copyright' - puts Copyright - exit 0 - else - setup_rb_error "unknown global option '#{arg}'" - end - end - nil - end - - def valid_task?(t) - valid_task_re() =~ t - end - - def valid_task_re - @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ - end - - def parsearg_no_options - unless ARGV.empty? - task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) - setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_test parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - evalopt = [] - set = [] - @config.config_opt = [] - while i = ARGV.shift - if /\A--?\z/ =~ i - @config.config_opt = ARGV.dup - break - end - name, value = *@config.parse_opt(i) - if @config.value_config?(name) - @config[name] = value - else - evalopt.push [name, value] - end - set.push name - end - evalopt.each do |name, value| - @config.lookup(name).evaluate value, @config - end - # Check if configuration is valid - set.each do |n| - @config[n] if @config.value_config?(n) - end - end - - def parsearg_install - @config.no_harm = false - @config.install_prefix = '' - while a = ARGV.shift - case a - when '--no-harm' - @config.no_harm = true - when /\A--prefix=/ - path = a.split(/=/, 2)[1] - path = File.expand_path(path) unless path[0,1] == '/' - @config.install_prefix = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, ' --help', 'print this message' - out.printf fmt, ' --version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - @config.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_test - @installer.exec_test - end - - def exec_show - @config.each do |i| - printf "%-20s %s\n", i.name, i.value if i.value? - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end # class ToplevelInstaller - - -class ToplevelInstallerMulti < ToplevelInstaller - - include FileOperations - - def initialize(ardir_root, config) - super - @packages = directories_of("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig", self - @packages.each do |name| - @config.load_script "#{@ardir}/packages/#{name}/metaconfig" - end - end - - attr_reader :packages - - def packages=(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_test - run_hook 'pre-test' - each_selected_installers {|inst| inst.exec_test } - run_hook 'post-test' - end - - def exec_clean - rm_f @config.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f @config.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if verbose? - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def run_hook(id) - @root_installer.run_hook id - end - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - -end # class ToplevelInstallerMulti - - -class Installer - - FILETYPES = %w( bin lib ext data conf man ) - - include FileOperations - include HookScriptAPI - - def initialize(config, srcroot, objroot) - @config = config - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - def noop(rel) - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # Config Access - # - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - - def verbose_off - begin - save, @config.verbose = @config.verbose?, false - yield - ensure - @config.verbose = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - alias config_dir_bin noop - alias config_dir_lib noop - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - alias config_dir_data noop - alias config_dir_conf noop - alias config_dir_man noop - - def extconf - ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - files_of(curr_srcdir()).each do |fname| - update_shebang_line "#{curr_srcdir()}/#{fname}" - end - end - - alias setup_dir_lib noop - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - alias setup_dir_data noop - alias setup_dir_conf noop - alias setup_dir_man noop - - def update_shebang_line(path) - return if no_harm? - return if config('shebang') == 'never' - old = Shebang.load(path) - if old - $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 - new = new_shebang(old) - return if new.to_s == old.to_s - else - return unless config('shebang') == 'all' - new = Shebang.new(config('rubypath')) - end - $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? - open_atomic_writer(path) {|output| - File.open(path, 'rb') {|f| - f.gets if old # discard - output.puts new.to_s - output.print f.read - } - } - end - - def new_shebang(old) - if /\Aruby/ =~ File.basename(old.cmd) - Shebang.new(config('rubypath'), old.args) - elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' - Shebang.new(config('rubypath'), old.args[1..-1]) - else - return old unless config('shebang') == 'all' - Shebang.new(config('rubypath')) - end - end - - def open_atomic_writer(path, &block) - tmpfile = File.basename(path) + '.tmp' - begin - File.open(tmpfile, 'wb', &block) - File.rename tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - class Shebang - def Shebang.load(path) - line = nil - File.open(path) {|f| - line = f.gets - } - return nil unless /\A#!/ =~ line - parse(line) - end - - def Shebang.parse(line) - cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') - new(cmd, args) - end - - def initialize(cmd, args = []) - @cmd = cmd - @args = args - end - - attr_reader :cmd - attr_reader :args - - def to_s - "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") - end - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files rubyextentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_dir_conf(rel) - # FIXME: should not remove current config files - # (rename previous file to .old/.org) - install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 - end - - def install_dir_man(rel) - install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @config.install_prefix - list.each do |fname| - install fname, dest, mode, @config.install_prefix - end - end - - def libfiles - glob_reject(%w(*.y *.output), targetfiles()) - end - - def rubyextentions(dir) - ents = glob_select("*.#{@config.dllext}", targetfiles()) - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - ents - end - - def targetfiles - mapdir(existfiles() - hookfiles()) - end - - def mapdir(ents) - ents.map {|ent| - if File.exist?(ent) - then ent # objdir - else "#{curr_srcdir()}/#{ent}" # srcdir - end - } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - JUNK_FILES = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - - def existfiles - glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def glob_select(pat, ents) - re = globs2re([pat]) - ents.select {|ent| re =~ ent } - end - - def glob_reject(pats, ents) - re = globs2re(pats) - ents.reject {|ent| re =~ ent } - end - - GLOB2REGEX = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - - def globs2re(pats) - /\A(?:#{ - pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') - })\z/ - end - - # - # TASK test - # - - TESTDIR = 'test' - - def exec_test - unless File.directory?('test') - $stderr.puts 'no test in this package' if verbose? - return - end - $stderr.puts 'Running tests...' if verbose? - begin - require 'test/unit' - rescue LoadError - setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' - end - runner = Test::Unit::AutoRunner.new(true) - runner.to_run << TESTDIR - runner.run - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias clean_dir_bin noop - alias clean_dir_lib noop - alias clean_dir_data noop - alias clean_dir_conf noop - alias clean_dir_man noop - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias distclean_dir_bin noop - alias distclean_dir_lib noop - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - alias distclean_dir_data noop - alias distclean_dir_conf noop - alias distclean_dir_man noop - - # - # Traversing - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if type == 'ext' and config('without-ext') == 'yes' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - directories_of(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - - def run_hook(id) - path = [ "#{curr_srcdir()}/#{id}", - "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } - return unless path - begin - instance_eval File.read(path), path, 1 - rescue - raise if $DEBUG - setup_rb_error "hook #{path} failed:\n" + $!.message - end - end - -end # class Installer - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -if $0 == __FILE__ - begin - ToplevelInstaller.invoke - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/oauth-0.3.2/test/test_action_controller_request_proxy.rb b/vendor/oauth-0.3.2/test/test_action_controller_request_proxy.rb deleted file mode 100644 index bc739d901..000000000 --- a/vendor/oauth-0.3.2/test/test_action_controller_request_proxy.rb +++ /dev/null @@ -1,45 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/request_proxy/action_controller_request.rb' -require 'action_controller' -require 'action_controller/test_process' - -class ActionControllerRequestProxyTest < Test::Unit::TestCase - - def request_proxy(parameters={}) - request = ActionController::TestRequest.new({}, parameters) - request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded' - yield request if block_given? - OAuth::RequestProxy.proxy(request) - end - - def test_parameter_keys_should_preserve_brackets_from_hash - assert_equal( - [["message[body]", "This is a test"]], - request_proxy({ :message => { :body => 'This is a test' }}).parameters_for_signature - ) - end - - def test_parameter_values_with_amps_should_not_break_parameter_parsing - assert_equal( - [['message[body]', 'http://foo.com/?a=b&c=d']], - request_proxy({ :message => { :body => 'http://foo.com/?a=b&c=d'}}).parameters_for_signature - ) - end - - def test_parameter_keys_should_preserve_brackets_from_array - assert_equal( - [["foo[]", "123"], ["foo[]", "456"]], - request_proxy({ :foo => [123, 456] }).parameters_for_signature.sort - ) - end - - def test_query_string_parameter_values_should_be_cgi_unescaped - request = request_proxy do |r| - r.env['QUERY_STRING'] = 'url=http%3A%2F%2Ffoo.com%2F%3Fa%3Db%26c%3Dd' - end - assert_equal( - [['url', 'http://foo.com/?a=b&c=d']], - request.parameters_for_signature.sort - ) - end -end diff --git a/vendor/oauth-0.3.2/test/test_consumer.rb b/vendor/oauth-0.3.2/test/test_consumer.rb deleted file mode 100644 index 580ffcd4a..000000000 --- a/vendor/oauth-0.3.2/test/test_consumer.rb +++ /dev/null @@ -1,327 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' -require 'oauth/consumer' -require 'oauth/signature/rsa/sha1' - - -# This performs testing against Andy Smith's test server http://term.ie/oauth/example/ -# Thanks Andy. -# This also means you have to be online to be able to run these. -class ConsumerTest < Test::Unit::TestCase - def setup - @consumer=OAuth::Consumer.new( - 'consumer_key_86cad9', '5888bf0345e5d237', - { - :site=>"http://blabla.bla", - :request_token_path=>"/oauth/example/request_token.php", - :access_token_path=>"/oauth/example/access_token.php", - :authorize_path=>"/oauth/example/authorize.php", - :scheme=>:header, - :http_method=>:get - }) - @token = OAuth::ConsumerToken.new(@consumer,'token_411a7f', '3196ffd991c8ebdb') - @request_uri = URI.parse('http://example.com/test?key=value') - @request_parameters = { 'key' => 'value' } - @nonce = 225579211881198842005988698334675835446 - @timestamp = "1199645624" - @consumer.http=Net::HTTP.new(@request_uri.host, @request_uri.port) - end - - def test_initializer - assert_equal "consumer_key_86cad9",@consumer.key - assert_equal "5888bf0345e5d237",@consumer.secret - assert_equal "http://blabla.bla",@consumer.site - assert_equal "/oauth/example/request_token.php",@consumer.request_token_path - assert_equal "/oauth/example/access_token.php",@consumer.access_token_path - assert_equal "http://blabla.bla/oauth/example/request_token.php",@consumer.request_token_url - assert_equal "http://blabla.bla/oauth/example/access_token.php",@consumer.access_token_url - assert_equal "http://blabla.bla/oauth/example/authorize.php",@consumer.authorize_url - assert_equal :header,@consumer.scheme - assert_equal :get,@consumer.http_method - end - - def test_defaults - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://twitter.com" - }) - assert_equal "key",@consumer.key - assert_equal "secret",@consumer.secret - assert_equal "http://twitter.com",@consumer.site - assert_equal "/oauth/request_token",@consumer.request_token_path - assert_equal "/oauth/access_token",@consumer.access_token_path - assert_equal "http://twitter.com/oauth/request_token",@consumer.request_token_url - assert_equal "http://twitter.com/oauth/access_token",@consumer.access_token_url - assert_equal "http://twitter.com/oauth/authorize",@consumer.authorize_url - assert_equal :header,@consumer.scheme - assert_equal :post,@consumer.http_method - end - - def test_override_paths - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://twitter.com", - :request_token_url=>"http://oauth.twitter.com/request_token", - :access_token_url=>"http://oauth.twitter.com/access_token", - :authorize_url=>"http://site.twitter.com/authorize" - }) - assert_equal "key",@consumer.key - assert_equal "secret",@consumer.secret - assert_equal "http://twitter.com",@consumer.site - assert_equal "/oauth/request_token",@consumer.request_token_path - assert_equal "/oauth/access_token",@consumer.access_token_path - assert_equal "http://oauth.twitter.com/request_token",@consumer.request_token_url - assert_equal "http://oauth.twitter.com/access_token",@consumer.access_token_url - assert_equal "http://site.twitter.com/authorize",@consumer.authorize_url - assert_equal :header,@consumer.scheme - assert_equal :post,@consumer.http_method - end - - def test_that_signing_auth_headers_on_get_requests_works - request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) - @token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'GET', request.method - assert_equal '/test?key=value', request.path - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_setting_signature_method_on_consumer_effects_signing - require 'oauth/signature/plaintext' - request = Net::HTTP::Get.new(@request_uri.path) - consumer = @consumer.dup - consumer.options[:signature_method] = 'PLAINTEXT' - token = OAuth::ConsumerToken.new(consumer, 'token_411a7f', '3196ffd991c8ebdb') - token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) - - assert_no_match( /oauth_signature_method="HMAC-SHA1"/, request['authorization']) - assert_match( /oauth_signature_method="PLAINTEXT"/, request['authorization']) - end - - def test_that_setting_signature_method_on_consumer_effects_signature_base_string - require 'oauth/signature/plaintext' - request = Net::HTTP::Get.new(@request_uri.path) - consumer = @consumer.dup - consumer.options[:signature_method] = 'PLAINTEXT' - - request = Net::HTTP::Get.new('/') - signature_base_string = consumer.signature_base_string(request) - - assert_no_match( /HMAC-SHA1/, signature_base_string) - assert_equal( "#{consumer.secret}%26", signature_base_string) - end - - def test_that_plaintext_signature_works - require 'oauth/signature/plaintext' - consumer = OAuth::Consumer.new("key", "secret", - :site => "http://term.ie", :signature_method => 'PLAINTEXT') - access_token = OAuth::AccessToken.new(consumer, 'accesskey', 'accesssecret') - response = access_token.get("/oauth/example/echo_api.php?echo=hello") - - assert_equal 'echo=hello', response.body - end - - def test_that_signing_auth_headers_on_post_requests_works - request = Net::HTTP::Post.new(@request_uri.path) - request.set_form_data( @request_parameters ) - @token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) -# assert_equal "",request.oauth_helper.signature_base_string - - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal 'key=value', request.body - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_signing_post_params_works - request = Net::HTTP::Post.new(@request_uri.path) - request.set_form_data( @request_parameters ) - @token.sign!(request, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") - assert_equal nil, request['authorization'] - end - - def test_that_using_auth_headers_on_get_on_create_signed_requests_works - request=@consumer.create_signed_request(:get,@request_uri.path+ "?" + request_parameters_to_s,@token,{:nonce => @nonce, :timestamp => @timestamp},@request_parameters) - - assert_equal 'GET', request.method - assert_equal '/test?key=value', request.path - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_using_auth_headers_on_post_on_create_signed_requests_works - request=@consumer.create_signed_request(:post,@request_uri.path,@token,{:nonce => @nonce, :timestamp => @timestamp},@request_parameters,{}) - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal 'key=value', request.body - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_signing_post_params_works_2 - request=@consumer.create_signed_request(:post,@request_uri.path,@token,{:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp},@request_parameters,{}) - - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") - assert_equal nil, request['authorization'] - end - - def test_step_by_step_token_request - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://term.ie", - :request_token_path=>"/oauth/example/request_token.php", - :access_token_path=>"/oauth/example/access_token.php", - :authorize_path=>"/oauth/example/authorize.php", - :scheme=>:header - }) - options={:nonce=>'nonce',:timestamp=>Time.now.to_i.to_s} - - request = Net::HTTP::Get.new("/oauth/example/request_token.php") - signature_base_string=@consumer.signature_base_string(request,nil,options) - assert_equal "GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3D#{options[:nonce]}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D#{options[:timestamp]}%26oauth_version%3D1.0",signature_base_string - @consumer.sign!(request, nil,options) - - assert_equal 'GET', request.method - assert_equal nil, request.body - response=@consumer.http.request(request) - assert_equal "200",response.code - assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body - end - - def test_get_token_sequence - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://term.ie", - :request_token_path=>"/oauth/example/request_token.php", - :access_token_path=>"/oauth/example/access_token.php", - :authorize_path=>"/oauth/example/authorize.php" - }) - assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url - assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url - - assert !@consumer.request_token_url?, "Should not use fully qualified request token url" - assert !@consumer.access_token_url?, "Should not use fully qualified access token url" - assert !@consumer.authorize_url?, "Should not use fully qualified url" - - @request_token=@consumer.get_request_token - assert_not_nil @request_token - assert_equal "requestkey",@request_token.token - assert_equal "requestsecret",@request_token.secret - assert_equal "http://term.ie/oauth/example/authorize.php?oauth_token=requestkey",@request_token.authorize_url - - @access_token=@request_token.get_access_token - assert_not_nil @access_token - assert_equal "accesskey",@access_token.token - assert_equal "accesssecret",@access_token.secret - - @response=@access_token.get("/oauth/example/echo_api.php?ok=hello&test=this") - assert_not_nil @response - assert_equal "200",@response.code - assert_equal( "ok=hello&test=this",@response.body) - - @response=@access_token.post("/oauth/example/echo_api.php",{'ok'=>'hello','test'=>'this'}) - assert_not_nil @response - assert_equal "200",@response.code - assert_equal( "ok=hello&test=this",@response.body) - end - - def test_get_token_sequence_using_fqdn - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://term.ie", - :request_token_url=>"http://term.ie/oauth/example/request_token.php", - :access_token_url=>"http://term.ie/oauth/example/access_token.php", - :authorize_url=>"http://term.ie/oauth/example/authorize.php" - }) - assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url - assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url - - assert @consumer.request_token_url?, "Should use fully qualified request token url" - assert @consumer.access_token_url?, "Should use fully qualified access token url" - assert @consumer.authorize_url?, "Should use fully qualified url" - - @request_token=@consumer.get_request_token - assert_not_nil @request_token - assert_equal "requestkey",@request_token.token - assert_equal "requestsecret",@request_token.secret - assert_equal "http://term.ie/oauth/example/authorize.php?oauth_token=requestkey",@request_token.authorize_url - - @access_token=@request_token.get_access_token - assert_not_nil @access_token - assert_equal "accesskey",@access_token.token - assert_equal "accesssecret",@access_token.secret - - @response=@access_token.get("/oauth/example/echo_api.php?ok=hello&test=this") - assert_not_nil @response - assert_equal "200",@response.code - assert_equal( "ok=hello&test=this",@response.body) - - @response=@access_token.post("/oauth/example/echo_api.php",{'ok'=>'hello','test'=>'this'}) - assert_not_nil @response - assert_equal "200",@response.code - assert_equal( "ok=hello&test=this",@response.body) - end - - - # This test does an actual https request (the result doesn't matter) - # to initialize the same way as get_request_token does. Can be any - # site that supports https. - # - # It also generates "warning: using default DH parameters." which I - # don't know how to get rid of -# def test_serialization_with_https -# consumer = OAuth::Consumer.new('token', 'secret', :site => 'https://plazes.net') -# consumer.http.verify_mode = OpenSSL::SSL::VERIFY_NONE -# consumer.http.get('/') -# -# assert_nothing_raised do -# # Specifically this should not raise TypeError: no marshal_dump -# # is defined for class OpenSSL::SSL::SSLContext -# Marshal.dump(consumer) -# end -# end -# - def test_get_request_token_with_custom_arguments - @consumer=OAuth::Consumer.new( - "key", - "secret", - { - :site=>"http://term.ie", - :request_token_path=>"/oauth/example/request_token.php", - :access_token_path=>"/oauth/example/access_token.php", - :authorize_path=>"/oauth/example/authorize.php" - }) - - - debug = "" - @consumer.http.set_debug_output(debug) - - # get_request_token should receive our custom request_options and *arguments parameters from get_request_token. - @consumer.get_request_token({}, {:scope => "http://www.google.com/calendar/feeds http://picasaweb.google.com/data"}) - - # Because this is a POST request, create_http_request should take the first element of *arguments - # and turn it into URL-encoded data in the body of the POST. - assert_match( /^<- "scope=http%3a%2f%2fwww.google.com%2fcalendar%2ffeeds%20http%3a%2f%2fpicasaweb.google.com%2fdata"/, - debug) - end - - protected - - def request_parameters_to_s - @request_parameters.map { |k,v| "#{k}=#{v}" }.join("&") - end - -end diff --git a/vendor/oauth-0.3.2/test/test_helper.rb b/vendor/oauth-0.3.2/test/test_helper.rb deleted file mode 100644 index 940e32b0b..000000000 --- a/vendor/oauth-0.3.2/test/test_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test/unit' -require File.dirname(__FILE__) + '/../lib/oauth' - -begin - # load redgreen unless running from within TextMate (in which case ANSI - # color codes mess with the output) - require 'redgreen' unless ENV['TM_CURRENT_LINE'] -rescue LoadError - nil -end diff --git a/vendor/oauth-0.3.2/test/test_net_http_client.rb b/vendor/oauth-0.3.2/test/test_net_http_client.rb deleted file mode 100644 index 7e41f3c84..000000000 --- a/vendor/oauth-0.3.2/test/test_net_http_client.rb +++ /dev/null @@ -1,169 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/client/net_http' - -class NetHTTPClientTest < Test::Unit::TestCase - - def setup - @consumer = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237') - @token = OAuth::Token.new('token_411a7f', '3196ffd991c8ebdb') - @request_uri = URI.parse('http://example.com/test?key=value') - @request_parameters = { 'key' => 'value' } - @nonce = 225579211881198842005988698334675835446 - @timestamp = "1199645624" - @http = Net::HTTP.new(@request_uri.host, @request_uri.port) - end - - def test_that_using_auth_headers_on_get_requests_works - request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) - request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'GET', request.method - assert_equal '/test?key=value', request.path - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_using_auth_headers_on_post_requests_works - request = Net::HTTP::Post.new(@request_uri.path) - request.set_form_data( @request_parameters ) - request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal 'key=value', request.body - assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort - end - - def test_that_using_post_params_works - request = Net::HTTP::Post.new(@request_uri.path) - request.set_form_data( @request_parameters ) - request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'POST', request.method - assert_equal '/test', request.path - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") - assert_equal nil, request['authorization'] - end - - def test_that_using_get_params_works - request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) - request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'GET', request.method - uri = URI.parse(request.path) - assert_equal '/test', uri.path - assert_equal nil, uri.fragment - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=1oO2izFav1GP4kEH2EskwXkCRFg%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join("&") - assert_equal nil, request['authorization'] - end - - def test_that_using_get_params_works_with_post_requests - request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s) - request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'POST', request.method - uri = URI.parse(request.path) - assert_equal '/test', uri.path - assert_equal nil, uri.fragment - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&') - assert_equal nil, request.body - assert_equal nil, request['authorization'] - end - - def test_that_using_get_params_works_with_post_requests_that_have_post_bodies - request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s) - request.set_form_data( { 'key2' => 'value2' } ) - request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp}) - - assert_equal 'POST', request.method - uri = URI.parse(request.path) - assert_equal '/test', uri.path - assert_equal nil, uri.fragment - assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=4kSU8Zd1blWo3W6qJH7eaRTMkg0%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&') - assert_equal "key2=value2", request.body - assert_equal nil, request['authorization'] - end - - - def test_example_from_specs - consumer=OAuth::Consumer.new("dpf43f3p2l4k3l03","kd94hf93k423kf44") - token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00') - request_uri = URI.parse('http://photos.example.net/photos?file=vacation.jpg&size=original') - nonce = 'kllo9940pd9333jh' - timestamp = "1191242096" - http = Net::HTTP.new(request_uri.host, request_uri.port) - - request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query) - signature_base_string=request.signature_base_string(http, consumer, token, {:nonce => nonce, :timestamp => timestamp}) - assert_equal 'GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal',signature_base_string - -# request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query) - request.oauth!(http, consumer, token, {:nonce => nonce, :timestamp => timestamp,:realm=>"http://photos.example.net/"}) - - assert_equal 'GET', request.method - assert_equal 'OAuth realm="http://photos.example.net/", oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="nnch734d00sl2jdk", oauth_timestamp="1191242096", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"'.split(', ').sort, request['authorization'].split(', ').sort - - end - - def test_step_by_step_token_request - consumer=OAuth::Consumer.new( - "key", - "secret") - request_uri = URI.parse('http://term.ie/oauth/example/request_token.php') - nonce = rand(2**128).to_s - timestamp = Time.now.to_i.to_s - http = Net::HTTP.new(request_uri.host, request_uri.port) - - request = Net::HTTP::Get.new(request_uri.path) - signature_base_string=request.signature_base_string(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp}) - assert_equal "GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3D#{nonce}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D#{timestamp}%26oauth_version%3D1.0",signature_base_string - -# request = Net::HTTP::Get.new(request_uri.path) - request.oauth!(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp}) - assert_equal 'GET', request.method - assert_nil request.body - assert_nil request['authorization'] -# assert_equal 'OAuth oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="", oauth_timestamp="'+timestamp+'", oauth_consumer_key="key", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"', request['authorization'] - - response=http.request(request) - assert_equal "200",response.code -# assert_equal request['authorization'],response.body - assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body - end - - def test_that_put_bodies_not_signed - request = Net::HTTP::Put.new(@request_uri.path) - request.body = "baz" - request["Content-Type"] = "application/xml" - signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) - assert_equal "PUT&http%3A%2F%2Fexample.com%2Ftest&oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string - end - - def test_that_put_bodies_not_signed_even_if_form_urlencoded - request = Net::HTTP::Put.new(@request_uri.path) - request.set_form_data( { 'key2' => 'value2' } ) - signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) - assert_equal "PUT&http%3A%2F%2Fexample.com%2Ftest&oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string - end - - def test_that_post_bodies_signed_if_form_urlencoded - request = Net::HTTP::Post.new(@request_uri.path) - request.set_form_data( { 'key2' => 'value2' } ) - signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) - assert_equal "POST&http%3A%2F%2Fexample.com%2Ftest&key2%3Dvalue2%26oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string - end - - def test_that_post_bodies_not_signed_if_other_content_type - request = Net::HTTP::Post.new(@request_uri.path) - request.body = "baz" - request["Content-Type"] = "application/xml" - signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) - assert_equal "POST&http%3A%2F%2Fexample.com%2Ftest&oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string - end - - protected - - def request_parameters_to_s - @request_parameters.map { |k,v| "#{k}=#{v}" }.join("&") - end - -end diff --git a/vendor/oauth-0.3.2/test/test_net_http_request_proxy.rb b/vendor/oauth-0.3.2/test/test_net_http_request_proxy.rb deleted file mode 100644 index 1358a5aec..000000000 --- a/vendor/oauth-0.3.2/test/test_net_http_request_proxy.rb +++ /dev/null @@ -1,38 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/request_proxy/net_http' - -class NetHTTPRequestProxyTest < Test::Unit::TestCase - - def test_that_proxy_simple_get_request_works - request = Net::HTTP::Get.new('/test?key=value') - request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'}) - - expected_parameters = {'key' => ['value']} - assert_equal expected_parameters, request_proxy.parameters - assert_equal 'http://example.com/test', request_proxy.normalized_uri - assert_equal 'GET', request_proxy.method - end - - def test_that_proxy_simple_post_request_works - request = Net::HTTP::Post.new('/test') - params = {'key' => 'value'} - request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) - - expected_parameters = {'key' => ['value']} - assert_equal expected_parameters, request_proxy.parameters - assert_equal 'http://example.com/test', request_proxy.normalized_uri - assert_equal 'POST', request_proxy.method - end - - def test_that_proxy_post_and_get_request_works - request = Net::HTTP::Post.new('/test?key=value') - params = {'key2' => 'value2'} - request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => params}) - - expected_parameters = {'key' => ['value'], 'key2' => ['value2']} - assert_equal expected_parameters, request_proxy.parameters - assert_equal 'http://example.com/test', request_proxy.normalized_uri - assert_equal 'POST', request_proxy.method - end - -end diff --git a/vendor/oauth-0.3.2/test/test_signature.rb b/vendor/oauth-0.3.2/test/test_signature.rb deleted file mode 100644 index 4772301af..000000000 --- a/vendor/oauth-0.3.2/test/test_signature.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper.rb' - -class TestOauth < Test::Unit::TestCase - - def setup - end - - def test_truth - assert true - end -end diff --git a/vendor/oauth-0.3.2/website/index.html b/vendor/oauth-0.3.2/website/index.html deleted file mode 100644 index 47d989a1d..000000000 --- a/vendor/oauth-0.3.2/website/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - Ruby OAuth GEM - - - - - - -
- -

Ruby OAuth GEM

-
-

Get Version

- 0.3.2 -
-

What

-

This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.

-

See the OAuth specs

-

Installing

-

sudo gem install oauth

-

You can also install it from the oauth rubyforge project.

-

The source code is now hosted on the OAuth GitHub Project

-

The basics

-

This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.

-

As a matter of fact it has been pulled out from an OAuth Rails Plugin which now requires this GEM.

-

Demonstration of usage

-

Create a new consumer instance by passing it a configuration hash:

-
@consumer=OAuth::Consumer.new( "key","secret", {
-    :site=>"https://agree2"
-    })
-

Start the process by requesting a token

-
@request_token=@consumer.get_request_token
-session[:request_token]=@request_token
-redirect_to @request_token.authorize_url
-

When user returns create an access_token

-
@access_token=@request_token.get_access_token
-@photos=@access_token.get('/photos.xml')
-

For more detailed instructions I have written this OAuth Client Tutorial and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider.

-

Finally be sure to check out the OAuth RDoc Manual.

-

Documentation Wiki

-

There is some documentation on the Google Code project for the OAuth Rails Plugin :

- -

Forum

-

http://groups.google.com/group/oauth-ruby

-

How to submit patches

-

Read the 8 steps for fixing other people’s code.

-

The source code is now hosted on the OAuth GitHub Project

-

To submit a patch, please fork the oauth project and create a patch with tests. Once you’re happy with it send a pull request and post a message to the google group.

-

License

-

This code is free to use under the terms of the MIT license.

-

Contact

-

Comments are welcome. Send an email to Pelle Braendgaard email via the OAuth Ruby mailing list

-

- FIXME full name, 9th September 2008
- Theme extended from Paul Battley -

-
- - - - - diff --git a/vendor/oauth-0.3.2/website/index.txt b/vendor/oauth-0.3.2/website/index.txt deleted file mode 100644 index 0beea2a81..000000000 --- a/vendor/oauth-0.3.2/website/index.txt +++ /dev/null @@ -1,73 +0,0 @@ -h1. Ruby OAuth GEM - -h2. What - -This is a RubyGem for implementing both OAuth clients and servers in Ruby applications. - -See the "OAuth specs":http://oauth.net/core/1.0/ - -h2. Installing - -
sudo gem install oauth
- -You can also install it from the "oauth rubyforge project":http://rubyforge.org/projects/oauth/. - -The source code is now hosted on the "OAuth GitHub Project":http://github.com/pelle/oauth/tree/master - -h2. The basics - -This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin. - -As a matter of fact it has been pulled out from an "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ which now requires this GEM. - -h2. Demonstration of usage - -Create a new consumer instance by passing it a configuration hash: - -
@consumer=OAuth::Consumer.new( "key","secret", {
-    :site=>"https://agree2"
-    })
- -Start the process by requesting a token - -
@request_token=@consumer.get_request_token
-session[:request_token]=@request_token
-redirect_to @request_token.authorize_url
- -When user returns create an access_token - -
@access_token=@request_token.get_access_token
-@photos=@access_token.get('/photos.xml')
- -For more detailed instructions I have written this "OAuth Client Tutorial":http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider. - -Finally be sure to check out the "OAuth RDoc Manual":http://oauth.rubyforge.org/rdoc/. - -h2. Documentation Wiki - -There is some documentation on the Google Code project for the "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ : - -* "RequestToken":http://code.google.com/p/oauth-plugin/wiki/RequestToken -* "AccessToken":http://code.google.com/p/oauth-plugin/wiki/AccessToken - -h2. Forum - -"http://groups.google.com/group/oauth-ruby":http://groups.google.com/group/oauth-ruby - - -h2. How to submit patches - -Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/. - -The source code is now hosted on the "OAuth GitHub Project":http://github.com/pelle/oauth/tree/master - -To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group. - -h2. License - -This code is free to use under the terms of the MIT license. - -h2. Contact - -Comments are welcome. Send an email to "Pelle Braendgaard":mailto:pelleb@gmail.com email via the "OAuth Ruby mailing list":http://groups.google.com/group/oauth-ruby - diff --git a/vendor/oauth-0.3.2/website/javascripts/rounded_corners_lite.inc.js b/vendor/oauth-0.3.2/website/javascripts/rounded_corners_lite.inc.js deleted file mode 100644 index afc3ea327..000000000 --- a/vendor/oauth-0.3.2/website/javascripts/rounded_corners_lite.inc.js +++ /dev/null @@ -1,285 +0,0 @@ - - /**************************************************************** - * * - * curvyCorners * - * ------------ * - * * - * This script generates rounded corners for your divs. * - * * - * Version 1.2.9 * - * Copyright (c) 2006 Cameron Cooke * - * By: Cameron Cooke and Tim Hutchison. * - * * - * * - * Website: http://www.curvycorners.net * - * Email: info@totalinfinity.com * - * Forum: http://www.curvycorners.net/forum/ * - * * - * * - * This library is free software; you can redistribute * - * it and/or modify it under the terms of the GNU * - * Lesser General Public License as published by the * - * Free Software Foundation; either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will * - * be useful, but WITHOUT ANY WARRANTY; without even the * - * implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU Lesser General Public * - * License for more details. * - * * - * You should have received a copy of the GNU Lesser * - * General Public License along with this library; * - * Inc., 59 Temple Place, Suite 330, Boston, * - * MA 02111-1307 USA * - * * - ****************************************************************/ - -var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners() -{ if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string") -{ var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);} -else -{ var startIndex = 1; var boxCol = arguments;} -var curvyCornersCol = new Array(); if(arguments[0].validTags) -var validElements = arguments[0].validTags; else -var validElements = ["div"]; for(var i = startIndex, j = boxCol.length; i < j; i++) -{ var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false) -{ curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);} -} -this.objects = curvyCornersCol; this.applyCornersToAll = function() -{ for(var x = 0, k = this.objects.length; x < k; x++) -{ this.objects[x].applyCorners();} -} -} -function curvyObject() -{ this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0) -this.box.innerHTML = ""; this.applyCorners = function() -{ for(var t = 0; t < 2; t++) -{ switch(t) -{ case 0: -if(this.settings.tl || this.settings.tr) -{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);} -break; case 1: -if(this.settings.bl || this.settings.br) -{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);} -break;} -} -if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners) -{ if(i > -1 < 4) -{ var cc = corners[i]; if(!this.settings[cc]) -{ if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) -{ var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "") -newCorner.style.backgroundColor = this.boxColour; else -newCorner.style.backgroundImage = this.backgroundImage; switch(cc) -{ case "tl": -newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr": -newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl": -newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br": -newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px" -newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;} -} -} -else -{ if(this.masterCorners[this.settings[cc].radius]) -{ var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);} -else -{ var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) -{ if((intx +1) >= borderRadius) -var y1 = -1; else -var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j) -{ if((intx) >= borderRadius) -var y2 = -1; else -var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j) -var y3 = -1; else -var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);} -if((intx) >= j) -var y4 = -1; else -var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j) -{ for(var inty = (y1 + 1); inty < y2; inty++) -{ if(this.settings.antiAlias) -{ if(this.backgroundImage != "") -{ var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30) -{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);} -else -{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);} -} -else -{ var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);} -} -} -if(this.settings.antiAlias) -{ if(y3 >= y2) -{ if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);} -} -else -{ if(y3 >= y1) -{ this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);} -} -var outsideColour = this.borderColour;} -else -{ var outsideColour = this.boxColour; var y3 = y1;} -if(this.settings.antiAlias) -{ for(var inty = (y3 + 1); inty < y4; inty++) -{ this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);} -} -} -this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);} -if(cc != "br") -{ for(var t = 0, k = newCorner.childNodes.length; t < k; t++) -{ var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";} -if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";} -switch(cc) -{ case "tr": -pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl": -pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl": -pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;} -} -} -} -if(newCorner) -{ switch(cc) -{ case "tl": -if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr": -if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl": -if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br": -if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;} -} -} -} -var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) -radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff) -{ if(z == "t" || z == "b") -{ if(radiusDiff[z]) -{ var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px" -newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType) -{ case "tl": -newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr": -newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl": -newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br": -newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;} -} -var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z) -{ case "t": -if(this.topContainer) -{ if(this.settings.tl.radius && this.settings.tr.radius) -{ newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "") -newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);} -this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";} -break; case "b": -if(this.bottomContainer) -{ if(this.settings.bl.radius && this.settings.br.radius) -{ newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "") -newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);} -} -break;} -} -} -if(this.settings.autoPad == true && this.boxPadding > 0) -{ var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding) -contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding) -contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);} -} -this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) -{ var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "") -{ pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";} -else -{ pixel.style.backgroundColor = colour;} -if (transAmount != 100) -setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);} -} -function insertAfter(parent, node, referenceNode) -{ parent.insertBefore(node, referenceNode.nextSibling);} -function BlendColour(Col1, Col2, Col1Fraction) -{ var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);} -function IntToHex(strNum) -{ base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;} -function MakeHex(x) -{ if((x >= 0) && (x <= 9)) -{ return x;} -else -{ switch(x) -{ case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";} -} -} -function pixelFraction(x, y, r) -{ var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1))) -{ whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;} -var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1))) -{ whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;} -var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1))) -{ whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;} -var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1))) -{ whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;} -switch (whatsides) -{ case "LeftRight": -pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight": -pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom": -pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom": -pixelfraction = (yvalues[0]*xvalues[1])/2; break; default: -pixelfraction = 1;} -return pixelfraction;} -function rgb2Hex(rgbColour) -{ try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);} -catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");} -return hexColour;} -function rgb2Array(rgbColour) -{ var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;} -function setOpacity(obj, opacity) -{ opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME") -{ var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";} -else if(typeof(obj.style.opacity) != "undefined") -{ obj.style.opacity = opacity/100;} -else if(typeof(obj.style.MozOpacity) != "undefined") -{ obj.style.MozOpacity = opacity/100;} -else if(typeof(obj.style.filter) != "undefined") -{ obj.style.filter = "alpha(opacity:" + opacity + ")";} -else if(typeof(obj.style.KHTMLOpacity) != "undefined") -{ obj.style.KHTMLOpacity = opacity/100;} -} -function inArray(array, value) -{ for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;} -return false;} -function inArrayKey(array, value) -{ for(key in array){ if(key === value) return true;} -return false;} -function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;} -else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;} -else { elm['on' + evType] = fn;} -} -function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");} -} -function format_colour(colour) -{ var returnColour = "#ffffff"; if(colour != "" && colour != "transparent") -{ if(colour.substr(0, 3) == "rgb") -{ returnColour = rgb2Hex(colour);} -else if(colour.length == 4) -{ returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);} -else -{ returnColour = colour;} -} -return returnColour;} -function get_style(obj, property, propertyNS) -{ try -{ if(obj.currentStyle) -{ var returnVal = eval("obj.currentStyle." + property);} -else -{ if(isSafari && obj.style.display == "none") -{ obj.style.display = ""; var wasHidden = true;} -var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden) -{ obj.style.display = "none";} -} -} -catch(e) -{ } -return returnVal;} -function getElementsByClass(searchClass, node, tag) -{ var classElements = new Array(); if(node == null) -node = document; if(tag == null) -tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++) -{ if(pattern.test(els[i].className)) -{ classElements[j] = els[i]; j++;} -} -return classElements;} -function newCurvyError(errorMessage) -{ return new Error("curvyCorners Error:\n" + errorMessage) -} diff --git a/vendor/oauth-0.3.2/website/stylesheets/screen.css b/vendor/oauth-0.3.2/website/stylesheets/screen.css deleted file mode 100644 index 2c84cd00c..000000000 --- a/vendor/oauth-0.3.2/website/stylesheets/screen.css +++ /dev/null @@ -1,138 +0,0 @@ -body { - background-color: #E1D1F1; - font-family: "Georgia", sans-serif; - font-size: 16px; - line-height: 1.6em; - padding: 1.6em 0 0 0; - color: #333; -} -h1, h2, h3, h4, h5, h6 { - color: #444; -} -h1 { - font-family: sans-serif; - font-weight: normal; - font-size: 4em; - line-height: 0.8em; - letter-spacing: -0.1ex; - margin: 5px; -} -li { - padding: 0; - margin: 0; - list-style-type: square; -} -a { - color: #5E5AFF; - background-color: #DAC; - font-weight: normal; - text-decoration: underline; -} -blockquote { - font-size: 90%; - font-style: italic; - border-left: 1px solid #111; - padding-left: 1em; -} -.caps { - font-size: 80%; -} - -#main { - width: 45em; - padding: 0; - margin: 0 auto; -} -.coda { - text-align: right; - color: #77f; - font-size: smaller; -} - -table { - font-size: 90%; - line-height: 1.4em; - color: #ff8; - background-color: #111; - padding: 2px 10px 2px 10px; - border-style: dashed; -} - -th { - color: #fff; -} - -td { - padding: 2px 10px 2px 10px; -} - -.success { - color: #0CC52B; -} - -.failed { - color: #E90A1B; -} - -.unknown { - color: #995000; -} -pre, code { - font-family: monospace; - font-size: 90%; - line-height: 1.4em; - color: #ff8; - background-color: #111; - padding: 2px 10px 2px 10px; -} -.comment { color: #aaa; font-style: italic; } -.keyword { color: #eff; font-weight: bold; } -.punct { color: #eee; font-weight: bold; } -.symbol { color: #0bb; } -.string { color: #6b4; } -.ident { color: #ff8; } -.constant { color: #66f; } -.regex { color: #ec6; } -.number { color: #F99; } -.expr { color: #227; } - -#version { - float: right; - text-align: right; - font-family: sans-serif; - font-weight: normal; - background-color: #B3ABFF; - color: #141331; - padding: 15px 20px 10px 20px; - margin: 0 auto; - margin-top: 15px; - border: 3px solid #141331; -} - -#version .numbers { - display: block; - font-size: 4em; - line-height: 0.8em; - letter-spacing: -0.1ex; - margin-bottom: 15px; -} - -#version p { - text-decoration: none; - color: #141331; - background-color: #B3ABFF; - margin: 0; - padding: 0; -} - -#version a { - text-decoration: none; - color: #141331; - background-color: #B3ABFF; -} - -.clickable { - cursor: pointer; - cursor: hand; -} - diff --git a/vendor/oauth-0.3.2/website/template.rhtml b/vendor/oauth-0.3.2/website/template.rhtml deleted file mode 100644 index e8517350d..000000000 --- a/vendor/oauth-0.3.2/website/template.rhtml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - <%= title %> - - - - - - -
- -

<%= title %>

-
-

Get Version

- <%= version %> -
- <%= body %> -

- FIXME full name, <%= modified.pretty %>
- Theme extended from Paul Battley -

-
- - - - - diff --git a/vendor/oauth-0.4.4/.gitignore b/vendor/oauth-0.4.4/.gitignore new file mode 100644 index 000000000..abf26103f --- /dev/null +++ b/vendor/oauth-0.4.4/.gitignore @@ -0,0 +1,3 @@ +pkg/* +_site +.bundle \ No newline at end of file diff --git a/vendor/oauth-0.4.4/Gemfile b/vendor/oauth-0.4.4/Gemfile new file mode 100644 index 000000000..58f7099cd --- /dev/null +++ b/vendor/oauth-0.4.4/Gemfile @@ -0,0 +1,13 @@ +source :gemcutter + +group :development do + gem 'jeweler' +end + +group :test do + gem 'actionpack', '2.3.8' + gem 'mocha', '>=0.9.8' + gem 'typhoeus', '>=0.1.13' + gem 'em-http-request', "0.2.11" + gem 'curb', ">= 0.6.6.0" +end diff --git a/vendor/oauth-0.4.4/Gemfile.lock b/vendor/oauth-0.4.4/Gemfile.lock new file mode 100644 index 000000000..e762a0ebd --- /dev/null +++ b/vendor/oauth-0.4.4/Gemfile.lock @@ -0,0 +1,40 @@ +GEM + remote: http://rubygems.org/ + specs: + actionpack (2.3.8) + activesupport (= 2.3.8) + rack (~> 1.1.0) + activesupport (2.3.8) + addressable (2.2.0) + curb (0.7.7.1) + em-http-request (0.2.11) + addressable (>= 2.0.0) + eventmachine (>= 0.12.9) + eventmachine (0.12.10) + gemcutter (0.4.1) + json_pure + git (1.2.5) + jeweler (1.4.0) + gemcutter (>= 0.1.0) + git (>= 1.2.5) + rubyforge (>= 2.0.0) + json_pure (1.4.3) + mocha (0.9.8) + rake + rack (1.1.0) + rake (0.8.7) + rubyforge (2.0.4) + json_pure (>= 1.1.7) + typhoeus (0.1.31) + rack + +PLATFORMS + ruby + +DEPENDENCIES + actionpack (= 2.3.8) + curb (>= 0.6.6.0) + em-http-request (= 0.2.11) + jeweler + mocha (>= 0.9.8) + typhoeus (>= 0.1.13) diff --git a/vendor/oauth-0.4.4/HISTORY b/vendor/oauth-0.4.4/HISTORY new file mode 100644 index 000000000..896d3175d --- /dev/null +++ b/vendor/oauth-0.4.4/HISTORY @@ -0,0 +1,150 @@ +=== 0.4.4 2010-10-31 + +* Fix LoadError rescue in tests: return can't be used in this context (Hans de Graaff) +* HTTP headers should be strings. (seancribbs) +* ensure consumer uri gets set back to original config even if an error occurs (Brian Finney) +* Yahoo uses & to split records in OAuth headers (Brian Finney) +* Added support for Rails 3 in client/action_controller_request (Pelle) + +== 0.4.3 2010-09-01 + +* Fix for em-http proxy (ichverstehe) + +== 0.4.2 2010-08-13 + +* Fixed compatibility with Ruby 1.9.2 (ecavazos) +* Fixed the em-http request proxy (Joshua Hull) +* Fix for oauth proxy string manipulation (Jakub Suder) +* Added Bundler (rc) Gemfile for easier dev/testing + +== 0.4.1 2010-06-16 + +* Added support for using OAuth with proxies (Marsh Gardiner) +* Rails 3 Compatibility fixes (Pelle Braendgaard) +* Fixed load errors on tests for missing (non-required) libraries + +== 0.4.0 2010-04-22 + +* Added computation of oauth_body_hash as per OAuth Request Body Hash 1.0 + Draft 4 (Michael Reinsch) +* Added the optional `oauth_session_handle` parameter for the Yahoo implementation (Will Bailey) +* Better marshalling implementation (Yoan Blanc) +* Added optional block to OAuth::Consumer.get_*_token (Neill Pearman) +* Exclude `oauth_callback` with :exclude_callback (Neill Pearman) +* Strip extraneous spaces and line breaks from access_token responses + (observed in the wild with Yahoo!'s OAuth+OpenID hybrid) (Eric Hartmann) +* Stop double-escaping PLAINTEXT signatures (Jimmy Zimmerman) +* OAuth::Client::Helper won't override the specified `oauth_version` + (Philip Kromer) +* Support for Ruby 1.9 (Aaron Quint, Corey Donahoe, et al) +* Fixed an encoding / multibyte issue (成田 一生) +* Replaced hoe with Jeweler (Aaron Quint) +* Support for Typhoeus (Bill Kocik) +* Support for em-http (EventMachine) (Darcy Laycock) +* Support for curb (André Luis Leal Cardoso Junior) +* New website (Aaron Quint) + +== 0.3.6 2009-09-14 + +* Added -B CLI option to use the :body authentication scheme (Seth) +* Respect `--method` in `authorize` CLI command (Seth) +* Support POST and PUT with raw bodies (Yu-Shan Fung et al) +* Test clean-up (Xavier Shay, Hannes Tydén) +* Added :ca_file consumer option to allow consumer specific certificate + override. (Pelle) + +== 0.3.5 2009-06-03 + +* `query` CLI command to access protected resources (Seth) +* Added -H, -Q CLI options for specifying the authentication scheme (Seth) +* Added -O CLI option for specifying a file containing options (Seth) +* Support streamable body contents for large request bodies (Seth Cousins) +* Support for OAuth 1.0a (Seth) +* Added proxy support to OAuth::Consumer (Marshall Huss) +* Added --scope CLI option for Google's 'scope' parameter (Seth) + +== 0.3.4 2009-05-06 + +* OAuth::Client::Helper uses OAuth::VERSION (chadisfaction) +* Fix OAuth::RequestProxy::ActionControllerRequest's handling of params + (Tristan Groléat) + +== 0.3.3 2009-05-04 + +* Corrected OAuth XMPP namespace (Seth) +* Improved error handling for invalid Authorization headers (Matt Sanford) +* Fixed signatures for non-ASCII under $KCODE other than 'u' (Matt Sanford) +* Fixed edge cases in ActionControllerRequestProxy where params were being + incorrectly signed (Marcos Wright Kuhns) +* Support for arguments in OAuth::Consumer#get_access_token (Matt Sanford) +* Add gem version to user-agent header (Matt Sanford) +* Handle input from aggressive form encoding libraries (Matt Wood) + +== 0.3.2 2009-03-23 + +* 2xx statuses should be treated as success (Anders Conbere) +* Support applications using the MethodOverride Rack middleware (László Bácsi) +* `authorize` command for `oauth` CLI (Seth) +* Initial support for Problem Reporting extension (Seth) +* Verify SSL certificates if CA certificates are available (Seth) +* Fixed ActionController parameter escaping behavior (Thiago Arrais, László + Bácsi, Brett Gibson, et al) +* Fixed signature calculation when both options and a block were provided to + OAuth::Signature::Base#initialize (Seth) +* Added help to the 'oauth' CLI (Seth) +* Fixed a problem when attempting to normalize MockRequest URIs (Seth) + +== 0.3.1 2009-1-26 + +* Fixed a problem with relative and absolute token request paths. (Michael + Wood) + +== 0.3.0 2009-1-25 + +* Support ActionController::Request from Edge Rails (László Bácsi) +* Correctly handle multi-valued parameters (Seth) +* Added #normalized_parameters to OAuth::RequestProxy::Base (Pelle) +* OAuth::Signature.sign and friends now yield the RequestProxy instead of the + token when the passed block's arity is 1. (Seth) +* Token requests are made to the configured URL rather than generating a + potentially incorrect one. (Kellan Elliott-McCrea) +* Command-line app for generating signatures. (Seth) +* Improved test-cases and compatibility for encoding issues. (Pelle) + +== 0.2.7 2008-9-10 The lets fix the last release release + +* Fixed plain text signatures (Andrew Arrow) +* Fixed RSA requests using OAuthTokens. (Philip Lipu Tsai) + +== 0.2.6 2008-9-9 The lets RSA release + +* Improved support for Ruby 1.8.7 (Bill Kocik) +* Fixed RSA verification to support RSA providers + now using Ruby and RSA +* Improved RSA testing +* Omit token when signing with RSA +* Added support for 'private_key_file' option for RSA signatures (Chris Mear) +* Fixed several edge cases where params were being incorrectly signed (Scott + Hill) +* Fixed RSA signing (choonkeat) + +== 0.2.2 2008-2-22 Lets actually support SSL release + +* Use HTTPS when required. + +== 0.2 2008-1-19 All together now release + +This is a big release, where we have merged the efforts of various parties into one common library. +This means there are definitely some API changes you should be aware of. They should be minimal +but please have a look at the unit tests. + +== 0.1.2 2007-12-1 + +* Fixed checks for missing OAuth params to improve performance +* Includes Pat's fix for getting the realm out. + +== 0.1.1 2007-11-26 + +* First release as a GEM +* Moved all non-Rails functionality from the Rails plugin: + http://code.google.com/p/oauth-plugin/ diff --git a/vendor/oauth-0.3.2/License.txt b/vendor/oauth-0.4.4/LICENSE similarity index 100% rename from vendor/oauth-0.3.2/License.txt rename to vendor/oauth-0.4.4/LICENSE diff --git a/vendor/oauth-0.3.2/README.rdoc b/vendor/oauth-0.4.4/README.rdoc similarity index 54% rename from vendor/oauth-0.3.2/README.rdoc rename to vendor/oauth-0.4.4/README.rdoc index 7f86a06ac..909ae5554 100644 --- a/vendor/oauth-0.3.2/README.rdoc +++ b/vendor/oauth-0.4.4/README.rdoc @@ -1,4 +1,4 @@ -= Ruby OAuth GEM += Ruby OAuth == What @@ -10,9 +10,7 @@ See the OAuth specs http://oauth.net/core/1.0/ sudo gem install oauth -You can also install it from the oauth rubyforge project http://rubyforge.org/projects/oauth/. - -The source code is now hosted on the OAuth GitHub Project http://github.com/pelle/oauth/tree/master +The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby == The basics @@ -37,27 +35,26 @@ When user returns create an access_token @access_token = @request_token.get_access_token @photos = @access_token.get('/photos.xml') -For more detailed instructions I have written this OAuth Client Tutorial http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider . - -Finally be sure to check out the OAuth RDoc Manual http://oauth.rubyforge.org/rdoc/ . - -== Documentation Wiki +Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose. -There is some documentation on the Google Code project for the "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ : + oauth_params = {:consumer => oauth_consumer, :token => access_token} + hydra = Typhoeus::Hydra.new + req = Typhoeus::Request.new(uri, options) + oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri)) + req.headers.merge!({"Authorization" => oauth_helper.header}) # Signs the request + hydra.queue(req) + hydra.run + @response = req.response -* RequestToken http://code.google.com/p/oauth-plugin/wiki/RequestToken -* AccessToken http://code.google.com/p/oauth-plugin/wiki/AccessToken -== Forum - -http://groups.google.com/group/oauth-ruby +== More Information +* RDoc: http://rdoc.info/projects/oauth/oauth-ruby/ +* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby == How to submit patches -Read the "8 steps for fixing other people's code" http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/. - -The source code is now hosted on the OAuth GitHub Project http://github.com/pelle/oauth/tree/master +The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group. @@ -67,5 +64,7 @@ This code is free to use under the terms of the MIT license. == Contact -Comments are welcome. Send an email to "Pelle Braendgaard" pelleb@gmail.com email via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby +OAuth Ruby has been created and maintained by a large number of talented individuals. +The current maintainer is Aaron Quint (quirkey). +Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby \ No newline at end of file diff --git a/vendor/oauth-0.4.4/Rakefile b/vendor/oauth-0.4.4/Rakefile new file mode 100644 index 000000000..9495c6336 --- /dev/null +++ b/vendor/oauth-0.4.4/Rakefile @@ -0,0 +1,35 @@ +%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f } +$LOAD_PATH << File.dirname(__FILE__) + '/lib' +require 'oauth' + +begin + require 'jeweler' + Jeweler::Tasks.new do |s| + s.name = %q{oauth} + s.version = OAuth::VERSION + s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"] + s.email = "oauth-ruby@googlegroups.com" + s.description = "OAuth Core Ruby implementation" + s.summary = s.description + s.rubyforge_project = %q{oauth} + s.add_development_dependency(%q, [">=2.3.5"]) + s.add_development_dependency(%q, [">= 1.0.0"]) + s.add_development_dependency(%q, [">= 0.9.8"]) + s.add_development_dependency(%q, [">= 0.1.13"]) + s.add_development_dependency(%q, [">= 0.2.10"]) + s.add_development_dependency(%q, [">= 0.6.6.0"]) + end + Jeweler::GemcutterTasks.new +rescue LoadError + puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" +end + +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList['test/*test*.rb'] + t.verbose = true +end + +Dir['tasks/**/*.rake'].each { |t| load t } + +task :default => :test diff --git a/vendor/oauth-0.3.2/TODO b/vendor/oauth-0.4.4/TODO similarity index 97% rename from vendor/oauth-0.3.2/TODO rename to vendor/oauth-0.4.4/TODO index f131892aa..e5207def2 100644 --- a/vendor/oauth-0.3.2/TODO +++ b/vendor/oauth-0.4.4/TODO @@ -27,6 +27,6 @@ the pre-release checks to make sure that there have been no regressions. Random TODOs: * finish CLI * sensible Exception hierarchy -* User Agent * Tokens as Modules * don't tie to Net::HTTP +* Take a look at Curb HTTP Verbs \ No newline at end of file diff --git a/vendor/oauth-0.4.4/bin/oauth b/vendor/oauth-0.4.4/bin/oauth new file mode 100755 index 000000000..8a97ac3c2 --- /dev/null +++ b/vendor/oauth-0.4.4/bin/oauth @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require "oauth/cli" + +OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV) \ No newline at end of file diff --git a/vendor/oauth-0.3.2/examples/yql.rb b/vendor/oauth-0.4.4/examples/yql.rb similarity index 91% rename from vendor/oauth-0.3.2/examples/yql.rb rename to vendor/oauth-0.4.4/examples/yql.rb index ff63ae425..41bb1f21c 100755 --- a/vendor/oauth-0.3.2/examples/yql.rb +++ b/vendor/oauth-0.4.4/examples/yql.rb @@ -39,6 +39,6 @@ access_token = OAuth::AccessToken.new(consumer) -response = access_token.request(:get, url = "/v1/yql?q=#{OAuth::Helper.escape(query)}&format=json") +response = access_token.request(:get, "/v1/yql?q=#{OAuth::Helper.escape(query)}&format=json") rsp = JSON.parse(response.body) pp rsp diff --git a/vendor/oauth-0.4.4/lib/digest/hmac.rb b/vendor/oauth-0.4.4/lib/digest/hmac.rb new file mode 100644 index 000000000..28711db6f --- /dev/null +++ b/vendor/oauth-0.4.4/lib/digest/hmac.rb @@ -0,0 +1,104 @@ +# = digest/hmac.rb +# +# An implementation of HMAC keyed-hashing algorithm +# +# == Overview +# +# This library adds a method named hmac() to Digest classes, which +# creates a Digest class for calculating HMAC digests. +# +# == Examples +# +# require 'digest/hmac' +# +# # one-liner example +# puts Digest::HMAC.hexdigest("data", "hash key", Digest::SHA1) +# +# # rather longer one +# hmac = Digest::HMAC.new("foo", Digest::RMD160) +# +# buf = "" +# while stream.read(16384, buf) +# hmac.update(buf) +# end +# +# puts hmac.bubblebabble +# +# == License +# +# Copyright (c) 2006 Akinori MUSHA +# +# Documentation by Akinori MUSHA +# +# All rights reserved. You can redistribute and/or modify it under +# the same terms as Ruby. +# +# $Id: hmac.rb 14881 2008-01-04 07:26:14Z akr $ +# + +require 'digest' + +unless defined?(Digest::HMAC) + module Digest + class HMAC < Digest::Class + def initialize(key, digester) + @md = digester.new + + block_len = @md.block_length + + if key.bytesize > block_len + key = @md.digest(key) + end + + ipad = Array.new(block_len).fill(0x36) + opad = Array.new(block_len).fill(0x5c) + + key.bytes.each_with_index { |c, i| + ipad[i] ^= c + opad[i] ^= c + } + + @key = key.freeze + @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze + @opad = opad.inject('') { |s, c| s << c.chr }.freeze + @md.update(@ipad) + end + + def initialize_copy(other) + @md = other.instance_eval { @md.clone } + end + + def update(text) + @md.update(text) + self + end + alias << update + + def reset + @md.reset + @md.update(@ipad) + self + end + + def finish + d = @md.digest! + @md.update(@opad) + @md.update(d) + @md.digest! + end + private :finish + + def digest_length + @md.digest_length + end + + def block_length + @md.block_length + end + + def inspect + sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 }); + end + end + end +end diff --git a/vendor/oauth-0.4.4/lib/oauth.rb b/vendor/oauth-0.4.4/lib/oauth.rb new file mode 100644 index 000000000..dc2bd8655 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth.rb @@ -0,0 +1,12 @@ +$LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__)) + +module OAuth + VERSION = "0.4.4" +end + +require 'oauth/oauth' +require 'oauth/core_ext' + +require 'oauth/client/helper' +require 'oauth/signature/hmac/sha1' +require 'oauth/request_proxy/mock_request' diff --git a/vendor/oauth-0.3.2/lib/oauth/cli.rb b/vendor/oauth-0.4.4/lib/oauth/cli.rb similarity index 65% rename from vendor/oauth-0.3.2/lib/oauth/cli.rb rename to vendor/oauth-0.4.4/lib/oauth/cli.rb index c1c579186..c547f72a1 100644 --- a/vendor/oauth-0.3.2/lib/oauth/cli.rb +++ b/vendor/oauth-0.4.4/lib/oauth/cli.rb @@ -6,7 +6,9 @@ class CLI SUPPORTED_COMMANDS = { "authorize" => "Obtain an access token and secret for a user", "debug" => "Verbosely generate an OAuth signature", - "sign" => "Generate an OAuth signature" + "query" => "Query a protected resource", + "sign" => "Generate an OAuth signature", + "version" => "Display the current version of the library" } attr_reader :command @@ -41,38 +43,73 @@ def execute(stdout, stdin, stderr, arguments = []) case command # TODO move command logic elsewhere when "authorize" - # Y! token authority requires realm=yahoo.com when headers are in use - # TODO remove :scheme when that's been fixed - # TODO determine endpoints w/ X-RDS-Simple - consumer = OAuth::Consumer.new \ - options[:oauth_consumer_key], - options[:oauth_consumer_secret], - :access_token_url => options[:access_token_url], - :authorize_url => options[:authorize_url], - :request_token_url => options[:request_token_url], - :scheme => :query_string - - # get a request token - request_token = consumer.get_request_token + begin + consumer = OAuth::Consumer.new \ + options[:oauth_consumer_key], + options[:oauth_consumer_secret], + :access_token_url => options[:access_token_url], + :authorize_url => options[:authorize_url], + :request_token_url => options[:request_token_url], + :scheme => options[:scheme], + :http_method => options[:method].to_s.downcase.to_sym + + # parameters for OAuth 1.0a + oauth_verifier = nil + + # get a request token + request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { "scope" => options[:scope] }) + + if request_token.callback_confirmed? + stdout.puts "Server appears to support OAuth 1.0a; enabling support." + options[:version] = "1.0a" + end - stdout.puts "Please visit this url to authorize:" - stdout.puts request_token.authorize_url + stdout.puts "Please visit this url to authorize:" + stdout.puts request_token.authorize_url - stdout.puts "Press return to continue..." - stdin.gets + if options[:version] == "1.0a" + stdout.puts "Please enter the verification code provided by the SP (oauth_verifier):" + oauth_verifier = stdin.gets.chomp + else + stdout.puts "Press return to continue..." + stdin.gets + end - begin - # get an access token - access_token = request_token.get_access_token + begin + # get an access token + access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier) - stdout.puts "Response:" - access_token.params.each do |k,v| - stdout.puts " #{k}: #{v}" + stdout.puts "Response:" + access_token.params.each do |k,v| + stdout.puts " #{k}: #{v}" unless k.is_a?(Symbol) + end + rescue OAuth::Unauthorized => e + stderr.puts "A problem occurred while attempting to obtain an access token:" + stderr.puts e + stderr.puts e.request.body end rescue OAuth::Unauthorized => e - stderr.puts "A problem occurred while attempting to obtain an access token:" + stderr.puts "A problem occurred while attempting to authorize:" stderr.puts e + stderr.puts e.request.body end + when "query" + consumer = OAuth::Consumer.new \ + options[:oauth_consumer_key], + options[:oauth_consumer_secret], + :scheme => options[:scheme] + + access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret]) + + # append params to the URL + uri = URI.parse(options[:uri]) + params = prepare_parameters.map { |k,v| v.map { |v2| "#{URI.encode(k)}=#{URI.encode(v2)}" } * "&" } + uri.query = [uri.query, *params].reject { |x| x.nil? } * "&" + p uri.to_s + + response = access_token.request(options[:method].downcase.to_sym, uri.to_s) + puts "#{response.code} #{response.message}" + puts response.body when "sign" parameters = prepare_parameters @@ -111,7 +148,7 @@ def execute(stdout, stdin, stderr, arguments = []) stdout.puts stdout.puts "XMPP Stanza:" stdout.puts <<-EOS - + #{request.oauth_consumer_key} #{request.oauth_token} #{request.oauth_signature_method} @@ -134,6 +171,8 @@ def execute(stdout, stdin, stderr, arguments = []) else stdout.puts request.oauth_signature end + when "version" + puts "OAuth for Ruby #{OAuth::VERSION}" end else usage @@ -147,7 +186,9 @@ def extract_command_and_parse_options(arguments) parse_options(arguments[0..-1]) end - def option_parser + def option_parser(arguments = "") + # TODO add realm parameter + # TODO add user-agent parameter option_parser = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options] " @@ -156,10 +197,17 @@ def option_parser options[:oauth_signature_method] = "HMAC-SHA1" options[:oauth_timestamp] = OAuth::Helper.generate_timestamp options[:oauth_version] = "1.0" + options[:method] = :post options[:params] = [] + options[:scheme] = :header + options[:version] = "1.0" ## Common Options + opts.on("-B", "--body", "Use the request body for OAuth parameters.") do + options[:scheme] = :body + end + opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v| options[:oauth_consumer_key] = v end @@ -168,7 +216,21 @@ def option_parser options[:oauth_consumer_secret] = v end - ## Options for signing + opts.on("-H", "--header", "Use the 'Authorization' header for OAuth parameters (default).") do + options[:scheme] = :header + end + + opts.on("-Q", "--query-string", "Use the query string for OAuth parameters.") do + options[:scheme] = :query_string + end + + opts.on("-O", "--options FILE", "Read options from a file") do |v| + arguments.unshift(*open(v).readlines.map { |l| l.chomp.split(" ") }.flatten) + end + + ## Options for signing and making requests + + opts.separator("\n options for signing and querying") opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v| options[:method] = v @@ -206,8 +268,12 @@ def option_parser options[:uri] = v end - opts.on("--version VERSION", "Specifies the OAuth version to use.") do |v| - options[:oauth_version] = v + opts.on(:OPTIONAL, "--version VERSION", "Specifies the OAuth version to use.") do |v| + if v + options[:oauth_version] = v + else + @command = "version" + end end opts.on("--no-version", "Omit oauth_version.") do @@ -225,6 +291,8 @@ def option_parser ## Options for authorization + opts.separator("\n options for authorization") + opts.on("--access-token-url URL", "Specifies the access token URL.") do |v| options[:access_token_url] = v end @@ -233,14 +301,22 @@ def option_parser options[:authorize_url] = v end + opts.on("--callback-url URL", "Specifies a callback URL.") do |v| + options[:oauth_callback] = v + end + opts.on("--request-token-url URL", "Specifies the request token URL.") do |v| options[:request_token_url] = v end + + opts.on("--scope SCOPE", "Specifies the scope (Google-specific).") do |v| + options[:scope] = v + end end end def parse_options(arguments) - option_parser.parse!(arguments) + option_parser(arguments).parse!(arguments) end def prepare_parameters @@ -274,6 +350,8 @@ def sufficient_options? options[:oauth_consumer_key] && options[:oauth_consumer_secret] && options[:access_token_url] && options[:authorize_url] && options[:request_token_url] + when "version" + true else options[:oauth_consumer_key] && options[:oauth_consumer_secret] && options[:method] && options[:uri] diff --git a/vendor/oauth-0.3.2/lib/oauth/client.rb b/vendor/oauth-0.4.4/lib/oauth/client.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/client.rb rename to vendor/oauth-0.4.4/lib/oauth/client.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/client/action_controller_request.rb b/vendor/oauth-0.4.4/lib/oauth/client/action_controller_request.rb similarity index 58% rename from vendor/oauth-0.3.2/lib/oauth/client/action_controller_request.rb rename to vendor/oauth-0.4.4/lib/oauth/client/action_controller_request.rb index b73031e0d..3d649fb8c 100644 --- a/vendor/oauth-0.3.2/lib/oauth/client/action_controller_request.rb +++ b/vendor/oauth-0.4.4/lib/oauth/client/action_controller_request.rb @@ -1,15 +1,26 @@ require 'oauth/client/helper' -require 'oauth/request_proxy/action_controller_request' -require 'action_controller/test_process' +if defined? ActionDispatch + require 'oauth/request_proxy/rack_request' + require 'action_dispatch/testing/test_process' +else + require 'oauth/request_proxy/action_controller_request' + require 'action_controller/test_process' +end module ActionController class Base - def process_with_oauth(request, response=nil) - request.apply_oauth! - process_without_oauth(request, response) + if defined? ActionDispatch + def process_with_new_base_test(request, response=nil) + request.apply_oauth! if request.respond_to?(:apply_oauth!) + super(request, response) + end + else + def process_with_oauth(request, response=nil) + request.apply_oauth! if request.respond_to?(:apply_oauth!) + process_without_oauth(request, response) + end + alias_method_chain :process, :oauth end - - alias_method_chain :process, :oauth end class TestRequest @@ -33,7 +44,8 @@ def configure_oauth(consumer = nil, token = nil, options = {}) def apply_oauth! return unless ActionController::TestRequest.use_oauth? && @oauth_options - @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => request_uri)) + @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => (respond_to?(:fullpath) ? fullpath : request_uri))) + @oauth_helper.amend_user_agent_header(env) self.send("set_oauth_#{@oauth_options[:scheme]}") end diff --git a/vendor/oauth-0.4.4/lib/oauth/client/em_http.rb b/vendor/oauth-0.4.4/lib/oauth/client/em_http.rb new file mode 100644 index 000000000..c59e55022 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/client/em_http.rb @@ -0,0 +1,120 @@ +require 'em-http' +require 'oauth/helper' +require 'oauth/client/helper' +require 'oauth/request_proxy/em_http_request' + +# Extensions for em-http so that we can use consumer.sign! with an EventMachine::HttpClient +# instance. This is purely syntactic sugar. +class EventMachine::HttpClient + + attr_reader :oauth_helper + + # Add the OAuth information to an HTTP request. Depending on the options[:scheme] setting + # this may add a header, additional query string parameters, or additional POST body parameters. + # The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+ + # header. + # + # * http - Configured Net::HTTP instance, ignored in this scenario except for getting host. + # * consumer - OAuth::Consumer instance + # * token - OAuth::Token instance + # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+, + # +signature_method+, +nonce+, +timestamp+) + # + # This method also modifies the User-Agent header to add the OAuth gem version. + # + # See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1] + def oauth!(http, consumer = nil, token = nil, options = {}) + options = { :request_uri => normalized_oauth_uri(http), + :consumer => consumer, + :token => token, + :scheme => 'header', + :signature_method => nil, + :nonce => nil, + :timestamp => nil }.merge(options) + + @oauth_helper = OAuth::Client::Helper.new(self, options) + self.__send__(:"set_oauth_#{options[:scheme]}") + end + + # Create a string suitable for signing for an HTTP request. This process involves parameter + # normalization as specified in the OAuth specification. The exact normalization also depends + # on the options[:scheme] being used so this must match what will be used for the request + # itself. The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+ + # header. + # + # * http - Configured Net::HTTP instance + # * consumer - OAuth::Consumer instance + # * token - OAuth::Token instance + # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+, + # +signature_method+, +nonce+, +timestamp+) + # + # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1] + def signature_base_string(http, consumer = nil, token = nil, options = {}) + options = { :request_uri => normalized_oauth_uri(http), + :consumer => consumer, + :token => token, + :scheme => 'header', + :signature_method => nil, + :nonce => nil, + :timestamp => nil }.merge(options) + + OAuth::Client::Helper.new(self, options).signature_base_string + end + + # This code was lifted from the em-http-request because it was removed from + # the gem June 19, 2010 + # see: http://github.com/igrigorik/em-http-request/commit/d536fc17d56dbe55c487eab01e2ff9382a62598b + def normalize_uri + @normalized_uri ||= begin + uri = @uri.dup + encoded_query = encode_query(@uri, @options[:query]) + path, query = encoded_query.split("?", 2) + uri.query = query unless encoded_query.empty? + uri.path = path + uri + end + end + + protected + + def combine_query(path, query, uri_query) + combined_query = if query.kind_of?(Hash) + query.map { |k, v| encode_param(k, v) }.join('&') + else + query.to_s + end + if !uri_query.to_s.empty? + combined_query = [combined_query, uri_query].reject {|part| part.empty?}.join("&") + end + combined_query.to_s.empty? ? path : "#{path}?#{combined_query}" + end + + # Since we expect to get the host etc details from the http instance (...), + # we create a fake url here. Surely this is a horrible, horrible idea? + def normalized_oauth_uri(http) + uri = URI.parse(normalize_uri.path) + uri.host = http.address + uri.port = http.port + + if http.respond_to?(:use_ssl?) && http.use_ssl? + uri.scheme = "https" + else + uri.scheme = "http" + end + uri.to_s + end + + def set_oauth_header + headers = (self.options[:head] ||= {}) + headers['Authorization'] = @oauth_helper.header + end + + def set_oauth_body + raise NotImplementedError, 'please use the set_oauth_header method instead' + end + + def set_oauth_query_string + raise NotImplementedError, 'please use the set_oauth_header method instead' + end + +end diff --git a/vendor/oauth-0.3.2/lib/oauth/client/helper.rb b/vendor/oauth-0.4.4/lib/oauth/client/helper.rb similarity index 66% rename from vendor/oauth-0.3.2/lib/oauth/client/helper.rb rename to vendor/oauth-0.4.4/lib/oauth/client/helper.rb index 5e7da9e60..97241d3e5 100644 --- a/vendor/oauth-0.3.2/lib/oauth/client/helper.rb +++ b/vendor/oauth-0.4.4/lib/oauth/client/helper.rb @@ -28,19 +28,25 @@ def timestamp def oauth_parameters { + 'oauth_body_hash' => options[:body_hash], + 'oauth_callback' => options[:oauth_callback], 'oauth_consumer_key' => options[:consumer].key, 'oauth_token' => options[:token] ? options[:token].token : '', 'oauth_signature_method' => options[:signature_method], 'oauth_timestamp' => timestamp, 'oauth_nonce' => nonce, - 'oauth_version' => '1.0' + 'oauth_verifier' => options[:oauth_verifier], + 'oauth_version' => (options[:oauth_version] || '1.0'), + 'oauth_session_handle' => options[:oauth_session_handle] }.reject { |k,v| v.to_s == "" } end def signature(extra_options = {}) OAuth::Signature.sign(@request, { :uri => options[:request_uri], :consumer => options[:consumer], - :token => options[:token] }.merge(extra_options) ) + :token => options[:token], + :unsigned_parameters => options[:unsigned_parameters] + }.merge(extra_options) ) end def signature_base_string(extra_options = {}) @@ -50,11 +56,25 @@ def signature_base_string(extra_options = {}) :parameters => oauth_parameters}.merge(extra_options) ) end + def hash_body + @options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters) + end + + def amend_user_agent_header(headers) + @oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}" + # Net::HTTP in 1.9 appends Ruby + if headers['User-Agent'] && headers['User-Agent'] != 'Ruby' + headers['User-Agent'] += " (#{@oauth_ua_string})" + else + headers['User-Agent'] = @oauth_ua_string + end + end + def header parameters = oauth_parameters parameters.merge!('oauth_signature' => signature(options.merge(:parameters => parameters))) - header_params_str = parameters.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ') + header_params_str = parameters.sort.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ') realm = "realm=\"#{options[:realm]}\", " if options[:realm] "OAuth #{realm}#{header_params_str}" diff --git a/vendor/oauth-0.4.4/lib/oauth/client/net_http.rb b/vendor/oauth-0.4.4/lib/oauth/client/net_http.rb new file mode 100644 index 000000000..db2f1757c --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/client/net_http.rb @@ -0,0 +1,119 @@ +require 'oauth/helper' +require 'oauth/client/helper' +require 'oauth/request_proxy/net_http' + +class Net::HTTPRequest + include OAuth::Helper + + attr_reader :oauth_helper + + # Add the OAuth information to an HTTP request. Depending on the options[:scheme] setting + # this may add a header, additional query string parameters, or additional POST body parameters. + # The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+ + # header. + # + # * http - Configured Net::HTTP instance + # * consumer - OAuth::Consumer instance + # * token - OAuth::Token instance + # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+, + # +signature_method+, +nonce+, +timestamp+) + # + # This method also modifies the User-Agent header to add the OAuth gem version. + # + # See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1], + # {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html] + def oauth!(http, consumer = nil, token = nil, options = {}) + helper_options = oauth_helper_options(http, consumer, token, options) + @oauth_helper = OAuth::Client::Helper.new(self, helper_options) + @oauth_helper.amend_user_agent_header(self) + @oauth_helper.hash_body if oauth_body_hash_required? + self.send("set_oauth_#{helper_options[:scheme]}") + end + + # Create a string suitable for signing for an HTTP request. This process involves parameter + # normalization as specified in the OAuth specification. The exact normalization also depends + # on the options[:scheme] being used so this must match what will be used for the request + # itself. The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+ + # header. + # + # * http - Configured Net::HTTP instance + # * consumer - OAuth::Consumer instance + # * token - OAuth::Token instance + # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+, + # +signature_method+, +nonce+, +timestamp+) + # + # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1], + # {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html] + def signature_base_string(http, consumer = nil, token = nil, options = {}) + helper_options = oauth_helper_options(http, consumer, token, options) + oauth_helper = OAuth::Client::Helper.new(self, helper_options) + oauth_helper.hash_body if oauth_body_hash_required? + oauth_helper.signature_base_string + end + +private + + def oauth_helper_options(http, consumer, token, options) + { :request_uri => oauth_full_request_uri(http,options), + :consumer => consumer, + :token => token, + :scheme => 'header', + :signature_method => nil, + :nonce => nil, + :timestamp => nil }.merge(options) + end + + def oauth_full_request_uri(http,options) + uri = URI.parse(self.path) + uri.host = http.address + uri.port = http.port + + if options[:request_endpoint] && options[:site] + uri.host = options[:site].gsub(%r(^https?://), '') + uri.port = 80 + end + + if http.respond_to?(:use_ssl?) && http.use_ssl? + uri.scheme = "https" + else + uri.scheme = "http" + end + + uri.to_s + end + + def oauth_body_hash_required? + request_body_permitted? && content_type != "application/x-www-form-urlencoded" + end + + def set_oauth_header + self['Authorization'] = @oauth_helper.header + end + + # FIXME: if you're using a POST body and query string parameters, this method + # will move query string parameters into the body unexpectedly. This may + # cause problems with non-x-www-form-urlencoded bodies submitted to URLs + # containing query string params. If duplicate parameters are present in both + # places, all instances should be included when calculating the signature + # base string. + + def set_oauth_body + self.set_form_data(@oauth_helper.stringify_keys(@oauth_helper.parameters_with_oauth)) + params_with_sig = @oauth_helper.parameters.merge(:oauth_signature => @oauth_helper.signature) + self.set_form_data(@oauth_helper.stringify_keys(params_with_sig)) + end + + def set_oauth_query_string + oauth_params_str = @oauth_helper.oauth_parameters.map { |k,v| [escape(k), escape(v)] * "=" }.join("&") + uri = URI.parse(path) + if uri.query.to_s == "" + uri.query = oauth_params_str + else + uri.query = uri.query + "&" + oauth_params_str + end + + @path = uri.to_s + + @path << "&oauth_signature=#{escape(oauth_helper.signature)}" + end +end diff --git a/vendor/oauth-0.3.2/lib/oauth/consumer.rb b/vendor/oauth-0.4.4/lib/oauth/consumer.rb similarity index 65% rename from vendor/oauth-0.3.2/lib/oauth/consumer.rb rename to vendor/oauth-0.4.4/lib/oauth/consumer.rb index 5527e2c51..3fd574069 100644 --- a/vendor/oauth-0.3.2/lib/oauth/consumer.rb +++ b/vendor/oauth-0.4.4/lib/oauth/consumer.rb @@ -1,7 +1,9 @@ require 'net/http' require 'net/https' +require 'oauth/oauth' require 'oauth/client/net_http' require 'oauth/errors' +require 'cgi' module OAuth class Consumer @@ -24,6 +26,7 @@ class Consumer :authorize_path => '/oauth/authorize', :access_token_path => '/oauth/access_token', + :proxy => nil, # How do we send the oauth values to the server see # http://oauth.net/core/1.0/#consumer_req_param for more info # @@ -37,6 +40,12 @@ class Consumer # Default http method used for OAuth Token Requests (defaults to :post) :http_method => :post, + # Add a custom ca_file for consumer + # :ca_file => '/etc/certs.pem' + + # Add a custom ca_file for consumer + # :ca_file => '/etc/certs.pem' + :oauth_version => "1.0" } @@ -70,10 +79,10 @@ def initialize(consumer_key, consumer_secret, options = {}) @secret = consumer_secret # ensure that keys are symbols - @options = @@default_options.merge(options.inject({}) { |options, (key, value)| - options[key.to_sym] = value - options - }) + @options = @@default_options.merge(options.inject({}) do |opts, (key, value)| + opts[key.to_sym] = value + opts + end) end # The default http method @@ -96,18 +105,48 @@ def uri(custom_uri = nil) end end + def get_access_token(request_token, request_options = {}, *arguments, &block) + response = token_request(http_method, (access_token_url? ? access_token_url : access_token_path), request_token, request_options, *arguments, &block) + OAuth::AccessToken.from_hash(self, response) + end + # Makes a request to the service for a new OAuth::RequestToken # # @request_token = @consumer.get_request_token # - def get_request_token(request_options = {}, *arguments) - response = token_request(http_method, (request_token_url? ? request_token_url : request_token_path), nil, request_options, *arguments) - OAuth::RequestToken.new(self, response[:oauth_token], response[:oauth_token_secret]) + # To include OAuth parameters: + # + # @request_token = @consumer.get_request_token \ + # :oauth_callback => "http://example.com/cb" + # + # To include application-specific parameters: + # + # @request_token = @consumer.get_request_token({}, :foo => "bar") + # + # TODO oauth_callback should be a mandatory parameter + def get_request_token(request_options = {}, *arguments, &block) + # if oauth_callback wasn't provided, it is assumed that oauth_verifiers + # will be exchanged out of band + request_options[:oauth_callback] ||= OAuth::OUT_OF_BAND unless request_options[:exclude_callback] + + if block_given? + response = token_request(http_method, + (request_token_url? ? request_token_url : request_token_path), + nil, + request_options, + *arguments, &block) + else + response = token_request(http_method, (request_token_url? ? request_token_url : request_token_path), nil, request_options, *arguments) + end + OAuth::RequestToken.from_hash(self, response) end # Creates, signs and performs an http request. # It's recommended to use the OAuth::Token classes to set this up correctly. - # The arguments parameters are a hash or string encoded set of parameters if it's a post request as well as optional http headers. + # request_options take precedence over consumer-wide options when signing + # a request. + # arguments are POST and PUT bodies (a Hash, string-encoded parameters, or + # absent), followed by additional HTTP headers. # # @consumer.request(:get, '/people', @token, { :scheme => :query_string }) # @consumer.request(:post, '/people', @token, {}, @person.to_xml, { 'Content-Type' => 'application/xml' }) @@ -119,13 +158,15 @@ def request(http_method, path, token = nil, request_options = {}, *arguments) path = "#{_uri.path}#{_uri.query ? "?#{_uri.query}" : ""}" end - rsp = http.request(create_signed_request(http_method, path, token, request_options, *arguments)) - + # override the request with your own, this is useful for file uploads which Net::HTTP does not do + req = create_signed_request(http_method, path, token, request_options, *arguments) + return nil if block_given? and yield(req) == :done + rsp = http.request(req) # check for an error reported by the Problem Reporting extension # (http://wiki.oauth.net/ProblemReporting) # note: a 200 may actually be an error; check for an oauth_problem key to be sure if !(headers = rsp.to_hash["www-authenticate"]).nil? && - (h = headers.select { |h| h =~ /^OAuth / }).any? && + (h = headers.select { |hdr| hdr =~ /^OAuth / }).any? && h.first =~ /oauth_problem/ # puts "Header: #{h.first}" @@ -154,11 +195,21 @@ def create_signed_request(http_method, path, token = nil, request_options = {}, # Creates a request and parses the result as url_encoded. This is used internally for the RequestToken and AccessToken requests. def token_request(http_method, path, token = nil, request_options = {}, *arguments) response = request(http_method, path, token, request_options, *arguments) - case response.code.to_i when (200..299) - CGI.parse(response.body).inject({}) { |h,(k,v)| h[k.to_sym] = v.first; h } + if block_given? + yield response.body + else + # symbolize keys + # TODO this could be considered unexpected behavior; symbols or not? + # TODO this also drops subsequent values from multi-valued keys + CGI.parse(response.body).inject({}) do |h,(k,v)| + h[k.strip.to_sym] = v.first + h[k.strip] = v.first + h + end + end when (300..399) # this is a redirect response.error! @@ -183,6 +234,11 @@ def site @options[:site].to_s end + def request_endpoint + return nil if @options[:request_endpoint].nil? + @options[:request_endpoint].to_s + end + def scheme @options[:scheme] end @@ -224,28 +280,44 @@ def access_token_url? @options.has_key?(:access_token_url) end - protected + def proxy + @options[:proxy] + end + + protected # Instantiates the http object def create_http(_url = nil) + + + if !request_endpoint.nil? + _url = request_endpoint + end + + if _url.nil? || _url[0] =~ /^\// our_uri = URI.parse(site) else our_uri = URI.parse(_url) end - http_object = Net::HTTP.new(our_uri.host, our_uri.port) + + if proxy.nil? + http_object = Net::HTTP.new(our_uri.host, our_uri.port) + else + proxy_uri = proxy.is_a?(URI) ? proxy : URI.parse(proxy) + http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password) + end http_object.use_ssl = (our_uri.scheme == 'https') - if CA_FILE - http_object.ca_file = CA_FILE + if @options[:ca_file] || CA_FILE + http_object.ca_file = @options[:ca_file] || CA_FILE http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER http_object.verify_depth = 5 else http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE end - http_object end @@ -262,10 +334,10 @@ def create_http_request(http_method, path, *arguments) case http_method when :post request = Net::HTTP::Post.new(path,headers) - request["Content-Length"] = 0 # Default to 0 + request["Content-Length"] = '0' # Default to 0 when :put request = Net::HTTP::Put.new(path,headers) - request["Content-Length"] = 0 # Default to 0 + request["Content-Length"] = '0' # Default to 0 when :get request = Net::HTTP::Get.new(path,headers) when :delete @@ -277,20 +349,35 @@ def create_http_request(http_method, path, *arguments) end if data.is_a?(Hash) - request.set_form_data(data) + form_data = {} + data.each {|k,v| form_data[k.to_s] = v if !v.nil?} + request.set_form_data(form_data) elsif data - request.body = data.to_s - request["Content-Length"] = request.body.length + if data.respond_to?(:read) + request.body_stream = data + if data.respond_to?(:length) + request["Content-Length"] = data.length.to_s + elsif data.respond_to?(:stat) && data.stat.respond_to?(:size) + request["Content-Length"] = data.stat.size.to_s + else + raise ArgumentError, "Don't know how to send a body_stream that doesn't respond to .length or .stat.size" + end + else + request.body = data.to_s + request["Content-Length"] = request.body.length.to_s + end end request end - # Unset cached http instance because it cannot be marshalled when - # it has already been used and use_ssl is set to true def marshal_dump(*args) - @http = nil - self + {:key => @key, :secret => @secret, :options => @options} end + + def marshal_load(data) + initialize(data[:key], data[:secret], data[:options]) + end + end end diff --git a/vendor/oauth-0.4.4/lib/oauth/core_ext.rb b/vendor/oauth-0.4.4/lib/oauth/core_ext.rb new file mode 100644 index 000000000..64bc80a32 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/core_ext.rb @@ -0,0 +1,31 @@ +# these are to backport methods from 1.8.7/1.9.1 to 1.8.6 + +class Object + + unless method_defined?(:tap) + def tap + yield self + self + end + end + +end + +class String + + + + unless method_defined?(:bytesize) + def bytesize + self.size + end + end + + unless method_defined?(:bytes) + def bytes + require 'enumerator' + Enumerable::Enumerator.new(self, :each_byte) + end + end + +end diff --git a/vendor/oauth-0.3.2/lib/oauth/errors.rb b/vendor/oauth-0.4.4/lib/oauth/errors.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/errors.rb rename to vendor/oauth-0.4.4/lib/oauth/errors.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/errors/error.rb b/vendor/oauth-0.4.4/lib/oauth/errors/error.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/errors/error.rb rename to vendor/oauth-0.4.4/lib/oauth/errors/error.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/errors/problem.rb b/vendor/oauth-0.4.4/lib/oauth/errors/problem.rb similarity index 98% rename from vendor/oauth-0.3.2/lib/oauth/errors/problem.rb rename to vendor/oauth-0.4.4/lib/oauth/errors/problem.rb index 52662c56b..d002611a4 100644 --- a/vendor/oauth-0.3.2/lib/oauth/errors/problem.rb +++ b/vendor/oauth-0.4.4/lib/oauth/errors/problem.rb @@ -11,4 +11,4 @@ def to_s problem end end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.3.2/lib/oauth/errors/unauthorized.rb b/vendor/oauth-0.4.4/lib/oauth/errors/unauthorized.rb similarity index 98% rename from vendor/oauth-0.3.2/lib/oauth/errors/unauthorized.rb rename to vendor/oauth-0.4.4/lib/oauth/errors/unauthorized.rb index 4e799594f..e304d6b41 100644 --- a/vendor/oauth-0.3.2/lib/oauth/errors/unauthorized.rb +++ b/vendor/oauth-0.4.4/lib/oauth/errors/unauthorized.rb @@ -9,4 +9,4 @@ def to_s [request.code, request.message] * " " end end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.4.4/lib/oauth/helper.rb b/vendor/oauth-0.4.4/lib/oauth/helper.rb new file mode 100644 index 000000000..c22950d5b --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/helper.rb @@ -0,0 +1,88 @@ +require 'openssl' +require 'base64' + +module OAuth + module Helper + extend self + + # Escape +value+ by URL encoding all non-reserved character. + # + # See Also: {OAuth core spec version 1.0, section 5.1}[http://oauth.net/core/1.0#rfc.section.5.1] + def escape(value) + URI::escape(value.to_s, OAuth::RESERVED_CHARACTERS) + rescue ArgumentError + URI::escape(value.to_s.force_encoding(Encoding::UTF_8), OAuth::RESERVED_CHARACTERS) + end + + # Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word + # characters removed. + def generate_key(size=32) + Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/, '') + end + + alias_method :generate_nonce, :generate_key + + def generate_timestamp #:nodoc: + Time.now.to_i.to_s + end + + # Normalize a +Hash+ of parameter values. Parameters are sorted by name, using lexicographical + # byte value ordering. If two or more parameters share the same name, they are sorted by their value. + # Parameters are concatenated in their sorted order into a single string. For each parameter, the name + # is separated from the corresponding value by an "=" character, even if the value is empty. Each + # name-value pair is separated by an "&" character. + # + # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1] + def normalize(params) + params.sort.map do |k, values| + + if values.is_a?(Array) + # multiple values were provided for a single key + values.sort.collect do |v| + [escape(k),escape(v)] * "=" + end + else + [escape(k),escape(values)] * "=" + end + end * "&" + end + + # Parse an Authorization / WWW-Authenticate header into a hash. Takes care of unescaping and + # removing surrounding quotes. Raises a OAuth::Problem if the header is not parsable into a + # valid hash. Does not validate the keys or values. + # + # hash = parse_header(headers['Authorization'] || headers['WWW-Authenticate']) + # hash['oauth_timestamp'] + # #=>"1234567890" + # + def parse_header(header) + # decompose + params = header[6,header.length].split(/[,=&]/) + + # odd number of arguments - must be a malformed header. + raise OAuth::Problem.new("Invalid authorization header") if params.size % 2 != 0 + + params.map! do |v| + # strip and unescape + val = unescape(v.strip) + # strip quotes + val.sub(/^\"(.*)\"$/, '\1') + end + + # convert into a Hash + Hash[*params.flatten] + end + + def unescape(value) + URI.unescape(value.gsub('+', '%2B')) + end + + def stringify_keys(hash) + new_h = {} + hash.each do |k, v| + new_h[k.to_s] = v.is_a?(Hash) ? stringify_keys(v) : v + end + new_h + end + end +end diff --git a/vendor/oauth-0.4.4/lib/oauth/oauth.rb b/vendor/oauth-0.4.4/lib/oauth/oauth.rb new file mode 100644 index 000000000..3b2c42896 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/oauth.rb @@ -0,0 +1,13 @@ +module OAuth + # request tokens are passed between the consumer and the provider out of + # band (i.e. callbacks cannot be used), per section 6.1.1 + OUT_OF_BAND = "oob" + + # required parameters, per sections 6.1.1, 6.3.1, and 7 + PARAMETERS = %w(oauth_callback oauth_consumer_key oauth_token + oauth_signature_method oauth_timestamp oauth_nonce oauth_verifier + oauth_version oauth_signature oauth_body_hash) + + # reserved character regexp, per section 5.1 + RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/ +end diff --git a/vendor/oauth-0.3.2/lib/oauth/oauth_test_helper.rb b/vendor/oauth-0.4.4/lib/oauth/oauth_test_helper.rb similarity index 99% rename from vendor/oauth-0.3.2/lib/oauth/oauth_test_helper.rb rename to vendor/oauth-0.4.4/lib/oauth/oauth_test_helper.rb index aae316b87..a59b4cb6a 100644 --- a/vendor/oauth-0.3.2/lib/oauth/oauth_test_helper.rb +++ b/vendor/oauth-0.4.4/lib/oauth/oauth_test_helper.rb @@ -22,4 +22,4 @@ def mock_incoming_request_with_authorize_header(request) incoming end end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/action_controller_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/action_controller_request.rb similarity index 80% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/action_controller_request.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/action_controller_request.rb index ff7daa5f3..8ea5741c4 100644 --- a/vendor/oauth-0.3.2/lib/oauth/request_proxy/action_controller_request.rb +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/action_controller_request.rb @@ -1,6 +1,6 @@ require 'active_support' +require 'action_controller' require 'action_controller/request' -require 'oauth/request_proxy/base' require 'uri' module OAuth::RequestProxy @@ -34,17 +34,18 @@ def parameters_for_signature unless options[:clobber_request] params << header_params.to_query - params << request.query_string unless request.query_string.blank? - if request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded") + params << request.query_string unless query_string_blank? + + if request.post? && request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded") params << request.raw_post end end params. join('&').split('&'). - reject { |kv| kv =~ /^oauth_signature=.*/}. reject(&:blank?). - map { |p| p.split('=').map{|esc| CGI.unescape(esc)} } + map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }. + reject { |kv| kv[0] == 'oauth_signature'} end protected diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/base.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/base.rb similarity index 86% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/base.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/base.rb index f9c144880..039ef5e9d 100644 --- a/vendor/oauth-0.3.2/lib/oauth/request_proxy/base.rb +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/base.rb @@ -9,15 +9,20 @@ def self.proxies(klass) OAuth::RequestProxy.available_proxies[klass] = self end - attr_accessor :request, :options + attr_accessor :request, :options, :unsigned_parameters def initialize(request, options = {}) @request = request + @unsigned_parameters = (options[:unsigned_parameters] || []).map {|param| param.to_s} @options = options end ## OAuth parameters + def oauth_callback + parameters['oauth_callback'] + end + def oauth_consumer_key parameters['oauth_consumer_key'] end @@ -28,7 +33,7 @@ def oauth_nonce def oauth_signature # TODO can this be nil? - parameters['oauth_signature'] || "" + [parameters['oauth_signature']].flatten.first || "" end def oauth_signature_method @@ -48,6 +53,10 @@ def oauth_token parameters['oauth_token'] end + def oauth_verifier + parameters['oauth_verifier'] + end + def oauth_version parameters["oauth_version"] end @@ -67,7 +76,7 @@ def parameters end def parameters_for_signature - parameters.reject { |k,v| k == "oauth_signature" } + parameters.reject { |k,v| k == "oauth_signature" || unsigned_parameters.include?(k)} end def oauth_parameters @@ -133,6 +142,14 @@ def oauth_header(options = {}) "OAuth #{realm}#{header_params_str}" end + def query_string_blank? + if uri = request.request_uri + uri.split('?', 2)[1].nil? + else + request.query_string.blank? + end + end + protected def header_params diff --git a/vendor/oauth-0.4.4/lib/oauth/request_proxy/curb_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/curb_request.rb new file mode 100644 index 000000000..a67cba669 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/curb_request.rb @@ -0,0 +1,55 @@ + require 'oauth/request_proxy/base' +require 'curb' +require 'uri' +require 'cgi' + +module OAuth::RequestProxy::Curl + class Easy < OAuth::RequestProxy::Base + # Proxy for signing Curl::Easy requests + # Usage example: + # oauth_params = {:consumer => oauth_consumer, :token => access_token} + # req = Curl::Easy.new(uri) + # oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri)) + # req.headers.merge!({"Authorization" => oauth_helper.header}) + # req.http_get + # response = req.body_str + proxies ::Curl::Easy + + def method + nil + end + + def uri + options[:uri].to_s + end + + def parameters + if options[:clobber_request] + options[:parameters] + else + post_parameters.merge(query_parameters).merge(options[:parameters] || {}) + end + end + + private + + def query_parameters + query = URI.parse(request.url).query + return(query ? CGI.parse(query) : {}) + end + + def post_parameters + post_body = {} + + # Post params are only used if posting form data + if (request.headers['Content-Type'] && request.headers['Content-Type'].downcase == 'application/x-www-form-urlencoded') + + request.post_body.split("&").each do |str| + param = str.split("=") + post_body[param[0]] = param[1] + end + end + post_body + end + end +end diff --git a/vendor/oauth-0.4.4/lib/oauth/request_proxy/em_http_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/em_http_request.rb new file mode 100644 index 000000000..6879f29c8 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/em_http_request.rb @@ -0,0 +1,66 @@ +require 'oauth/request_proxy/base' +# em-http also uses adddressable so there is no need to require uri. +require 'em-http' +require 'cgi' + +module OAuth::RequestProxy::EventMachine + class HttpRequest < OAuth::RequestProxy::Base + + # A Proxy for use when you need to sign EventMachine::HttpClient instances. + # It needs to be called once the client is construct but before data is sent. + # Also see oauth/client/em-http + proxies ::EventMachine::HttpClient + + # Request in this con + + def method + request.method + end + + def uri + request.normalize_uri.to_s + end + + def parameters + if options[:clobber_request] + options[:parameters] + else + all_parameters + end + end + + protected + + def all_parameters + merged_parameters({}, post_parameters, query_parameters, options[:parameters]) + end + + def query_parameters + CGI.parse(request.normalize_uri.query.to_s) + end + + def post_parameters + headers = request.options[:head] || {} + form_encoded = headers['Content-Type'].to_s.downcase == 'application/x-www-form-urlencoded' + if ['POST', 'PUT'].include?(method) && form_encoded + CGI.parse(request.normalize_body.to_s) + else + {} + end + end + + def merged_parameters(params, *extra_params) + extra_params.compact.each do |params_pairs| + params_pairs.each_pair do |key, value| + if params.has_key?(key) + params[key] += value + else + params[key] = [value].flatten + end + end + end + params + end + + end +end diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/jabber_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/jabber_request.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/jabber_request.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/jabber_request.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/mock_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/mock_request.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/mock_request.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/mock_request.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/net_http.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/net_http.rb similarity index 78% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/net_http.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/net_http.rb index 273bb43c7..b9c41c686 100644 --- a/vendor/oauth-0.3.2/lib/oauth/request_proxy/net_http.rb +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/net_http.rb @@ -13,8 +13,7 @@ def method end def uri - uri = options[:uri] - uri.to_s + options[:uri].to_s end def parameters @@ -25,16 +24,21 @@ def parameters end end + def body + request.body + end + private def all_parameters request_params = CGI.parse(query_string) + if options[:parameters] options[:parameters].each do |k,v| - if request_params.has_key?(k) + if request_params.has_key?(k) && v request_params[k] << v else - request_params[k] = [v].flatten + request_params[k] = [v] end end end @@ -43,11 +47,14 @@ def all_parameters def query_string params = [ query_params, auth_header_params ] - is_form_urlencoded = request['Content-Type'] != nil && request['Content-Type'].downcase == 'application/x-www-form-urlencoded' - params << post_params if method.to_s.upcase == 'POST' && is_form_urlencoded + params << post_params if method.to_s.upcase == 'POST' && form_url_encoded? params.compact.join('&') end + def form_url_encoded? + request['Content-Type'] != nil && request['Content-Type'].downcase == 'application/x-www-form-urlencoded' + end + def query_params URI.parse(request.path).query end diff --git a/vendor/oauth-0.3.2/lib/oauth/request_proxy/rack_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/rack_request.rb similarity index 97% rename from vendor/oauth-0.3.2/lib/oauth/request_proxy/rack_request.rb rename to vendor/oauth-0.4.4/lib/oauth/request_proxy/rack_request.rb index 8ec63d11f..70b2a5769 100644 --- a/vendor/oauth-0.3.2/lib/oauth/request_proxy/rack_request.rb +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/rack_request.rb @@ -34,7 +34,7 @@ def query_params end def request_params - request.params + request.POST end end end diff --git a/vendor/oauth-0.4.4/lib/oauth/request_proxy/typhoeus_request.rb b/vendor/oauth-0.4.4/lib/oauth/request_proxy/typhoeus_request.rb new file mode 100644 index 000000000..0474f9442 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/request_proxy/typhoeus_request.rb @@ -0,0 +1,53 @@ +require 'oauth/request_proxy/base' +require 'typhoeus' +require 'typhoeus/request' +require 'uri' +require 'cgi' + +module OAuth::RequestProxy::Typhoeus + class Request < OAuth::RequestProxy::Base + # Proxy for signing Typhoeus::Request requests + # Usage example: + # oauth_params = {:consumer => oauth_consumer, :token => access_token} + # req = Typhoeus::Request.new(uri, options) + # oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri)) + # req.headers.merge!({"Authorization" => oauth_helper.header}) + # hydra = Typhoeus::Hydra.new() + # hydra.queue(req) + # hydra.run + # response = req.response + proxies Typhoeus::Request + + def method + request.method.to_s.upcase + end + + def uri + options[:uri].to_s + end + + def parameters + if options[:clobber_request] + options[:parameters] + else + post_parameters.merge(query_parameters).merge(options[:parameters] || {}) + end + end + + private + + def query_parameters + query = URI.parse(request.url).query + return(query ? CGI.parse(query) : {}) + end + + def post_parameters + # Post params are only used if posting form data + if(method == 'POST' && request.headers['Content-Type'] && request.headers['Content-Type'].downcase == 'application/x-www-form-urlencoded') + request.body || {} + else + {} + end + end + end +end diff --git a/vendor/oauth-0.3.2/lib/oauth/server.rb b/vendor/oauth-0.4.4/lib/oauth/server.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/server.rb rename to vendor/oauth-0.4.4/lib/oauth/server.rb diff --git a/vendor/oauth-0.4.4/lib/oauth/signature.rb b/vendor/oauth-0.4.4/lib/oauth/signature.rb new file mode 100644 index 000000000..93f7c3824 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/signature.rb @@ -0,0 +1,45 @@ +module OAuth + module Signature + # Returns a list of available signature methods + def self.available_methods + @available_methods ||= {} + end + + # Build a signature from a +request+. + # + # Raises UnknownSignatureMethod exception if the signature method is unknown. + def self.build(request, options = {}, &block) + request = OAuth::RequestProxy.proxy(request, options) + klass = available_methods[ + (request.signature_method || + ((c = request.options[:consumer]) && c.options[:signature_method]) || + "").downcase] + raise UnknownSignatureMethod, request.signature_method unless klass + klass.new(request, options, &block) + end + + # Sign a +request+ + def self.sign(request, options = {}, &block) + self.build(request, options, &block).signature + end + + # Verify the signature of +request+ + def self.verify(request, options = {}, &block) + self.build(request, options, &block).verify + end + + # Create the signature base string for +request+. This string is the normalized parameter information. + # + # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1] + def self.signature_base_string(request, options = {}, &block) + self.build(request, options, &block).signature_base_string + end + + # Create the body hash for a request + def self.body_hash(request, options = {}, &block) + self.build(request, options, &block).body_hash + end + + class UnknownSignatureMethod < Exception; end + end +end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/base.rb b/vendor/oauth-0.4.4/lib/oauth/signature/base.rb similarity index 76% rename from vendor/oauth-0.3.2/lib/oauth/signature/base.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/base.rb index 807f0eeb4..8d1f5cbfe 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/base.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/base.rb @@ -10,8 +10,10 @@ class Base attr_accessor :options attr_reader :token_secret, :consumer_secret, :request - def self.implements(signature_method) - OAuth::Signature.available_methods[signature_method] = self + def self.implements(signature_method = nil) + return @implements if signature_method.nil? + @implements = signature_method + OAuth::Signature.available_methods[@implements] = self end def self.digest_class(digest_class = nil) @@ -19,6 +21,16 @@ def self.digest_class(digest_class = nil) @digest_class = digest_class end + def self.digest_klass(digest_klass = nil) + return @digest_klass if digest_klass.nil? + @digest_klass = digest_klass + end + + def self.hash_class(hash_class = nil) + return @hash_class if hash_class.nil? + @hash_class = hash_class + end + def initialize(request, options = {}, &block) raise TypeError unless request.kind_of?(OAuth::RequestProxy::Base) @request = request @@ -38,7 +50,6 @@ def initialize(request, options = {}, &block) # presence of :token_secret option will override any Token that's provided @token_secret = options[:token_secret] if options[:token_secret] - # override secrets based on the values returned from the block (if any) if block_given? # consumer secret and token secret need to be looked up based on pieces of the request @@ -66,6 +77,14 @@ def signature_base_string request.signature_base_string end + def body_hash + if self.class.hash_class + Base64.encode64(self.class.hash_class.digest(request.body || '')).chomp.gsub(/\n/,'') + else + nil # no body hash algorithm defined, so don't generate one + end + end + private def token diff --git a/vendor/oauth-0.4.4/lib/oauth/signature/hmac/base.rb b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/base.rb new file mode 100644 index 000000000..18eb1f260 --- /dev/null +++ b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/base.rb @@ -0,0 +1,15 @@ +# -*- encoding: utf-8 -*- + +require 'oauth/signature/base' +require 'digest/hmac' + +module OAuth::Signature::HMAC + class Base < OAuth::Signature::Base + + private + def digest + self.class.digest_class Object.module_eval("::Digest::#{self.class.digest_klass}") + Digest::HMAC.digest(signature_base_string, secret, self.class.digest_class) + end + end +end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/md5.rb b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/md5.rb similarity index 71% rename from vendor/oauth-0.3.2/lib/oauth/signature/hmac/md5.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/hmac/md5.rb index 5363e98b4..15d6db447 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/md5.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/md5.rb @@ -1,9 +1,8 @@ require 'oauth/signature/hmac/base' -require 'hmac-md5' module OAuth::Signature::HMAC class MD5 < Base implements 'hmac-md5' - digest_class ::HMAC::MD5 + digest_class 'MD5' end end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/rmd160.rb b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/rmd160.rb similarity index 70% rename from vendor/oauth-0.3.2/lib/oauth/signature/hmac/rmd160.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/hmac/rmd160.rb index 1a5b250ba..b8dc3c3b2 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/rmd160.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/rmd160.rb @@ -1,9 +1,8 @@ require 'oauth/signature/hmac/base' -require 'hmac-rmd160' module OAuth::Signature::HMAC class RMD160 < Base implements 'hmac-rmd160' - digest_class ::HMAC::RMD160 + digest_klass 'RMD160' end end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha1.rb b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha1.rb similarity index 69% rename from vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha1.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha1.rb index 9391eb46f..dd0b2af13 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha1.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha1.rb @@ -1,9 +1,9 @@ require 'oauth/signature/hmac/base' -require 'hmac-sha1' module OAuth::Signature::HMAC class SHA1 < Base implements 'hmac-sha1' - digest_class ::HMAC::SHA1 + digest_klass 'SHA1' + hash_class ::Digest::SHA1 end end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha2.rb b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha2.rb similarity index 71% rename from vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha2.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha2.rb index f3f4d40df..495413627 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/hmac/sha2.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/hmac/sha2.rb @@ -1,9 +1,8 @@ require 'oauth/signature/hmac/base' -require 'hmac-sha2' module OAuth::Signature::HMAC class SHA2 < Base implements 'hmac-sha2' - digest_class ::HMAC::SHA2 + digest_klass 'SHA2' end end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/md5.rb b/vendor/oauth-0.4.4/lib/oauth/signature/md5.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/signature/md5.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/md5.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/plaintext.rb b/vendor/oauth-0.4.4/lib/oauth/signature/plaintext.rb similarity index 82% rename from vendor/oauth-0.3.2/lib/oauth/signature/plaintext.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/plaintext.rb index 318bd310b..71c445c67 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/plaintext.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/plaintext.rb @@ -9,7 +9,7 @@ def signature end def ==(cmp_signature) - signature == escape(cmp_signature) + signature.to_s == cmp_signature.to_s end def signature_base_string @@ -17,7 +17,7 @@ def signature_base_string end def secret - escape(super) + super end end end diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/rsa/sha1.rb b/vendor/oauth-0.4.4/lib/oauth/signature/rsa/sha1.rb similarity index 97% rename from vendor/oauth-0.3.2/lib/oauth/signature/rsa/sha1.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/rsa/sha1.rb index 786dedec2..018852aca 100644 --- a/vendor/oauth-0.3.2/lib/oauth/signature/rsa/sha1.rb +++ b/vendor/oauth-0.4.4/lib/oauth/signature/rsa/sha1.rb @@ -4,6 +4,7 @@ module OAuth::Signature::RSA class SHA1 < OAuth::Signature::Base implements 'rsa-sha1' + hash_class ::Digest::SHA1 def ==(cmp_signature) public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(cmp_signature.is_a?(Array) ? cmp_signature.first : cmp_signature), signature_base_string) diff --git a/vendor/oauth-0.3.2/lib/oauth/signature/sha1.rb b/vendor/oauth-0.4.4/lib/oauth/signature/sha1.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/signature/sha1.rb rename to vendor/oauth-0.4.4/lib/oauth/signature/sha1.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/token.rb b/vendor/oauth-0.4.4/lib/oauth/token.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/token.rb rename to vendor/oauth-0.4.4/lib/oauth/token.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/tokens/access_token.rb b/vendor/oauth-0.4.4/lib/oauth/tokens/access_token.rb similarity index 85% rename from vendor/oauth-0.3.2/lib/oauth/tokens/access_token.rb rename to vendor/oauth-0.4.4/lib/oauth/tokens/access_token.rb index db1faf243..8d3f01bdd 100644 --- a/vendor/oauth-0.3.2/lib/oauth/tokens/access_token.rb +++ b/vendor/oauth-0.4.4/lib/oauth/tokens/access_token.rb @@ -7,11 +7,14 @@ def request(http_method, path, *arguments) request_uri = URI.parse(path) site_uri = consumer.uri is_service_uri_different = (request_uri.absolute? && request_uri != site_uri) - consumer.uri(request_uri) if is_service_uri_different - @response = super(http_method, path, *arguments) - # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs? - # so reset in case consumer is still used for other token-management tasks subsequently? - consumer.uri(site_uri) if is_service_uri_different + begin + consumer.uri(request_uri) if is_service_uri_different + @response = super(http_method, path, *arguments) + ensure + # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs? + # so reset in case consumer is still used for other token-management tasks subsequently? + consumer.uri(site_uri) if is_service_uri_different + end @response end diff --git a/vendor/oauth-0.3.2/lib/oauth/tokens/consumer_token.rb b/vendor/oauth-0.4.4/lib/oauth/tokens/consumer_token.rb similarity index 97% rename from vendor/oauth-0.3.2/lib/oauth/tokens/consumer_token.rb rename to vendor/oauth-0.4.4/lib/oauth/tokens/consumer_token.rb index 0d7608d97..58c48429a 100644 --- a/vendor/oauth-0.3.2/lib/oauth/tokens/consumer_token.rb +++ b/vendor/oauth-0.4.4/lib/oauth/tokens/consumer_token.rb @@ -13,6 +13,7 @@ def self.from_hash(consumer, hash) def initialize(consumer, token="", secret="") super(token, secret) @consumer = consumer + @params = {} end # Make a signed request using given http_method to the path diff --git a/vendor/oauth-0.3.2/lib/oauth/tokens/request_token.rb b/vendor/oauth-0.4.4/lib/oauth/tokens/request_token.rb similarity index 82% rename from vendor/oauth-0.3.2/lib/oauth/tokens/request_token.rb rename to vendor/oauth-0.4.4/lib/oauth/tokens/request_token.rb index 2e0ca4af2..f2ee65409 100644 --- a/vendor/oauth-0.3.2/lib/oauth/tokens/request_token.rb +++ b/vendor/oauth-0.4.4/lib/oauth/tokens/request_token.rb @@ -9,9 +9,13 @@ def authorize_url(params = nil) build_authorize_url(consumer.authorize_url, params) end + def callback_confirmed? + params[:oauth_callback_confirmed] == "true" + end + # exchange for AccessToken on server - def get_access_token(options = {}) - response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options) + def get_access_token(options = {}, *arguments) + response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments) OAuth::AccessToken.from_hash(consumer, response) end diff --git a/vendor/oauth-0.3.2/lib/oauth/tokens/server_token.rb b/vendor/oauth-0.4.4/lib/oauth/tokens/server_token.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/tokens/server_token.rb rename to vendor/oauth-0.4.4/lib/oauth/tokens/server_token.rb diff --git a/vendor/oauth-0.3.2/lib/oauth/tokens/token.rb b/vendor/oauth-0.4.4/lib/oauth/tokens/token.rb similarity index 100% rename from vendor/oauth-0.3.2/lib/oauth/tokens/token.rb rename to vendor/oauth-0.4.4/lib/oauth/tokens/token.rb diff --git a/vendor/oauth-0.4.4/oauth.gemspec b/vendor/oauth-0.4.4/oauth.gemspec new file mode 100644 index 000000000..28603363e --- /dev/null +++ b/vendor/oauth-0.4.4/oauth.gemspec @@ -0,0 +1,174 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{oauth} + s.version = "0.4.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"] + s.date = %q{2010-10-31} + s.default_executable = %q{oauth} + s.description = %q{OAuth Core Ruby implementation} + s.email = %q{oauth-ruby@googlegroups.com} + s.executables = ["oauth"] + s.extra_rdoc_files = [ + "LICENSE", + "README.rdoc", + "TODO" + ] + s.files = [ + ".gitignore", + "Gemfile", + "Gemfile.lock", + "HISTORY", + "LICENSE", + "README.rdoc", + "Rakefile", + "TODO", + "bin/oauth", + "examples/yql.rb", + "lib/digest/hmac.rb", + "lib/oauth.rb", + "lib/oauth/cli.rb", + "lib/oauth/client.rb", + "lib/oauth/client/action_controller_request.rb", + "lib/oauth/client/em_http.rb", + "lib/oauth/client/helper.rb", + "lib/oauth/client/net_http.rb", + "lib/oauth/consumer.rb", + "lib/oauth/core_ext.rb", + "lib/oauth/errors.rb", + "lib/oauth/errors/error.rb", + "lib/oauth/errors/problem.rb", + "lib/oauth/errors/unauthorized.rb", + "lib/oauth/helper.rb", + "lib/oauth/oauth.rb", + "lib/oauth/oauth_test_helper.rb", + "lib/oauth/request_proxy.rb", + "lib/oauth/request_proxy/action_controller_request.rb", + "lib/oauth/request_proxy/base.rb", + "lib/oauth/request_proxy/curb_request.rb", + "lib/oauth/request_proxy/em_http_request.rb", + "lib/oauth/request_proxy/jabber_request.rb", + "lib/oauth/request_proxy/mock_request.rb", + "lib/oauth/request_proxy/net_http.rb", + "lib/oauth/request_proxy/rack_request.rb", + "lib/oauth/request_proxy/typhoeus_request.rb", + "lib/oauth/server.rb", + "lib/oauth/signature.rb", + "lib/oauth/signature/base.rb", + "lib/oauth/signature/hmac/base.rb", + "lib/oauth/signature/hmac/md5.rb", + "lib/oauth/signature/hmac/rmd160.rb", + "lib/oauth/signature/hmac/sha1.rb", + "lib/oauth/signature/hmac/sha2.rb", + "lib/oauth/signature/md5.rb", + "lib/oauth/signature/plaintext.rb", + "lib/oauth/signature/rsa/sha1.rb", + "lib/oauth/signature/sha1.rb", + "lib/oauth/token.rb", + "lib/oauth/tokens/access_token.rb", + "lib/oauth/tokens/consumer_token.rb", + "lib/oauth/tokens/request_token.rb", + "lib/oauth/tokens/server_token.rb", + "lib/oauth/tokens/token.rb", + "oauth.gemspec", + "tasks/deployment.rake", + "tasks/environment.rake", + "tasks/website.rake", + "test/cases/oauth_case.rb", + "test/cases/spec/1_0-final/test_construct_request_url.rb", + "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", + "test/cases/spec/1_0-final/test_parameter_encodings.rb", + "test/cases/spec/1_0-final/test_signature_base_strings.rb", + "test/integration/consumer_test.rb", + "test/keys/rsa.cert", + "test/keys/rsa.pem", + "test/test_access_token.rb", + "test/test_action_controller_request_proxy.rb", + "test/test_consumer.rb", + "test/test_curb_request_proxy.rb", + "test/test_em_http_client.rb", + "test/test_em_http_request_proxy.rb", + "test/test_helper.rb", + "test/test_hmac_sha1.rb", + "test/test_net_http_client.rb", + "test/test_net_http_request_proxy.rb", + "test/test_oauth_helper.rb", + "test/test_rack_request_proxy.rb", + "test/test_request_token.rb", + "test/test_rsa_sha1.rb", + "test/test_server.rb", + "test/test_signature.rb", + "test/test_signature_base.rb", + "test/test_signature_plain_text.rb", + "test/test_token.rb", + "test/test_typhoeus_request_proxy.rb" + ] + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{oauth} + s.rubygems_version = %q{1.3.7} + s.summary = %q{OAuth Core Ruby implementation} + s.test_files = [ + "test/cases/oauth_case.rb", + "test/cases/spec/1_0-final/test_construct_request_url.rb", + "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", + "test/cases/spec/1_0-final/test_parameter_encodings.rb", + "test/cases/spec/1_0-final/test_signature_base_strings.rb", + "test/integration/consumer_test.rb", + "test/test_access_token.rb", + "test/test_action_controller_request_proxy.rb", + "test/test_consumer.rb", + "test/test_curb_request_proxy.rb", + "test/test_em_http_client.rb", + "test/test_em_http_request_proxy.rb", + "test/test_helper.rb", + "test/test_hmac_sha1.rb", + "test/test_net_http_client.rb", + "test/test_net_http_request_proxy.rb", + "test/test_oauth_helper.rb", + "test/test_rack_request_proxy.rb", + "test/test_request_token.rb", + "test/test_rsa_sha1.rb", + "test/test_server.rb", + "test/test_signature.rb", + "test/test_signature_base.rb", + "test/test_signature_plain_text.rb", + "test/test_token.rb", + "test/test_typhoeus_request_proxy.rb", + "examples/yql.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 2.3.5"]) + s.add_development_dependency(%q, [">= 1.0.0"]) + s.add_development_dependency(%q, [">= 0.9.8"]) + s.add_development_dependency(%q, [">= 0.1.13"]) + s.add_development_dependency(%q, [">= 0.2.10"]) + s.add_development_dependency(%q, [">= 0.6.6.0"]) + else + s.add_dependency(%q, [">= 2.3.5"]) + s.add_dependency(%q, [">= 1.0.0"]) + s.add_dependency(%q, [">= 0.9.8"]) + s.add_dependency(%q, [">= 0.1.13"]) + s.add_dependency(%q, [">= 0.2.10"]) + s.add_dependency(%q, [">= 0.6.6.0"]) + end + else + s.add_dependency(%q, [">= 2.3.5"]) + s.add_dependency(%q, [">= 1.0.0"]) + s.add_dependency(%q, [">= 0.9.8"]) + s.add_dependency(%q, [">= 0.1.13"]) + s.add_dependency(%q, [">= 0.2.10"]) + s.add_dependency(%q, [">= 0.6.6.0"]) + end +end + diff --git a/vendor/oauth-0.3.2/tasks/deployment.rake b/vendor/oauth-0.4.4/tasks/deployment.rake similarity index 100% rename from vendor/oauth-0.3.2/tasks/deployment.rake rename to vendor/oauth-0.4.4/tasks/deployment.rake diff --git a/vendor/oauth-0.3.2/tasks/environment.rake b/vendor/oauth-0.4.4/tasks/environment.rake similarity index 100% rename from vendor/oauth-0.3.2/tasks/environment.rake rename to vendor/oauth-0.4.4/tasks/environment.rake diff --git a/vendor/oauth-0.3.2/tasks/website.rake b/vendor/oauth-0.4.4/tasks/website.rake similarity index 100% rename from vendor/oauth-0.3.2/tasks/website.rake rename to vendor/oauth-0.4.4/tasks/website.rake diff --git a/vendor/oauth-0.3.2/test/cases/oauth_case.rb b/vendor/oauth-0.4.4/test/cases/oauth_case.rb similarity index 98% rename from vendor/oauth-0.3.2/test/cases/oauth_case.rb rename to vendor/oauth-0.4.4/test/cases/oauth_case.rb index 51eaa0a26..8b37dcf4a 100644 --- a/vendor/oauth-0.3.2/test/cases/oauth_case.rb +++ b/vendor/oauth-0.4.4/test/cases/oauth_case.rb @@ -9,11 +9,11 @@ def run(*args) return if @method_name.to_s == "default_test" super end - + protected - + # Creates a fake request def request(params={},method='GET',uri="http://photos.example.net/photos") OAuth::RequestProxy.proxy({'parameters'=>params,'method'=>method,'uri'=>uri}) end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_construct_request_url.rb b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_construct_request_url.rb similarity index 96% rename from vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_construct_request_url.rb rename to vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_construct_request_url.rb index 879b74e24..9a797c408 100644 --- a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_construct_request_url.rb +++ b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_construct_request_url.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../oauth_case' +require File.expand_path('../../../oauth_case', __FILE__) # See http://oauth.net/core/1.0/#anchor14 # @@ -19,11 +19,11 @@ class ConstructRequestUrlTest < OAuthCase - + def test_from_spec assert_request_url("http://example.com/resource","HTTP://Example.com:80/resource?id=123") end - + def test_simple_url_with_ending_slash assert_request_url("http://example.com/","http://example.com/") end @@ -31,7 +31,7 @@ def test_simple_url_with_ending_slash def test_simple_url_without_ending_slash assert_request_url("http://example.com/","http://example.com") end - + def test_of_normalized_http assert_request_url("http://example.com/resource","http://example.com/resource") end @@ -43,20 +43,20 @@ def test_of_https def test_of_normalized_https assert_request_url("https://example.com/resource","https://example.com/resource") end - + def test_of_http_with_non_standard_port assert_request_url("http://example.com:8080/resource","http://example.com:8080/resource") end - + def test_of_https_with_non_standard_port assert_request_url("https://example.com:8080/resource","https://example.com:8080/resource") end - + protected - - + + def assert_request_url(expected,given,message=nil) assert_equal expected, request({},'GET',given).normalized_uri, message end - -end \ No newline at end of file + +end diff --git a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_normalize_request_parameters.rb b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_normalize_request_parameters.rb similarity index 93% rename from vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_normalize_request_parameters.rb rename to vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_normalize_request_parameters.rb index 76d6e5a11..58b2d63f4 100644 --- a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +++ b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_normalize_request_parameters.rb @@ -1,31 +1,31 @@ -require File.dirname(__FILE__) + '/../../oauth_case' +require File.expand_path('../../../oauth_case', __FILE__) # See http://oauth.net/core/1.0/#anchor14 # # 9.1.1. Normalize Request Parameters -# +# # The request parameters are collected, sorted and concatenated into a normalized string: -# +# # Parameters in the OAuth HTTP Authorization header excluding the realm parameter. # Parameters in the HTTP POST request body (with a content-type of application/x-www-form-urlencoded). # HTTP GET parameters added to the URLs in the query part (as defined by [RFC3986] section 3). # The oauth_signature parameter MUST be excluded. -# +# # The parameters are normalized into a single string as follows: -# -# Parameters are sorted by name, using lexicographical byte value ordering. +# +# Parameters are sorted by name, using lexicographical byte value ordering. # If two or more parameters share the same name, they are sorted by their value. For example: # # a=1, c=hi%20there, f=25, f=50, f=a, z=p, z=t -# Parameters are concatenated in their sorted order into a single string. For each parameter, -# the name is separated from the corresponding value by an ‘=’ character (ASCII code 61), even +# Parameters are concatenated in their sorted order into a single string. For each parameter, +# the name is separated from the corresponding value by an ‘=’ character (ASCII code 61), even # if the value is empty. Each name-value pair is separated by an ‘&’ character (ASCII code 38). For example: # a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t -# +# class NormalizeRequestParametersTest < OAuthCase - + def test_parameters_for_signature params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'} assert_equal params,request(params).parameters_for_signature @@ -36,7 +36,7 @@ def test_parameters_for_signature_removes_oauth_signature params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'} assert_equal params,request(params.merge({'oauth_signature'=>'blalbla'})).parameters_for_signature end - + def test_spec_example assert_normalized 'a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t', { 'a' => 1, 'c' => 'hi there', 'f' => ['25', '50', 'a'], 'z' => ['p', 't'] } end @@ -49,26 +49,26 @@ def test_sorts_parameters_correctly def test_empty assert_normalized "",{} end - - + + # These are from the wiki http://wiki.oauth.net/TestCases # in the section Normalize Request Parameters # Parameters have already been x-www-form-urlencoded (i.e. + = ) def test_wiki1 assert_normalized "name=",{"name"=>nil} end - + def test_wiki2 assert_normalized "a=b",{'a'=>'b'} end - + def test_wiki3 assert_normalized "a=b&c=d",{'a'=>'b','c'=>'d'} end - + def test_wiki4 assert_normalized "a=x%20y&a=x%21y",{'a'=>["x!y","x y"]} - + end def test_wiki5 @@ -76,13 +76,13 @@ def test_wiki5 end protected - - + + def assert_normalized(expected,params,message=nil) assert_equal expected, normalize_request_parameters(params), message end - + def normalize_request_parameters(params={}) request(params).normalized_parameters end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_parameter_encodings.rb b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_parameter_encodings.rb similarity index 91% rename from vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_parameter_encodings.rb rename to vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_parameter_encodings.rb index 3ce072660..db18fd869 100644 --- a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_parameter_encodings.rb +++ b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_parameter_encodings.rb @@ -1,16 +1,16 @@ -require File.dirname(__FILE__) + '/../../oauth_case' +require File.expand_path('../../../oauth_case', __FILE__) # See http://oauth.net/core/1.0/#encoding_parameters # # 5.1. Parameter Encoding -# -# All parameter names and values are escaped using the [RFC3986] percent-encoding (%xx) mechanism. -# Characters not in the unreserved character set ([RFC3986] section 2.3) MUST be encoded. Characters -# in the unreserved character set MUST NOT be encoded. Hexadecimal characters in encodings MUST be +# +# All parameter names and values are escaped using the [RFC3986] percent-encoding (%xx) mechanism. +# Characters not in the unreserved character set ([RFC3986] section 2.3) MUST be encoded. Characters +# in the unreserved character set MUST NOT be encoded. Hexadecimal characters in encodings MUST be # upper case. Text names and values MUST be encoded as UTF-8 octets before percent-encoding them per [RFC3629]. -# +# # unreserved = ALPHA, DIGIT, '-', '.', '_', '~' -# +# class ParameterEncodingTest < OAuthCase def test_encodings_alpha_num diff --git a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_signature_base_strings.rb b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_signature_base_strings.rb similarity index 90% rename from vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_signature_base_strings.rb rename to vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_signature_base_strings.rb index fc099b56d..6f6f78970 100644 --- a/vendor/oauth-0.3.2/test/cases/spec/1_0-final/test_signature_base_strings.rb +++ b/vendor/oauth-0.4.4/test/cases/spec/1_0-final/test_signature_base_strings.rb @@ -1,20 +1,20 @@ -require File.dirname(__FILE__) + '/../../oauth_case' +require File.expand_path('../../../oauth_case', __FILE__) # See http://oauth.net/core/1.0/#anchor14 # # 9.1. Signature Base String -# +# # The Signature Base String is a consistent reproducible concatenation of the request elements -# into a single string. The string is used as an input in hashing or signing algorithms. The -# HMAC-SHA1 signature method provides both a standard and an example of using the Signature -# Base String with a signing algorithm to generate signatures. All the request parameters MUST +# into a single string. The string is used as an input in hashing or signing algorithms. The +# HMAC-SHA1 signature method provides both a standard and an example of using the Signature +# Base String with a signing algorithm to generate signatures. All the request parameters MUST # be encoded as described in Parameter Encoding prior to constructing the Signature Base String. -# +# class SignatureBaseStringTest < OAuthCase - + def test_A_5_1 - parameters={ + parameters={ 'oauth_consumer_key'=>'dpf43f3p2l4k3l03', 'oauth_token'=>'nnch734d00sl2jdk', 'oauth_signature_method'=>'HMAC-SHA1', @@ -25,34 +25,34 @@ def test_A_5_1 'size'=>'original' } sbs='GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal' - + assert_signature_base_string sbs,parameters,'GET',"http://photos.example.net/photos" end - + # These are from the wiki http://wiki.oauth.net/TestCases # in the section Concatenate Test Elements - + def test_wiki_1_simple_with_ending_slash - parameters={ + parameters={ 'n'=>'v' } sbs='GET&http%3A%2F%2Fexample.com%2F&n%3Dv' - + assert_signature_base_string sbs,parameters,'GET',"http://example.com/" end - + def test_wiki_2_simple_without_ending_slash - parameters={ + parameters={ 'n'=>'v' } sbs='GET&http%3A%2F%2Fexample.com%2F&n%3Dv' - + assert_signature_base_string sbs,parameters,'GET',"http://example.com" end def test_wiki_2_request_token - parameters={ + parameters={ 'oauth_version'=>'1.0', 'oauth_consumer_key'=>'dpf43f3p2l4k3l03', 'oauth_timestamp'=>'1191242090', @@ -60,18 +60,18 @@ def test_wiki_2_request_token 'oauth_signature_method'=>'PLAINTEXT', 'oauth_signature'=>'ignored' } sbs='POST&https%3A%2F%2Fphotos.example.net%2Frequest_token&oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dhsu94j3884jdopsl%26oauth_signature_method%3DPLAINTEXT%26oauth_timestamp%3D1191242090%26oauth_version%3D1.0' - + assert_signature_base_string sbs,parameters,'POST',"https://photos.example.net/request_token" end - + protected - - + + def assert_signature_base_string(expected,params={},method='GET',uri="http://photos.example.net/photos",message="Signature Base String does not match") assert_equal expected, signature_base_string(params,method,uri), message end - + def signature_base_string(params={},method='GET',uri="http://photos.example.net/photos") request(params,method,uri).signature_base_string end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.4.4/test/integration/consumer_test.rb b/vendor/oauth-0.4.4/test/integration/consumer_test.rb new file mode 100644 index 000000000..d5a934a69 --- /dev/null +++ b/vendor/oauth-0.4.4/test/integration/consumer_test.rb @@ -0,0 +1,304 @@ +require File.expand_path('../../test_helper', __FILE__) + +module Integration + class ConsumerTest < Test::Unit::TestCase + def setup + @consumer=OAuth::Consumer.new( + 'consumer_key_86cad9', '5888bf0345e5d237', + { + :site=>"http://blabla.bla", + :proxy=>"http://user:password@proxy.bla:8080", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php", + :scheme=>:header, + :http_method=>:get + }) + @token = OAuth::ConsumerToken.new(@consumer,'token_411a7f', '3196ffd991c8ebdb') + @request_uri = URI.parse('http://example.com/test?key=value') + @request_parameters = { 'key' => 'value' } + @nonce = 225579211881198842005988698334675835446 + @timestamp = "1199645624" + @consumer.http=Net::HTTP.new(@request_uri.host, @request_uri.port) + end + + def test_that_signing_auth_headers_on_get_requests_works + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + @token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'GET', request.method + assert_equal '/test?key=value', request.path + assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort + end + + def test_that_setting_signature_method_on_consumer_effects_signing + require 'oauth/signature/plaintext' + request = Net::HTTP::Get.new(@request_uri.path) + consumer = @consumer.dup + consumer.options[:signature_method] = 'PLAINTEXT' + token = OAuth::ConsumerToken.new(consumer, 'token_411a7f', '3196ffd991c8ebdb') + token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_no_match( /oauth_signature_method="HMAC-SHA1"/, request['authorization']) + assert_match( /oauth_signature_method="PLAINTEXT"/, request['authorization']) + end + + def test_that_setting_signature_method_on_consumer_effects_signature_base_string + require 'oauth/signature/plaintext' + request = Net::HTTP::Get.new(@request_uri.path) + consumer = @consumer.dup + consumer.options[:signature_method] = 'PLAINTEXT' + + request = Net::HTTP::Get.new('/') + signature_base_string = consumer.signature_base_string(request) + + assert_no_match( /HMAC-SHA1/, signature_base_string) + assert_equal( "#{consumer.secret}&", signature_base_string) + end + + def test_that_plaintext_signature_works + # Invalid test because server expects double-escaped signature + require 'oauth/signature/plaintext' + # consumer = OAuth::Consumer.new("key", "secret", + # :site => "http://term.ie", :signature_method => 'PLAINTEXT') + # access_token = OAuth::AccessToken.new(consumer, 'accesskey', 'accesssecret') + # response = access_token.get("/oauth/example/echo_api.php?echo=hello") + + # assert_equal 'echo=hello', response.body + end + + def test_that_signing_auth_headers_on_post_requests_works + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + @token.sign!(request, {:nonce => @nonce, :timestamp => @timestamp}) + # assert_equal "",request.oauth_helper.signature_base_string + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal 'key=value', request.body + assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort + end + + def test_that_signing_post_params_works + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + @token.sign!(request, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_that_using_auth_headers_on_get_on_create_signed_requests_works + request=@consumer.create_signed_request(:get,@request_uri.path+ "?" + request_parameters_to_s,@token,{:nonce => @nonce, :timestamp => @timestamp},@request_parameters) + + assert_equal 'GET', request.method + assert_equal '/test?key=value', request.path + assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort + end + + def test_that_using_auth_headers_on_post_on_create_signed_requests_works + request=@consumer.create_signed_request(:post,@request_uri.path,@token,{:nonce => @nonce, :timestamp => @timestamp},@request_parameters,{}) + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal 'key=value', request.body + assert_equal "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"".split(', ').sort, request['authorization'].split(', ').sort + end + + def test_that_signing_post_params_works_2 + request=@consumer.create_signed_request(:post,@request_uri.path,@token,{:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp},@request_parameters,{}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_step_by_step_token_request + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://term.ie", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php", + :scheme=>:header + }) + options={:nonce=>'nonce',:timestamp=>Time.now.to_i.to_s} + + request = Net::HTTP::Get.new("/oauth/example/request_token.php") + signature_base_string=@consumer.signature_base_string(request,nil,options) + assert_equal "GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3D#{options[:nonce]}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D#{options[:timestamp]}%26oauth_version%3D1.0",signature_base_string + @consumer.sign!(request, nil,options) + + assert_equal 'GET', request.method + assert_equal nil, request.body + response=@consumer.http.request(request) + assert_equal "200",response.code + assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body + end + + def test_get_token_sequence + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://term.ie", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php" + }) + assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url + assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url + + assert !@consumer.request_token_url?, "Should not use fully qualified request token url" + assert !@consumer.access_token_url?, "Should not use fully qualified access token url" + assert !@consumer.authorize_url?, "Should not use fully qualified url" + + @request_token=@consumer.get_request_token + assert_not_nil @request_token + assert_equal "requestkey",@request_token.token + assert_equal "requestsecret",@request_token.secret + assert_equal "http://term.ie/oauth/example/authorize.php?oauth_token=requestkey",@request_token.authorize_url + + @access_token=@request_token.get_access_token + assert_not_nil @access_token + assert_equal "accesskey",@access_token.token + assert_equal "accesssecret",@access_token.secret + + @response=@access_token.get("/oauth/example/echo_api.php?ok=hello&test=this") + assert_not_nil @response + assert_equal "200",@response.code + assert_equal( "ok=hello&test=this",@response.body) + + @response=@access_token.post("/oauth/example/echo_api.php",{'ok'=>'hello','test'=>'this'}) + assert_not_nil @response + assert_equal "200",@response.code + assert_equal( "ok=hello&test=this",@response.body) + end + + def test_get_token_sequence_using_fqdn + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://term.ie", + :request_token_url=>"http://term.ie/oauth/example/request_token.php", + :access_token_url=>"http://term.ie/oauth/example/access_token.php", + :authorize_url=>"http://term.ie/oauth/example/authorize.php" + }) + assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url + assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url + + assert @consumer.request_token_url?, "Should use fully qualified request token url" + assert @consumer.access_token_url?, "Should use fully qualified access token url" + assert @consumer.authorize_url?, "Should use fully qualified url" + + @request_token=@consumer.get_request_token + assert_not_nil @request_token + assert_equal "requestkey",@request_token.token + assert_equal "requestsecret",@request_token.secret + assert_equal "http://term.ie/oauth/example/authorize.php?oauth_token=requestkey",@request_token.authorize_url + + @access_token=@request_token.get_access_token + assert_not_nil @access_token + assert_equal "accesskey",@access_token.token + assert_equal "accesssecret",@access_token.secret + + @response=@access_token.get("/oauth/example/echo_api.php?ok=hello&test=this") + assert_not_nil @response + assert_equal "200",@response.code + assert_equal( "ok=hello&test=this",@response.body) + + @response=@access_token.post("/oauth/example/echo_api.php",{'ok'=>'hello','test'=>'this'}) + assert_not_nil @response + assert_equal "200",@response.code + assert_equal( "ok=hello&test=this",@response.body) + end + + + # This test does an actual https request (the result doesn't matter) + # to initialize the same way as get_request_token does. Can be any + # site that supports https. + # + # It also generates "warning: using default DH parameters." which I + # don't know how to get rid of + # def test_serialization_with_https + # consumer = OAuth::Consumer.new('token', 'secret', :site => 'https://plazes.net') + # consumer.http.verify_mode = OpenSSL::SSL::VERIFY_NONE + # consumer.http.get('/') + # + # assert_nothing_raised do + # # Specifically this should not raise TypeError: no marshal_dump + # # is defined for class OpenSSL::SSL::SSLContext + # Marshal.dump(consumer) + # end + # end + # + def test_get_request_token_with_custom_arguments + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://term.ie", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php" + }) + + + debug = "" + @consumer.http.set_debug_output(debug) + + # get_request_token should receive our custom request_options and *arguments parameters from get_request_token. + @consumer.get_request_token({}, {:scope => "http://www.google.com/calendar/feeds http://picasaweb.google.com/data"}) + + # Because this is a POST request, create_http_request should take the first element of *arguments + # and turn it into URL-encoded data in the body of the POST. + assert_match( /^<- "scope=http%3a%2f%2fwww.google.com%2fcalendar%2ffeeds%20http%3a%2f%2fpicasaweb.google.com%2fdata"/, + debug) + end + + def test_post_with_body_stream + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://term.ie", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php" + }) + + + @request_token=@consumer.get_request_token + @access_token=@request_token.get_access_token + + request_body_string = "Hello, hello, hello" + request_body_stream = StringIO.new( request_body_string ) + + @response=@access_token.post("/oauth/example/echo_api.php",request_body_stream) + assert_not_nil @response + assert_equal "200",@response.code + + request_body_file = File.open(__FILE__) + + @response=@access_token.post("/oauth/example/echo_api.php",request_body_file) + assert_not_nil @response + assert_equal "200",@response.code + + # unfortunately I don't know of a way to test that the body data was received correctly since the test server at http://term.ie + # echos back any non-oauth parameters but not the body. However, this does test that the request is still correctly signed + # (including the Content-Length header) and that the server received Content-Length bytes of body since it won't process the + # request & respond until the full body length is received. + end + + private + + def request_parameters_to_s + @request_parameters.map { |k,v| "#{k}=#{v}" }.join("&") + end + end +end diff --git a/vendor/oauth-0.3.2/test/keys/rsa.cert b/vendor/oauth-0.4.4/test/keys/rsa.cert similarity index 100% rename from vendor/oauth-0.3.2/test/keys/rsa.cert rename to vendor/oauth-0.4.4/test/keys/rsa.cert diff --git a/vendor/oauth-0.3.2/test/keys/rsa.pem b/vendor/oauth-0.4.4/test/keys/rsa.pem similarity index 100% rename from vendor/oauth-0.3.2/test/keys/rsa.pem rename to vendor/oauth-0.4.4/test/keys/rsa.pem diff --git a/vendor/oauth-0.3.2/test/test_access_token.rb b/vendor/oauth-0.4.4/test/test_access_token.rb similarity index 87% rename from vendor/oauth-0.3.2/test/test_access_token.rb rename to vendor/oauth-0.4.4/test/test_access_token.rb index 040e2db2e..591a1c91f 100644 --- a/vendor/oauth-0.3.2/test/test_access_token.rb +++ b/vendor/oauth-0.4.4/test/test_access_token.rb @@ -1,6 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/token' -require 'oauth/consumer' +require File.expand_path('../test_helper', __FILE__) class TestAccessToken < Test::Unit::TestCase def setup @@ -25,4 +23,4 @@ def test_access_token_makes_non_oauth_response_params_available assert_not_nil @access_token.params[:user_id] assert_equal 5734758743895, @access_token.params[:user_id] end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.4.4/test/test_action_controller_request_proxy.rb b/vendor/oauth-0.4.4/test/test_action_controller_request_proxy.rb new file mode 100644 index 000000000..cab8e528e --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_action_controller_request_proxy.rb @@ -0,0 +1,133 @@ +gem 'actionpack', '2.3.8' +require File.expand_path('../test_helper', __FILE__) + +require 'oauth/request_proxy/action_controller_request' +require 'action_controller/test_process' + +class ActionControllerRequestProxyTest < Test::Unit::TestCase + + def request_proxy(request_method = :get, uri_params = {}, body_params = {}) + request = ActionController::TestRequest.new + request.set_REQUEST_URI('/') + + case request_method + when :post + request.env['REQUEST_METHOD'] = 'POST' + when :put + request.env['REQUEST_METHOD'] = 'PUT' + end + + request.env['REQUEST_URI'] = '/' + request.env['RAW_POST_DATA'] = body_params.to_query + request.env['QUERY_STRING'] = body_params.to_query + request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded' + + yield request if block_given? + OAuth::RequestProxy::ActionControllerRequest.new(request, :parameters => uri_params) + end + + def test_that_proxy_simple_get_request_works_with_query_params + request_proxy = request_proxy(:get, {'key'=>'value'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'GET', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_query_params + request_proxy = request_proxy(:post, {'key'=>'value'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_query_params + request_proxy = request_proxy(:put, {'key'=>'value'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_simple_get_request_works_with_post_params + request_proxy = request_proxy(:get, {}, {'key'=>'value'}) + + expected_parameters = [] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'GET', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_post_params + request_proxy = request_proxy(:post, {}, {'key'=>'value'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_post_params + request_proxy = request_proxy(:put, {}, {'key'=>'value'}) + + expected_parameters = [] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_simple_get_request_works_with_mixed_params + request_proxy = request_proxy(:get, {'key'=>'value'}, {'key2'=>'value2'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'GET', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_mixed_params + request_proxy = request_proxy(:post, {'key'=>'value'}, {'key2'=>'value2'}) + + expected_parameters = [["key", "value"],["key2", "value2"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_mixed_params + request_proxy = request_proxy(:put, {'key'=>'value'}, {'key2'=>'value2'}) + + expected_parameters = [["key", "value"]] + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'PUT', request_proxy.method + end + + def test_parameter_keys_should_preserve_brackets_from_hash + assert_equal( + [["message[body]", "This is a test"]], + request_proxy(:post, { :message => { :body => 'This is a test' }}).parameters_for_signature + ) + end + + def test_parameter_values_with_amps_should_not_break_parameter_parsing + assert_equal( + [['message[body]', 'http://foo.com/?a=b&c=d']], + request_proxy(:post, { :message => { :body => 'http://foo.com/?a=b&c=d'}}).parameters_for_signature + ) + end + + def test_parameter_keys_should_preserve_brackets_from_array + assert_equal( + [["foo[]", "123"], ["foo[]", "456"]], + request_proxy(:post, { :foo => [123, 456] }).parameters_for_signature.sort + ) + end + + # TODO disabled; ActionController::TestRequest does not appear to parse + # QUERY_STRING + def x_test_query_string_parameter_values_should_be_cgi_unescaped + request = request_proxy do |r| + r.env['QUERY_STRING'] = 'url=http%3A%2F%2Ffoo.com%2F%3Fa%3Db%26c%3Dd' + end + assert_equal( + [['url', 'http://foo.com/?a=b&c=d']], + request.parameters_for_signature.sort + ) + end +end diff --git a/vendor/oauth-0.4.4/test/test_consumer.rb b/vendor/oauth-0.4.4/test/test_consumer.rb new file mode 100644 index 000000000..0d48654fb --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_consumer.rb @@ -0,0 +1,159 @@ +require File.expand_path('../test_helper', __FILE__) +require 'mocha' + +require 'stringio' + +# This performs testing against Andy Smith's test server http://term.ie/oauth/example/ +# Thanks Andy. +# This also means you have to be online to be able to run these. +class ConsumerTest < Test::Unit::TestCase + def setup + @consumer=OAuth::Consumer.new( + 'consumer_key_86cad9', '5888bf0345e5d237', + { + :site=>"http://blabla.bla", + :proxy=>"http://user:password@proxy.bla:8080", + :request_token_path=>"/oauth/example/request_token.php", + :access_token_path=>"/oauth/example/access_token.php", + :authorize_path=>"/oauth/example/authorize.php", + :scheme=>:header, + :http_method=>:get + }) + @token = OAuth::ConsumerToken.new(@consumer,'token_411a7f', '3196ffd991c8ebdb') + @request_uri = URI.parse('http://example.com/test?key=value') + @request_parameters = { 'key' => 'value' } + @nonce = 225579211881198842005988698334675835446 + @timestamp = "1199645624" + @consumer.http=Net::HTTP.new(@request_uri.host, @request_uri.port) + end + + def test_initializer + assert_equal "consumer_key_86cad9",@consumer.key + assert_equal "5888bf0345e5d237",@consumer.secret + assert_equal "http://blabla.bla",@consumer.site + assert_equal "http://user:password@proxy.bla:8080",@consumer.proxy + assert_equal "/oauth/example/request_token.php",@consumer.request_token_path + assert_equal "/oauth/example/access_token.php",@consumer.access_token_path + assert_equal "http://blabla.bla/oauth/example/request_token.php",@consumer.request_token_url + assert_equal "http://blabla.bla/oauth/example/access_token.php",@consumer.access_token_url + assert_equal "http://blabla.bla/oauth/example/authorize.php",@consumer.authorize_url + assert_equal :header,@consumer.scheme + assert_equal :get,@consumer.http_method + end + + def test_defaults + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://twitter.com" + }) + assert_equal "key",@consumer.key + assert_equal "secret",@consumer.secret + assert_equal "http://twitter.com",@consumer.site + assert_nil @consumer.proxy + assert_equal "/oauth/request_token",@consumer.request_token_path + assert_equal "/oauth/access_token",@consumer.access_token_path + assert_equal "http://twitter.com/oauth/request_token",@consumer.request_token_url + assert_equal "http://twitter.com/oauth/access_token",@consumer.access_token_url + assert_equal "http://twitter.com/oauth/authorize",@consumer.authorize_url + assert_equal :header,@consumer.scheme + assert_equal :post,@consumer.http_method + end + + def test_override_paths + @consumer=OAuth::Consumer.new( + "key", + "secret", + { + :site=>"http://twitter.com", + :request_token_url=>"http://oauth.twitter.com/request_token", + :access_token_url=>"http://oauth.twitter.com/access_token", + :authorize_url=>"http://site.twitter.com/authorize" + }) + assert_equal "key",@consumer.key + assert_equal "secret",@consumer.secret + assert_equal "http://twitter.com",@consumer.site + assert_equal "/oauth/request_token",@consumer.request_token_path + assert_equal "/oauth/access_token",@consumer.access_token_path + assert_equal "http://oauth.twitter.com/request_token",@consumer.request_token_url + assert_equal "http://oauth.twitter.com/access_token",@consumer.access_token_url + assert_equal "http://site.twitter.com/authorize",@consumer.authorize_url + assert_equal :header,@consumer.scheme + assert_equal :post,@consumer.http_method + end + + def test_that_token_response_should_be_uri_parameter_format_as_default + @consumer.expects(:request).returns(create_stub_http_response("oauth_token=token&oauth_token_secret=secret")) + + hash = @consumer.token_request(:get, "") + + assert_equal "token", hash[:oauth_token] + assert_equal "secret", hash[:oauth_token_secret] + end + + def test_can_provided_a_block_to_interpret_token_response + @consumer.expects(:request).returns(create_stub_http_response) + + hash = @consumer.token_request(:get, '') {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }} + + assert_equal 'token', hash[:oauth_token] + assert_equal 'secret', hash[:oauth_token_secret] + end + + def test_that_can_provide_a_block_to_interpret_a_request_token_response + @consumer.expects(:request).returns(create_stub_http_response) + + token = @consumer.get_request_token {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }} + + assert_equal 'token', token.token + assert_equal 'secret', token.secret + end + + def test_that_block_is_not_mandatory_for_getting_an_access_token + stub_token = mock + @consumer.expects(:request).returns(create_stub_http_response("oauth_token=token&oauth_token_secret=secret")) + + token = @consumer.get_access_token(stub_token) + + assert_equal 'token', token.token + assert_equal 'secret', token.secret + end + + def test_that_can_provide_a_block_to_interpret_an_access_token_response + stub_token = mock + @consumer.expects(:request).returns(create_stub_http_response) + + token = @consumer.get_access_token(stub_token) {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }} + + assert_equal 'token', token.token + assert_equal 'secret', token.secret + end + + def test_that_not_setting_ignore_callback_will_include_oauth_callback_in_request_options + request_options = {} + @consumer.stubs(:request).returns(create_stub_http_response) + + @consumer.get_request_token(request_options) {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }} + + assert_equal 'oob', request_options[:oauth_callback] + end + + def test_that_setting_ignore_callback_will_exclude_oauth_callback_in_request_options + request_options = { :exclude_callback=> true } + @consumer.stubs(:request).returns(create_stub_http_response) + + @consumer.get_request_token(request_options) {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }} + + assert_nil request_options[:oauth_callback] + end + + private + + def create_stub_http_response expected_body=nil + stub_http_response = stub + stub_http_response.stubs(:code).returns(200) + stub_http_response.stubs(:body).tap {|expectation| expectation.returns(expected_body) unless expected_body.nil? } + return stub_http_response + end +end diff --git a/vendor/oauth-0.4.4/test/test_curb_request_proxy.rb b/vendor/oauth-0.4.4/test/test_curb_request_proxy.rb new file mode 100644 index 000000000..8abf2456c --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_curb_request_proxy.rb @@ -0,0 +1,77 @@ +require File.expand_path('../test_helper', __FILE__) + +begin + +require 'oauth/request_proxy/curb_request' +require 'curb' + + +class CurbRequestProxyTest < Test::Unit::TestCase + + def test_that_proxy_simple_get_request_works + request = Curl::Easy.new('/test?key=value') + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end + + def test_that_proxy_simple_post_request_works_with_arguments + request = Curl::Easy.new('/test') + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end + + def test_that_proxy_simple_post_request_works_with_form_data + request = Curl::Easy.new('/test') + request.post_body = 'key=value' + request.headers['Content-Type'] = 'application/x-www-form-urlencoded' + + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end + + def test_that_proxy_simple_put_request_works_with_arguments + request = Curl::Easy.new('/test') + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end + + def test_that_proxy_simple_put_request_works_with_form_data + request = Curl::Easy.new('/test') + request.post_body = 'key=value' + + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end + + def test_that_proxy_post_request_works_with_mixed_parameter_sources + request = Curl::Easy.new('/test?key=value') + request.post_body = 'key2=value2' + request.headers['Content-Type'] = 'application/x-www-form-urlencoded' + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}}) + + expected_parameters = {'key' => ['value'], 'key2' => 'value2', 'key3' => 'value3'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + end +end + +rescue LoadError => e + warn "! problems loading curb, skipping these tests: #{e}" +end diff --git a/vendor/oauth-0.4.4/test/test_em_http_client.rb b/vendor/oauth-0.4.4/test/test_em_http_client.rb new file mode 100644 index 000000000..603fd8b0c --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_em_http_client.rb @@ -0,0 +1,80 @@ +require File.expand_path('../test_helper', __FILE__) +begin + +require 'oauth/client/em_http' + +class EmHttpClientTest < Test::Unit::TestCase + + def setup + @consumer = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237') + @token = OAuth::Token.new('token_411a7f', '3196ffd991c8ebdb') + @request_uri = URI.parse('http://example.com/test?key=value') + @request_parameters = { 'key' => 'value' } + @nonce = 225579211881198842005988698334675835446 + @timestamp = "1199645624" + # This is really unneeded I guess. + @http = Net::HTTP.new(@request_uri.host, @request_uri.port) + end + + def test_that_using_auth_headers_on_get_requests_works + request = create_client + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'GET', request.method + assert_equal '/test', request.normalize_uri.path + assert_equal "key=value", request.normalize_uri.query + assert_equal_authz_headers "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"", authz_header(request) + end + + def test_that_using_auth_headers_on_get_requests_works_with_plaintext + require 'oauth/signature/plaintext' + c = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237',{ + :signature_method => 'PLAINTEXT' + }) + request = create_client + request.oauth!(@http, c, @token, {:nonce => @nonce, :timestamp => @timestamp, :signature_method => 'PLAINTEXT'}) + + assert_equal 'GET', request.method + assert_equal '/test', request.normalize_uri.path + assert_equal "key=value", request.normalize_uri.query + assert_equal_authz_headers "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"PLAINTEXT\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"5888bf0345e5d237%263196ffd991c8ebdb\", oauth_version=\"1.0\"", authz_header(request) + end + + def test_that_using_auth_headers_on_post_requests_works + request = create_client(:uri => "http://example.com/test", :method => "POST", :body => @request_parameters, :head => {"Content-Type" => "application/x-www-form-urlencoded"}) + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + assert_equal '/test', request.uri.path + assert_equal 'key=value', request.normalize_body + assert_equal_authz_headers "OAuth oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"", authz_header(request) + end + + protected + + def create_client(options = {}) + method = options.delete(:method) || "GET" + uri = options.delete(:uri) || @request_uri.to_s + client = EventMachine::HttpClient.new("") + client.uri = URI.parse(uri) + client.method = method.to_s.upcase + client.options = options + client + end + + def authz_header(request) + headers = request.options[:head] || {} + headers['Authorization'].to_s + end + + def assert_equal_authz_headers(expected, actual) + assert !actual.nil? + assert_equal expected[0,6], actual[0, 6] + assert_equal expected[6..1].split(', ').sort, actual[6..1].split(', ').sort + end + +end + +rescue LoadError => e + warn "! problem loading em-http, skipping these tests: #{e}" +end diff --git a/vendor/oauth-0.4.4/test/test_em_http_request_proxy.rb b/vendor/oauth-0.4.4/test/test_em_http_request_proxy.rb new file mode 100644 index 000000000..ab0b5a5f6 --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_em_http_request_proxy.rb @@ -0,0 +1,115 @@ +require File.expand_path('../test_helper', __FILE__) + +begin + +require 'em-http' +require 'oauth/request_proxy/em_http_request' + + +class EmHttpRequestProxyTest < Test::Unit::TestCase + + def test_request_proxy_works_with_simple_request + proxy = create_request_proxy + assert_equal({}, proxy.parameters) + end + + def test_request_proxy_works_with_query_string_params + assert_equal({"name" => ["Fred"]}, create_request_proxy(:query => "name=Fred").parameters) + assert_equal({"name" => ["Fred"]}, create_request_proxy(:query => {:name => "Fred"}).parameters) + proxy = create_request_proxy(:query => {:name => "Fred"}, :uri => "http://example.com/?awesome=true") + assert_equal({"name" => ["Fred"], "awesome" => ["true"]}, proxy.parameters) + end + + def test_request_proxy_works_with_post_body_params_with_correct_content_type + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "POST" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "POST", :body => "a=1" + assert_equal({"a" => ["1"]}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "POST", :body => {"a" => 1} + assert_equal({"a" => ["1"]}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "PUT" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "PUT", :body => "a=1" + assert_equal({"a" => ["1"]}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "PUT", :body => {"a" => 1} + assert_equal({"a" => ["1"]}, proxy.parameters) + end + + def test_request_proxy_ignore_post_body_with_invalid_content_type + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "POST" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "POST", :body => "a=1" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "POST", :body => {"a" => 1} + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "PUT" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "PUT", :body => "a=1" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'text/plain'}, :method => "PUT", :body => {"a" => 1} + assert_equal({}, proxy.parameters) + end + + def test_request_proxy_ignores_post_body_with_invalid_method + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "DELETE" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "DELETE", :body => "a=1" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "DELETE", :body => {"a" => 1} + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "GET" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "GET", :body => "a=1" + assert_equal({}, proxy.parameters) + proxy = create_request_proxy :head => {'Content-Type' => 'application/x-www-form-urlencoded'}, :method => "GET", :body => {"a" => 1} + assert_equal({}, proxy.parameters) + end + + def test_request_proxy_works_with_argument_params + assert_equal({"a" => ["1"]}, create_request_proxy(:proxy_options => {:parameters => {"a" => "1"}}).parameters) + end + + def test_request_proxy_works_with_mixed_params + proxy = create_request_proxy(:proxy_options => {:parameters => {"a" => "1"}},:query => {"c" => "1"}, :uri => "http://example.com/test?b=1") + assert_equal({"a" => ["1"], "b" => ["1"], "c" => ["1"]}, proxy.parameters) + proxy = create_request_proxy(:proxy_options => {:parameters => {"a" => "1"}}, :body => {"b" => "1"}, :query => {"c" => "1"}, + :uri => "http://example.com/test?d=1", :method => "POST", :head => {"Content-Type" => "application/x-www-form-urlencoded"}) + assert_equal({"a" => ["1"], "b" => ["1"], "c" => ["1"], "d" => ["1"]}, proxy.parameters) + end + + def test_request_has_the_correct_uri + assert_equal "http://example.com/", create_request_proxy.uri + assert_equal "http://example.com/?a=1", create_request_proxy(:query => "a=1").uri + assert_equal "http://example.com/?a=1", create_request_proxy(:query => {"a" => "1"}).uri + + end + + def test_request_proxy_has_correct_method + assert_equal "GET", create_request_proxy(:method => "GET").method + assert_equal "PUT", create_request_proxy(:method => "PUT").method + assert_equal "POST", create_request_proxy(:method => "POST").method + assert_equal "DELETE", create_request_proxy(:method => "DELETE").method + end + + protected + + def create_client(options = {}) + method = options.delete(:method) || "GET" + uri = options.delete(:uri) || "http://example.com/" + client = EventMachine::HttpClient.new("") + client.uri = URI.parse(uri) + client.method = method.to_s.upcase + client.options = options + client + end + + def create_request_proxy(opts = {}) + arguments = opts.delete(:proxy_options) || {} + OAuth::RequestProxy.proxy(create_client(opts), arguments) + end + +end + +rescue LoadError => e + warn "! problem loading em-http, skipping these tests: #{e}" +end diff --git a/vendor/oauth-0.4.4/test/test_helper.rb b/vendor/oauth-0.4.4/test/test_helper.rb new file mode 100644 index 000000000..27defe30d --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_helper.rb @@ -0,0 +1,20 @@ +require 'test/unit' +require 'rubygems' + +$LOAD_PATH << File.dirname(__FILE__) + '/../lib/' +require 'oauth' +require 'mocha' +require 'stringio' + +class Test::Unit::TestCase + + def assert_matching_headers(expected, actual) + # transform into sorted arrays + auth_intro, auth_params = actual.split(' ', 2) + assert_equal auth_intro, 'OAuth' + expected = expected.split(/(,|\s)/).reject {|v| v == '' || v =~ /^[\,\s]+/}.sort + auth_params = auth_params.split(/(,|\s)/).reject {|v| v == '' || v =~ /^[\,\s]+/}.sort + assert_equal expected, auth_params + end + +end diff --git a/vendor/oauth-0.3.2/test/test_hmac_sha1.rb b/vendor/oauth-0.4.4/test/test_hmac_sha1.rb similarity index 91% rename from vendor/oauth-0.3.2/test/test_hmac_sha1.rb rename to vendor/oauth-0.4.4/test/test_hmac_sha1.rb index 81c3642bf..ef0360b5a 100644 --- a/vendor/oauth-0.3.2/test/test_hmac_sha1.rb +++ b/vendor/oauth-0.4.4/test/test_hmac_sha1.rb @@ -1,5 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/signature/hmac/sha1' +require File.expand_path('../test_helper', __FILE__) class TestSignatureHmacSha1 < Test::Unit::TestCase def test_that_hmac_sha1_implements_hmac_sha1 diff --git a/vendor/oauth-0.4.4/test/test_net_http_client.rb b/vendor/oauth-0.4.4/test/test_net_http_client.rb new file mode 100644 index 000000000..a1978d500 --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_net_http_client.rb @@ -0,0 +1,277 @@ +require File.expand_path('../test_helper', __FILE__) + +class NetHTTPClientTest < Test::Unit::TestCase + + def setup + @consumer = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237') + @token = OAuth::Token.new('token_411a7f', '3196ffd991c8ebdb') + @request_uri = URI.parse('http://example.com/test?key=value') + @request_parameters = { 'key' => 'value' } + @nonce = 225579211881198842005988698334675835446 + @timestamp = "1199645624" + @http = Net::HTTP.new(@request_uri.host, @request_uri.port) + end + + def test_that_using_auth_headers_on_get_requests_works + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'GET', request.method + assert_equal '/test?key=value', request.path + correct_sorted_params = "oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"" + auth_intro, auth_params = request['authorization'].split(' ', 2) + assert_equal auth_intro, 'OAuth' + assert_matching_headers correct_sorted_params, request['authorization'] + end + + def test_that_using_auth_headers_on_get_requests_works_with_plaintext + require 'oauth/signature/plaintext' + c = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237',{ + :signature_method => 'PLAINTEXT' + }) + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + request.oauth!(@http, c, @token, {:nonce => @nonce, :timestamp => @timestamp, :signature_method => 'PLAINTEXT'}) + + assert_equal 'GET', request.method + assert_equal '/test?key=value', request.path + assert_matching_headers "oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"PLAINTEXT\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"5888bf0345e5d237%263196ffd991c8ebdb\", oauth_version=\"1.0\"", request['authorization'] + end + + def test_that_using_auth_headers_on_post_requests_works + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal 'key=value', request.body + correct_sorted_params = "oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"" + assert_matching_headers correct_sorted_params, request['authorization'] + end + + def test_that_using_auth_headers_on_post_requests_with_data_works + request = Net::HTTP::Post.new(@request_uri.path) + request.body = "data" + request.content_type = 'text/ascii' + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal 'data', request.body + assert_equal 'text/ascii', request.content_type + assert_matching_headers "oauth_nonce=\"225579211881198842005988698334675835446\", oauth_body_hash=\"oXyaqmHoChv3HQ2FCvTluqmAC70%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"0DA6pGTapdHSqC15RZelY5rNLDw%3D\", oauth_version=\"1.0\"", request['authorization'] + end + + def test_that_body_hash_is_obmitted_when_no_algorithm_is_defined + request = Net::HTTP::Post.new(@request_uri.path) + request.body = "data" + request.content_type = 'text/ascii' + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp, :signature_method => 'plaintext'}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal 'data', request.body + assert_equal 'text/ascii', request.content_type + assert_matching_headers "oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"plaintext\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"5888bf0345e5d237%263196ffd991c8ebdb\", oauth_version=\"1.0\"", request['authorization'] + end + + def test_that_version_is_added_to_existing_user_agent + request = Net::HTTP::Post.new(@request_uri.path) + request['User-Agent'] = "MyApp" + request.set_form_data( @request_parameters ) + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal "MyApp (OAuth gem v#{OAuth::VERSION})", request['User-Agent'] + end + + def test_that_version_is_set_when_no_user_agent + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp}) + + assert_equal "OAuth gem v#{OAuth::VERSION}", request['User-Agent'] + end + + def test_that_using_get_params_works + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'GET', request.method + uri = URI.parse(request.path) + assert_equal '/test', uri.path + assert_equal nil, uri.fragment + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=1oO2izFav1GP4kEH2EskwXkCRFg%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_that_using_get_params_works_with_plaintext + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp, :signature_method => 'PLAINTEXT'}) + + assert_equal 'GET', request.method + uri = URI.parse(request.path) + assert_equal '/test', uri.path + assert_equal nil, uri.fragment + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=5888bf0345e5d237%263196ffd991c8ebdb&oauth_signature_method=PLAINTEXT&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_that_using_post_params_works + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_that_using_post_params_works_with_plaintext + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( @request_parameters ) + request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp, :signature_method => 'PLAINTEXT'}) + + assert_equal 'POST', request.method + assert_equal '/test', request.path + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=5888bf0345e5d237%263196ffd991c8ebdb&oauth_signature_method=PLAINTEXT&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&") + assert_equal nil, request['authorization'] + end + + def test_that_using_post_with_uri_params_works + request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s) + request.set_form_data( {} ) # just to make sure we have a correct mime type and thus no body hash + request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + uri = URI.parse(request.path) + assert_equal '/test', uri.path + assert_equal nil, uri.fragment + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&') + assert_equal "", request.body + assert_equal nil, request['authorization'] + end + + def test_that_using_post_with_uri_and_form_params_works + request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s) + request.set_form_data( { 'key2' => 'value2' } ) + request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + uri = URI.parse(request.path) + assert_equal '/test', uri.path + assert_equal nil, uri.fragment + assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=4kSU8Zd1blWo3W6qJH7eaRTMkg0%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&') + assert_equal "key2=value2", request.body + assert_equal nil, request['authorization'] + end + + def test_that_using_post_with_uri_and_data_works + request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s) + request.body = "data" + request.content_type = 'text/ascii' + request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp}) + + assert_equal 'POST', request.method + uri = URI.parse(request.path) + assert_equal '/test', uri.path + assert_equal nil, uri.fragment + assert_equal "data", request.body + assert_equal 'text/ascii', request.content_type + assert_equal "key=value&oauth_body_hash=oXyaqmHoChv3HQ2FCvTluqmAC70%3D&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=MHRKU42iVHU4Ke9kBUDa9Zw6IAM%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&') + assert_equal nil, request['authorization'] + end + + + def test_example_from_specs + consumer=OAuth::Consumer.new("dpf43f3p2l4k3l03","kd94hf93k423kf44") + token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00') + request_uri = URI.parse('http://photos.example.net/photos?file=vacation.jpg&size=original') + nonce = 'kllo9940pd9333jh' + timestamp = "1191242096" + http = Net::HTTP.new(request_uri.host, request_uri.port) + + request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query) + signature_base_string=request.signature_base_string(http, consumer, token, {:nonce => nonce, :timestamp => timestamp}) + assert_equal 'GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal',signature_base_string + +# request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query) + request.oauth!(http, consumer, token, {:nonce => nonce, :timestamp => timestamp, :realm=>"http://photos.example.net/"}) + + assert_equal 'GET', request.method + correct_sorted_params = 'oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="nnch734d00sl2jdk", oauth_timestamp="1191242096", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"'.split(', ').sort + correct_sorted_params.unshift 'OAuth realm="http://photos.example.net/"' + assert_equal correct_sorted_params, request['authorization'].split(', ').sort + end + + def test_step_by_step_token_request + consumer=OAuth::Consumer.new( + "key", + "secret") + request_uri = URI.parse('http://term.ie/oauth/example/request_token.php') + nonce = rand(2**128).to_s + timestamp = Time.now.to_i.to_s + http = Net::HTTP.new(request_uri.host, request_uri.port) + + request = Net::HTTP::Get.new(request_uri.path) + signature_base_string=request.signature_base_string(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp}) + assert_equal "GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3D#{nonce}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D#{timestamp}%26oauth_version%3D1.0",signature_base_string + +# request = Net::HTTP::Get.new(request_uri.path) + request.oauth!(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp}) + assert_equal 'GET', request.method + assert_nil request.body + assert_nil request['authorization'] +# assert_equal 'OAuth oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="", oauth_timestamp="'+timestamp+'", oauth_consumer_key="key", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"', request['authorization'] + + response=http.request(request) + assert_equal "200",response.code +# assert_equal request['authorization'],response.body + assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body + end + + def test_that_put_bodies_signed + request = Net::HTTP::Put.new(@request_uri.path) + request.body = "baz" + request["Content-Type"] = "application/xml" + signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) + assert_equal "PUT&http%3A%2F%2Fexample.com%2Ftest&oauth_body_hash%3DDvAa1AWdFoH9K%252B%252F2AHm3f6wH27k%253D%26oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string + end + + def test_that_put_bodies_not_signed_even_if_form_urlencoded + request = Net::HTTP::Put.new(@request_uri.path) + request.set_form_data( { 'key2' => 'value2' } ) + signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) + assert_equal "PUT&http%3A%2F%2Fexample.com%2Ftest&oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string + end + + def test_that_post_bodies_signed_if_form_urlencoded + request = Net::HTTP::Post.new(@request_uri.path) + request.set_form_data( { 'key2' => 'value2' } ) + signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) + assert_equal "POST&http%3A%2F%2Fexample.com%2Ftest&key2%3Dvalue2%26oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string + end + + def test_that_post_bodies_signed_if_other_content_type + request = Net::HTTP::Post.new(@request_uri.path) + request.body = "baz" + request["Content-Type"] = "application/xml" + signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp }) + assert_equal "POST&http%3A%2F%2Fexample.com%2Ftest&oauth_body_hash%3DDvAa1AWdFoH9K%252B%252F2AHm3f6wH27k%253D%26oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string + end + + def test_that_site_address_is_not_modified_in_place + options = { :site => 'http://twitter.com', :request_endpoint => 'http://api.twitter.com' } + request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s) + request.oauth!(@http, @consumer, @token, options) + assert_equal "http://twitter.com", options[:site] + assert_equal "http://api.twitter.com", options[:request_endpoint] + end + + protected + + def request_parameters_to_s + @request_parameters.map { |k,v| "#{k}=#{v}" }.join("&") + end + +end diff --git a/vendor/oauth-0.4.4/test/test_net_http_request_proxy.rb b/vendor/oauth-0.4.4/test/test_net_http_request_proxy.rb new file mode 100644 index 000000000..e847fe538 --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_net_http_request_proxy.rb @@ -0,0 +1,72 @@ +require File.expand_path('../test_helper', __FILE__) + +class NetHTTPRequestProxyTest < Test::Unit::TestCase + + def test_that_proxy_simple_get_request_works + request = Net::HTTP::Get.new('/test?key=value') + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'GET', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_arguments + request = Net::HTTP::Post.new('/test') + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_form_data + request = Net::HTTP::Post.new('/test') + params = {'key' => 'value'} + request.set_form_data(params) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_argugments + request = Net::HTTP::Put.new('/test') + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_form_data + request = Net::HTTP::Put.new('/test') + params = {'key' => 'value'} + request.set_form_data(params) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_post_request_uses_post_parameters + request = Net::HTTP::Post.new('/test?key=value') + request.set_form_data({'key2' => 'value2'}) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}}) + + expected_parameters = {'key' => ['value'], 'key2' => ['value2'], 'key3' => ['value3']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end + +end diff --git a/vendor/oauth-0.4.4/test/test_oauth_helper.rb b/vendor/oauth-0.4.4/test/test_oauth_helper.rb new file mode 100644 index 000000000..f4428b1c4 --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_oauth_helper.rb @@ -0,0 +1,71 @@ +require File.expand_path('../test_helper', __FILE__) + +class TestOAuthHelper < Test::Unit::TestCase + + def test_parse_valid_header + header = 'OAuth ' \ + 'realm="http://example.com/method", ' \ + 'oauth_consumer_key="vince_clortho", ' \ + 'oauth_token="token_value", ' \ + 'oauth_signature_method="HMAC-SHA1", ' \ + 'oauth_signature="signature_here", ' \ + 'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \ + 'oauth_version="1.0" ' + + params = OAuth::Helper.parse_header(header) + + assert_equal "http://example.com/method", params['realm'] + assert_equal "vince_clortho", params['oauth_consumer_key'] + assert_equal "token_value", params['oauth_token'] + assert_equal "HMAC-SHA1", params['oauth_signature_method'] + assert_equal "signature_here", params['oauth_signature'] + assert_equal "1240004133", params['oauth_timestamp'] + assert_equal "nonce", params['oauth_nonce'] + assert_equal "1.0", params['oauth_version'] + end + + def test_parse_header_ill_formed + header = "OAuth garbage" + + assert_raise OAuth::Problem do + OAuth::Helper.parse_header(header) + end + end + + def test_parse_header_contains_equals + header = 'OAuth ' \ + 'realm="http://example.com/method", ' \ + 'oauth_consumer_key="vince_clortho", ' \ + 'oauth_token="token_value", ' \ + 'oauth_signature_method="HMAC-SHA1", ' \ + 'oauth_signature="signature_here_with_=", ' \ + 'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \ + 'oauth_version="1.0" ' + + assert_raise OAuth::Problem do + OAuth::Helper.parse_header(header) + end + end + + def test_parse_valid_header_with_and_signs + header = 'OAuth ' \ + 'realm="http://example.com/method"&' \ + 'oauth_consumer_key="vince_clortho"&' \ + 'oauth_token="token_value"&' \ + 'oauth_signature_method="HMAC-SHA1"&' \ + 'oauth_signature="signature_here"&' \ + 'oauth_timestamp="1240004133"&oauth_nonce="nonce"&' \ + 'oauth_version="1.0"' + + params = OAuth::Helper.parse_header(header) + + assert_equal "http://example.com/method", params['realm'] + assert_equal "vince_clortho", params['oauth_consumer_key'] + assert_equal "token_value", params['oauth_token'] + assert_equal "HMAC-SHA1", params['oauth_signature_method'] + assert_equal "signature_here", params['oauth_signature'] + assert_equal "1240004133", params['oauth_timestamp'] + assert_equal "nonce", params['oauth_nonce'] + assert_equal "1.0", params['oauth_version'] + end +end diff --git a/vendor/oauth-0.3.2/test/test_rack_request_proxy.rb b/vendor/oauth-0.4.4/test/test_rack_request_proxy.rb similarity index 97% rename from vendor/oauth-0.3.2/test/test_rack_request_proxy.rb rename to vendor/oauth-0.4.4/test/test_rack_request_proxy.rb index 4d9fba9b1..8b22afce4 100644 --- a/vendor/oauth-0.3.2/test/test_rack_request_proxy.rb +++ b/vendor/oauth-0.4.4/test/test_rack_request_proxy.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' +require File.expand_path('../test_helper', __FILE__) require 'oauth/request_proxy/rack_request' require 'rack/request' require 'rack/mock' diff --git a/vendor/oauth-0.3.2/test/test_request_token.rb b/vendor/oauth-0.4.4/test/test_request_token.rb similarity index 94% rename from vendor/oauth-0.3.2/test/test_request_token.rb rename to vendor/oauth-0.4.4/test/test_request_token.rb index 4d485c445..632e927a4 100644 --- a/vendor/oauth-0.3.2/test/test_request_token.rb +++ b/vendor/oauth-0.4.4/test/test_request_token.rb @@ -1,6 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/token' -require 'oauth/consumer' +require File.expand_path('../test_helper', __FILE__) class StubbedToken < OAuth::RequestToken define_method :build_authorize_url_promoted do |root_domain, params| @@ -50,4 +48,4 @@ def test_build_authorize_url assert url assert_equal "http://github.com/oauth/authorize?foo=bar+bar", url end -end \ No newline at end of file +end diff --git a/vendor/oauth-0.3.2/test/test_rsa_sha1.rb b/vendor/oauth-0.4.4/test/test_rsa_sha1.rb similarity index 98% rename from vendor/oauth-0.3.2/test/test_rsa_sha1.rb rename to vendor/oauth-0.4.4/test/test_rsa_sha1.rb index 587da9c51..f0578693c 100644 --- a/vendor/oauth-0.3.2/test/test_rsa_sha1.rb +++ b/vendor/oauth-0.4.4/test/test_rsa_sha1.rb @@ -1,20 +1,20 @@ -require File.dirname(__FILE__) + '/test_helper.rb' +require File.expand_path('../test_helper', __FILE__) require 'oauth/consumer' require 'oauth/signature/rsa/sha1' class TestSignatureRsaSha1 < Test::Unit::TestCase - + def setup @request = Net::HTTP::Get.new('/photos?file=vacaction.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&oauth_signature_method=RSA-SHA1') @consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03', OpenSSL::PKey::RSA.new(IO.read(File.dirname(__FILE__) + "/keys/rsa.pem"))) - + end - + def test_that_rsa_sha1_implements_rsa_sha1 assert OAuth::Signature.available_methods.include?('rsa-sha1') end - + def test_that_get_request_from_oauth_test_cases_produces_matching_signature_base_string sbs = OAuth::Signature.signature_base_string(@request, { :consumer => @consumer, :uri => 'http://photos.example.net/photos' } ) @@ -27,7 +27,7 @@ def test_that_get_request_from_oauth_test_cases_produces_matching_signature :uri => 'http://photos.example.net/photos' } ) assert_equal 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=', signature - + end def test_that_get_request_from_oauth_test_cases_produces_matching_signature_using_private_key_file @@ -48,7 +48,7 @@ def test_that_get_request_from_oauth_test_cases_verifies_signature :uri => 'http://photos.example.net/photos' } ) end - + def test_that_get_request_from_oauth_test_cases_verifies_signature_with_pem @request = Net::HTTP::Get.new('/photos?oauth_signature_method=RSA-SHA1&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&file=vacaction.jpg&size=original&oauth_signature=jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D') assert OAuth::Signature.verify(@request, { :consumer => @consumer, diff --git a/vendor/oauth-0.3.2/test/test_server.rb b/vendor/oauth-0.4.4/test/test_server.rb similarity index 95% rename from vendor/oauth-0.3.2/test/test_server.rb rename to vendor/oauth-0.4.4/test/test_server.rb index a0aa9928b..15947c7dd 100644 --- a/vendor/oauth-0.3.2/test/test_server.rb +++ b/vendor/oauth-0.4.4/test/test_server.rb @@ -1,22 +1,22 @@ -require File.dirname(__FILE__) + '/test_helper' +require File.expand_path('../test_helper', __FILE__) require 'oauth/server' class ServerTest < Test::Unit::TestCase def setup @server=OAuth::Server.new "http://test.com" end - + def test_default_paths assert_equal "/oauth/request_token",@server.request_token_path assert_equal "/oauth/authorize",@server.authorize_path assert_equal "/oauth/access_token",@server.access_token_path end - + def test_default_urls assert_equal "http://test.com/oauth/request_token",@server.request_token_url assert_equal "http://test.com/oauth/authorize",@server.authorize_url assert_equal "http://test.com/oauth/access_token",@server.access_token_url end - + def test_generate_consumer_credentials consumer=@server.generate_consumer_credentials assert_not_nil consumer.key @@ -35,6 +35,6 @@ def test_create_consumer assert_equal "http://test.com/oauth/request_token",@consumer.request_token_url assert_equal "http://test.com/oauth/authorize",@consumer.authorize_url assert_equal "http://test.com/oauth/access_token",@consumer.access_token_url - end - + end + end diff --git a/vendor/oauth-0.4.4/test/test_signature.rb b/vendor/oauth-0.4.4/test/test_signature.rb new file mode 100644 index 000000000..4fb70416a --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_signature.rb @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- + +require File.expand_path('../test_helper', __FILE__) + +class TestOauth < Test::Unit::TestCase + + def test_parameter_escaping_kcode_invariant + ruby19 = RUBY_VERSION =~ /^1\.9/ + old = $KCODE if !ruby19 + begin + %w(n N e E s S u U).each do |kcode| + $KCODE = kcode if !ruby19 + assert_equal '%E3%81%82', OAuth::Helper.escape('あ'), + "Failed to correctly escape Japanese under $KCODE = #{kcode}" + assert_equal '%C3%A9', OAuth::Helper.escape('é'), + "Failed to correctly escape e+acute under $KCODE = #{kcode}" + end + ensure + $KCODE = old if !ruby19 + end + end +end diff --git a/vendor/oauth-0.3.2/test/test_signature_base.rb b/vendor/oauth-0.4.4/test/test_signature_base.rb similarity index 93% rename from vendor/oauth-0.3.2/test/test_signature_base.rb rename to vendor/oauth-0.4.4/test/test_signature_base.rb index bacdbad77..c31f60601 100644 --- a/vendor/oauth-0.3.2/test/test_signature_base.rb +++ b/vendor/oauth-0.4.4/test/test_signature_base.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' +require File.expand_path('../test_helper', __FILE__) require 'oauth/signature/base' require 'net/http' class SignatureBaseTest < Test::Unit::TestCase diff --git a/vendor/oauth-0.3.2/test/test_signature_plain_text.rb b/vendor/oauth-0.4.4/test/test_signature_plain_text.rb similarity index 96% rename from vendor/oauth-0.3.2/test/test_signature_plain_text.rb rename to vendor/oauth-0.4.4/test/test_signature_plain_text.rb index 8dacb33ae..eb644b17a 100644 --- a/vendor/oauth-0.3.2/test/test_signature_plain_text.rb +++ b/vendor/oauth-0.4.4/test/test_signature_plain_text.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/test_helper.rb' +require File.expand_path('../test_helper', __FILE__) require 'oauth/signature/plaintext' class TestSignaturePlaintext < Test::Unit::TestCase diff --git a/vendor/oauth-0.3.2/test/test_token.rb b/vendor/oauth-0.4.4/test/test_token.rb similarity index 79% rename from vendor/oauth-0.3.2/test/test_token.rb rename to vendor/oauth-0.4.4/test/test_token.rb index 7c1cb149c..d4f9a822d 100644 --- a/vendor/oauth-0.3.2/test/test_token.rb +++ b/vendor/oauth-0.4.4/test/test_token.rb @@ -1,14 +1,14 @@ -require File.dirname(__FILE__) + '/test_helper.rb' -require 'oauth/token' - -class TestToken < Test::Unit::TestCase - - def setup - end - - def test_token_constructor_produces_valid_token - token = OAuth::Token.new('xyz', '123') - assert_equal 'xyz', token.token - assert_equal '123', token.secret - end -end +require File.expand_path('../test_helper', __FILE__) +require 'oauth/token' + +class TestToken < Test::Unit::TestCase + + def setup + end + + def test_token_constructor_produces_valid_token + token = OAuth::Token.new('xyz', '123') + assert_equal 'xyz', token.token + assert_equal '123', token.secret + end +end diff --git a/vendor/oauth-0.4.4/test/test_typhoeus_request_proxy.rb b/vendor/oauth-0.4.4/test/test_typhoeus_request_proxy.rb new file mode 100644 index 000000000..c809a6f2d --- /dev/null +++ b/vendor/oauth-0.4.4/test/test_typhoeus_request_proxy.rb @@ -0,0 +1,81 @@ +require File.expand_path('../test_helper', __FILE__) + +begin + +require 'oauth/request_proxy/typhoeus_request' +require 'typhoeus' + +class TyphoeusRequestProxyTest < Test::Unit::TestCase + + def test_that_proxy_simple_get_request_works + request = ::Typhoeus::Request.new('/test?key=value') + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'}) + + expected_parameters = {'key' => ['value']} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'GET', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_arguments + request = Typhoeus::Request.new('/test', :method => :post) + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_post_request_works_with_form_data + request = Typhoeus::Request.new('/test', :method => :post, + :body => {'key' => 'value'}, + :headers => {'Content-Type' => 'application/x-www-form-urlencoded'}) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_arguments + request = Typhoeus::Request.new('/test', :method => :put) + params = {'key' => 'value'} + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params}) + + expected_parameters = {'key' => 'value'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_simple_put_request_works_with_form_data + request = Typhoeus::Request.new('/test', :method => :put, :body => {'key' => 'value'}) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'}) + + expected_parameters = {} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'PUT', request_proxy.method + end + + def test_that_proxy_post_request_works_with_mixed_parameter_sources + request = Typhoeus::Request.new('/test?key=value', + :method => :post, + :body => {'key2' => 'value2'}, + :headers => {'Content-Type' => 'application/x-www-form-urlencoded'}) + request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}}) + + expected_parameters = {'key' => ['value'], 'key2' => 'value2', 'key3' => 'value3'} + assert_equal expected_parameters, request_proxy.parameters_for_signature + assert_equal 'http://example.com/test', request_proxy.normalized_uri + assert_equal 'POST', request_proxy.method + end +end + +rescue LoadError => e + warn "! problem loading typhoeus, skipping these tests: #{e}" +end + diff --git a/vendor/yammer4r-0.1.5/lib/yammer4r.rb b/vendor/yammer4r-0.1.5/lib/yammer4r.rb index c00ed0ddf..0194f6cb4 100644 --- a/vendor/yammer4r-0.1.5/lib/yammer4r.rb +++ b/vendor/yammer4r-0.1.5/lib/yammer4r.rb @@ -3,14 +3,8 @@ require 'date' require 'yaml' require 'open-uri' - -gem 'json', '>= 1.1.7' require 'json' - -gem 'oauth', '>=0.3.5' require 'oauth' - -gem 'mash', '>=0.0.3' require 'mash' $:.unshift(File.dirname(__FILE__))