alanho-typhoeus_oauth 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +8 -3
- data/Rakefile +6 -2
- data/lib/typhoeus_oauth.rb +11 -0
- data/spec/typhoeus_oauth_spec.rb +42 -2
- data/typhoeus_oauth.gemspec +66 -0
- metadata +2 -1
data/README.rdoc
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
= typhoeus_oauth
|
2
2
|
|
3
|
-
|
3
|
+
Enabling OAuth on Typhoeus.
|
4
|
+
|
5
|
+
== Exmaples
|
6
|
+
|
7
|
+
|
8
|
+
== Notes
|
9
|
+
This is my first gem and this is VERY experimental.
|
4
10
|
|
5
11
|
== Note on Patches/Pull Requests
|
6
12
|
|
@@ -9,8 +15,7 @@ Description goes here.
|
|
9
15
|
* Add tests for it. This is important so I don't break it in a
|
10
16
|
future version unintentionally.
|
11
17
|
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but
|
13
|
-
bump version in a commit by itself I can ignore when I pull)
|
18
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
14
19
|
* Send me a pull request. Bonus points for topic branches.
|
15
20
|
|
16
21
|
== Copyright
|
data/Rakefile
CHANGED
@@ -5,12 +5,16 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "typhoeus_oauth"
|
8
|
-
gem.summary = %Q{
|
9
|
-
gem.description = %Q{
|
8
|
+
gem.summary = %Q{Bridging OAuth and Typhoeus}
|
9
|
+
gem.description = %Q{Bridging OAuth and Typhoeus}
|
10
10
|
gem.email = "alanho@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/alanho/typhoeus_oauth"
|
12
12
|
gem.authors = ["Alan Ho"]
|
13
13
|
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_dependency('oauth', '>= 0.3.5')
|
15
|
+
gem.add_dependency('pauldix-typhoeus', '>= 0.0.24')
|
16
|
+
gem.files.include FileList['lib/**/*.rb']
|
17
|
+
# gem.files = FileList['lib/**/*.rb'].join(",")
|
14
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
19
|
end
|
16
20
|
rescue LoadError
|
data/lib/typhoeus_oauth.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "oauth"
|
5
|
+
require "typhoeus"
|
6
|
+
require "typhoeus_oauth/oauth_extension"
|
7
|
+
require "typhoeus_oauth/module_extension"
|
8
|
+
require "oauth/request_proxy/typhoeus_request"
|
9
|
+
|
10
|
+
Typhoeus::Easy.send :include, TyphoeusOAuth::OAuthExtension
|
11
|
+
Typhoeus::ClassMethods.send :include, TyphoeusOAuth::ModuleExtension
|
data/spec/typhoeus_oauth_spec.rb
CHANGED
@@ -1,7 +1,47 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
+
require "typhoeus"
|
4
|
+
require "lib/typhoeus_oauth"
|
5
|
+
|
3
6
|
describe "TyphoeusOauth" do
|
4
|
-
|
5
|
-
|
7
|
+
consumer = OAuth::Consumer.new("key","secret",{ :site=>"http://term.ie" })
|
8
|
+
access = OAuth::AccessToken.new(consumer, "accesskey", "accesssecret")
|
9
|
+
|
10
|
+
it "should generate the same signature_base_string as Net/HTTP request" do
|
11
|
+
key = (0...8).map{65.+(rand(25)).chr}.join
|
12
|
+
value = (0...8).map{65.+(rand(25)).chr}.join
|
13
|
+
query_string = "#{key}=#{value}"
|
14
|
+
|
15
|
+
easy = Typhoeus.get_easy_object
|
16
|
+
easy.url = "http://term.ie/oauth/example/echo_api.php?#{query_string}"
|
17
|
+
easy.method = :get
|
18
|
+
|
19
|
+
easy_base_string = easy.signature_base_string(consumer, access, {:nonce => "4572616e48616d6d65724c61686176", :timestamp => 137131200})
|
20
|
+
|
21
|
+
http = Net::HTTP.new("term.ie", 80)
|
22
|
+
request = Net::HTTP::Get.new("/oauth/example/echo_api.php?#{query_string}")
|
23
|
+
http_base_string = request.signature_base_string(http, consumer, access, {:nonce => "4572616e48616d6d65724c61686176", :timestamp => 137131200})
|
24
|
+
|
25
|
+
http_base_string.should == easy_base_string
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should behave like a net/http request using header authentication" do
|
29
|
+
key = (0...8).map{65.+(rand(25)).chr}.join
|
30
|
+
value = (0...8).map{65.+(rand(25)).chr}.join
|
31
|
+
query_string = "#{key}=#{value}"
|
32
|
+
|
33
|
+
easy = Typhoeus.get_easy_object
|
34
|
+
easy.url = "http://term.ie/oauth/example/echo_api.php?#{query_string}"
|
35
|
+
easy.method = :get
|
36
|
+
easy.oauth!(consumer, access)
|
37
|
+
easy.set_headers
|
38
|
+
easy.perform
|
39
|
+
easy.response_body
|
40
|
+
|
41
|
+
http = Net::HTTP.new("term.ie", 80)
|
42
|
+
request = Net::HTTP::Get.new("/oauth/example/echo_api.php?#{query_string}")
|
43
|
+
consumer.sign!(request, access)
|
44
|
+
res = http.request(request)
|
45
|
+
res.body.should == easy.response_body
|
6
46
|
end
|
7
47
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{typhoeus_oauth}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alan Ho"]
|
12
|
+
s.date = %q{2009-09-07}
|
13
|
+
s.description = %q{Bridging OAuth and Typhoeus}
|
14
|
+
s.email = %q{alanho@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/oauth/request_proxy/typhoeus_request.rb",
|
27
|
+
"lib/oauth/request_proxy/typhoeus_request.rb",
|
28
|
+
"lib/typhoeus_oauth.rb",
|
29
|
+
"lib/typhoeus_oauth.rb",
|
30
|
+
"lib/typhoeus_oauth/module_extension.rb",
|
31
|
+
"lib/typhoeus_oauth/module_extension.rb",
|
32
|
+
"lib/typhoeus_oauth/oauth_extension.rb",
|
33
|
+
"lib/typhoeus_oauth/oauth_extension.rb",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"spec/typhoeus_oauth_spec.rb",
|
36
|
+
"typhoeus_oauth.gemspec"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/alanho/typhoeus_oauth}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.5}
|
42
|
+
s.summary = %q{Bridging OAuth and Typhoeus}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/spec_helper.rb",
|
45
|
+
"spec/typhoeus_oauth_spec.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
54
|
+
s.add_runtime_dependency(%q<oauth>, [">= 0.3.5"])
|
55
|
+
s.add_runtime_dependency(%q<pauldix-typhoeus>, [">= 0.0.24"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_dependency(%q<oauth>, [">= 0.3.5"])
|
59
|
+
s.add_dependency(%q<pauldix-typhoeus>, [">= 0.0.24"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_dependency(%q<oauth>, [">= 0.3.5"])
|
64
|
+
s.add_dependency(%q<pauldix-typhoeus>, [">= 0.0.24"])
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alanho-typhoeus_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Ho
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/typhoeus_oauth/oauth_extension.rb
|
65
65
|
- spec/spec_helper.rb
|
66
66
|
- spec/typhoeus_oauth_spec.rb
|
67
|
+
- typhoeus_oauth.gemspec
|
67
68
|
has_rdoc: false
|
68
69
|
homepage: http://github.com/alanho/typhoeus_oauth
|
69
70
|
post_install_message:
|