oauth-instructure 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +47 -0
- data/HISTORY +174 -0
- data/LICENSE +20 -0
- data/README.rdoc +75 -0
- data/Rakefile +37 -0
- data/TODO +32 -0
- data/bin/oauth +5 -0
- data/examples/yql.rb +44 -0
- data/lib/digest/hmac.rb +104 -0
- data/lib/oauth.rb +13 -0
- data/lib/oauth/cli.rb +378 -0
- data/lib/oauth/client.rb +4 -0
- data/lib/oauth/client/action_pack.rb +9 -0
- data/lib/oauth/client/em_http.rb +120 -0
- data/lib/oauth/client/helper.rb +91 -0
- data/lib/oauth/client/net_http.rb +120 -0
- data/lib/oauth/consumer.rb +389 -0
- data/lib/oauth/core_ext.rb +31 -0
- data/lib/oauth/errors.rb +3 -0
- data/lib/oauth/errors/error.rb +4 -0
- data/lib/oauth/errors/problem.rb +14 -0
- data/lib/oauth/errors/unauthorized.rb +12 -0
- data/lib/oauth/helper.rb +109 -0
- data/lib/oauth/oauth.rb +13 -0
- data/lib/oauth/oauth_test_helper.rb +25 -0
- data/lib/oauth/request_proxy.rb +24 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +116 -0
- data/lib/oauth/request_proxy/action_dispatch_request.rb +113 -0
- data/lib/oauth/request_proxy/base.rb +174 -0
- data/lib/oauth/request_proxy/curb_request.rb +55 -0
- data/lib/oauth/request_proxy/em_http_request.rb +66 -0
- data/lib/oauth/request_proxy/jabber_request.rb +41 -0
- data/lib/oauth/request_proxy/mock_request.rb +44 -0
- data/lib/oauth/request_proxy/net_http.rb +73 -0
- data/lib/oauth/request_proxy/rack_request.rb +44 -0
- data/lib/oauth/request_proxy/typhoeus_request.rb +53 -0
- data/lib/oauth/server.rb +66 -0
- data/lib/oauth/signature.rb +45 -0
- data/lib/oauth/signature/base.rb +110 -0
- data/lib/oauth/signature/hmac/base.rb +15 -0
- data/lib/oauth/signature/hmac/md5.rb +8 -0
- data/lib/oauth/signature/hmac/rmd160.rb +8 -0
- data/lib/oauth/signature/hmac/sha1.rb +9 -0
- data/lib/oauth/signature/hmac/sha2.rb +8 -0
- data/lib/oauth/signature/md5.rb +13 -0
- data/lib/oauth/signature/plaintext.rb +23 -0
- data/lib/oauth/signature/rsa/sha1.rb +46 -0
- data/lib/oauth/signature/sha1.rb +13 -0
- data/lib/oauth/token.rb +7 -0
- data/lib/oauth/tokens/access_token.rb +71 -0
- data/lib/oauth/tokens/consumer_token.rb +33 -0
- data/lib/oauth/tokens/request_token.rb +32 -0
- data/lib/oauth/tokens/server_token.rb +9 -0
- data/lib/oauth/tokens/token.rb +17 -0
- data/oauth.gemspec +148 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/cases/oauth_case.rb +19 -0
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +62 -0
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +88 -0
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +86 -0
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +77 -0
- data/test/integration/consumer_test.rb +307 -0
- data/test/keys/rsa.cert +11 -0
- data/test/keys/rsa.pem +16 -0
- data/test/test_access_token.rb +26 -0
- data/test/test_action_controller_request_proxy.rb +133 -0
- data/test/test_consumer.rb +220 -0
- data/test/test_curb_request_proxy.rb +77 -0
- data/test/test_em_http_client.rb +80 -0
- data/test/test_em_http_request_proxy.rb +115 -0
- data/test/test_helper.rb +28 -0
- data/test/test_hmac_sha1.rb +20 -0
- data/test/test_net_http_client.rb +292 -0
- data/test/test_net_http_request_proxy.rb +72 -0
- data/test/test_oauth_helper.rb +94 -0
- data/test/test_rack_request_proxy.rb +40 -0
- data/test/test_request_token.rb +51 -0
- data/test/test_rsa_sha1.rb +59 -0
- data/test/test_server.rb +40 -0
- data/test/test_signature.rb +22 -0
- data/test/test_signature_base.rb +32 -0
- data/test/test_signature_plain_text.rb +31 -0
- data/test/test_token.rb +14 -0
- data/test/test_typhoeus_request_proxy.rb +80 -0
- metadata +274 -0
data/lib/oauth/token.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module OAuth
|
2
|
+
# The Access Token is used for the actual "real" web service calls that you perform against the server
|
3
|
+
class AccessToken < ConsumerToken
|
4
|
+
# The less intrusive way. Otherwise, if we are to do it correctly inside consumer,
|
5
|
+
# we need to restructure and touch more methods: request(), sign!(), etc.
|
6
|
+
def request(http_method, path, *arguments)
|
7
|
+
request_uri = URI.parse(path)
|
8
|
+
site_uri = consumer.uri
|
9
|
+
is_service_uri_different = (request_uri.absolute? && request_uri != site_uri)
|
10
|
+
begin
|
11
|
+
consumer.uri(request_uri) if is_service_uri_different
|
12
|
+
@response = super(http_method, path, *arguments)
|
13
|
+
ensure
|
14
|
+
# NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
|
15
|
+
# so reset in case consumer is still used for other token-management tasks subsequently?
|
16
|
+
consumer.uri(site_uri) if is_service_uri_different
|
17
|
+
end
|
18
|
+
@response
|
19
|
+
end
|
20
|
+
|
21
|
+
# Make a regular GET request using AccessToken
|
22
|
+
#
|
23
|
+
# @response = @token.get('/people')
|
24
|
+
# @response = @token.get('/people', { 'Accept'=>'application/xml' })
|
25
|
+
#
|
26
|
+
def get(path, headers = {})
|
27
|
+
request(:get, path, headers)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Make a regular HEAD request using AccessToken
|
31
|
+
#
|
32
|
+
# @response = @token.head('/people')
|
33
|
+
#
|
34
|
+
def head(path, headers = {})
|
35
|
+
request(:head, path, headers)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Make a regular POST request using AccessToken
|
39
|
+
#
|
40
|
+
# @response = @token.post('/people')
|
41
|
+
# @response = @token.post('/people', { :name => 'Bob', :email => 'bob@mailinator.com' })
|
42
|
+
# @response = @token.post('/people', { :name => 'Bob', :email => 'bob@mailinator.com' }, { 'Accept' => 'application/xml' })
|
43
|
+
# @response = @token.post('/people', nil, {'Accept' => 'application/xml' })
|
44
|
+
# @response = @token.post('/people', @person.to_xml, { 'Accept'=>'application/xml', 'Content-Type' => 'application/xml' })
|
45
|
+
#
|
46
|
+
def post(path, body = '', headers = {})
|
47
|
+
request(:post, path, body, headers)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Make a regular PUT request using AccessToken
|
51
|
+
#
|
52
|
+
# @response = @token.put('/people/123')
|
53
|
+
# @response = @token.put('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' })
|
54
|
+
# @response = @token.put('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' }, { 'Accept' => 'application/xml' })
|
55
|
+
# @response = @token.put('/people/123', nil, { 'Accept' => 'application/xml' })
|
56
|
+
# @response = @token.put('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
|
57
|
+
#
|
58
|
+
def put(path, body = '', headers = {})
|
59
|
+
request(:put, path, body, headers)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Make a regular DELETE request using AccessToken
|
63
|
+
#
|
64
|
+
# @response = @token.delete('/people/123')
|
65
|
+
# @response = @token.delete('/people/123', { 'Accept' => 'application/xml' })
|
66
|
+
#
|
67
|
+
def delete(path, headers = {})
|
68
|
+
request(:delete, path, headers)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module OAuth
|
2
|
+
# Superclass for tokens used by OAuth Clients
|
3
|
+
class ConsumerToken < Token
|
4
|
+
attr_accessor :consumer, :params
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def self.from_hash(consumer, hash)
|
8
|
+
token = self.new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
|
9
|
+
token.params = hash
|
10
|
+
token
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(consumer, token="", secret="")
|
14
|
+
super(token, secret)
|
15
|
+
@consumer = consumer
|
16
|
+
@params = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Make a signed request using given http_method to the path
|
20
|
+
#
|
21
|
+
# @token.request(:get, '/people')
|
22
|
+
# @token.request(:post, '/people', @person.to_xml, { 'Content-Type' => 'application/xml' })
|
23
|
+
#
|
24
|
+
def request(http_method, path, *arguments)
|
25
|
+
@response = consumer.request(http_method, path, self, {}, *arguments)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Sign a request generated elsewhere using Net:HTTP::Post.new or friends
|
29
|
+
def sign!(request, options = {})
|
30
|
+
consumer.sign!(request, self, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OAuth
|
2
|
+
# The RequestToken is used for the initial Request.
|
3
|
+
# This is normally created by the Consumer object.
|
4
|
+
class RequestToken < ConsumerToken
|
5
|
+
|
6
|
+
# Generate an authorization URL for user authorization
|
7
|
+
def authorize_url(params = nil)
|
8
|
+
params = (params || {}).merge(:oauth_token => self.token)
|
9
|
+
build_authorize_url(consumer.authorize_url, params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def callback_confirmed?
|
13
|
+
params[:oauth_callback_confirmed] == "true"
|
14
|
+
end
|
15
|
+
|
16
|
+
# exchange for AccessToken on server
|
17
|
+
def get_access_token(options = {}, *arguments)
|
18
|
+
response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments)
|
19
|
+
OAuth::AccessToken.from_hash(consumer, response)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
# construct an authorization url
|
25
|
+
def build_authorize_url(base_url, params)
|
26
|
+
uri = URI.parse(base_url.to_s)
|
27
|
+
# TODO doesn't handle array values correctly
|
28
|
+
uri.query = params.map { |k,v| [k, CGI.escape(v)] * "=" } * "&"
|
29
|
+
uri.to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OAuth
|
2
|
+
# Superclass for the various tokens used by OAuth
|
3
|
+
class Token
|
4
|
+
include OAuth::Helper
|
5
|
+
|
6
|
+
attr_accessor :token, :secret
|
7
|
+
|
8
|
+
def initialize(token, secret)
|
9
|
+
@token = token
|
10
|
+
@secret = secret
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_query
|
14
|
+
"oauth_token=#{escape(token)}&oauth_secret=#{escape(secret)}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/oauth.gemspec
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
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 = "oauth-instructure"
|
8
|
+
s.version = "0.4.8"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
|
12
|
+
s.description = "OAuth Core Ruby implementation"
|
13
|
+
s.email = "oauth-ruby@googlegroups.com"
|
14
|
+
s.executables = ["oauth"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gemtest",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"HISTORY",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"TODO",
|
29
|
+
"bin/oauth",
|
30
|
+
"examples/yql.rb",
|
31
|
+
"lib/digest/hmac.rb",
|
32
|
+
"lib/oauth.rb",
|
33
|
+
"lib/oauth/cli.rb",
|
34
|
+
"lib/oauth/client.rb",
|
35
|
+
"lib/oauth/client/action_pack.rb",
|
36
|
+
"lib/oauth/client/em_http.rb",
|
37
|
+
"lib/oauth/client/helper.rb",
|
38
|
+
"lib/oauth/client/net_http.rb",
|
39
|
+
"lib/oauth/consumer.rb",
|
40
|
+
"lib/oauth/core_ext.rb",
|
41
|
+
"lib/oauth/errors.rb",
|
42
|
+
"lib/oauth/errors/error.rb",
|
43
|
+
"lib/oauth/errors/problem.rb",
|
44
|
+
"lib/oauth/errors/unauthorized.rb",
|
45
|
+
"lib/oauth/helper.rb",
|
46
|
+
"lib/oauth/oauth.rb",
|
47
|
+
"lib/oauth/oauth_test_helper.rb",
|
48
|
+
"lib/oauth/request_proxy.rb",
|
49
|
+
"lib/oauth/request_proxy/action_controller_request.rb",
|
50
|
+
"lib/oauth/request_proxy/action_dispatch_request.rb",
|
51
|
+
"lib/oauth/request_proxy/base.rb",
|
52
|
+
"lib/oauth/request_proxy/curb_request.rb",
|
53
|
+
"lib/oauth/request_proxy/em_http_request.rb",
|
54
|
+
"lib/oauth/request_proxy/jabber_request.rb",
|
55
|
+
"lib/oauth/request_proxy/mock_request.rb",
|
56
|
+
"lib/oauth/request_proxy/net_http.rb",
|
57
|
+
"lib/oauth/request_proxy/rack_request.rb",
|
58
|
+
"lib/oauth/request_proxy/typhoeus_request.rb",
|
59
|
+
"lib/oauth/server.rb",
|
60
|
+
"lib/oauth/signature.rb",
|
61
|
+
"lib/oauth/signature/base.rb",
|
62
|
+
"lib/oauth/signature/hmac/base.rb",
|
63
|
+
"lib/oauth/signature/hmac/md5.rb",
|
64
|
+
"lib/oauth/signature/hmac/rmd160.rb",
|
65
|
+
"lib/oauth/signature/hmac/sha1.rb",
|
66
|
+
"lib/oauth/signature/hmac/sha2.rb",
|
67
|
+
"lib/oauth/signature/md5.rb",
|
68
|
+
"lib/oauth/signature/plaintext.rb",
|
69
|
+
"lib/oauth/signature/rsa/sha1.rb",
|
70
|
+
"lib/oauth/signature/sha1.rb",
|
71
|
+
"lib/oauth/token.rb",
|
72
|
+
"lib/oauth/tokens/access_token.rb",
|
73
|
+
"lib/oauth/tokens/consumer_token.rb",
|
74
|
+
"lib/oauth/tokens/request_token.rb",
|
75
|
+
"lib/oauth/tokens/server_token.rb",
|
76
|
+
"lib/oauth/tokens/token.rb",
|
77
|
+
"oauth.gemspec",
|
78
|
+
"tasks/deployment.rake",
|
79
|
+
"tasks/environment.rake",
|
80
|
+
"tasks/website.rake",
|
81
|
+
"test/cases/oauth_case.rb",
|
82
|
+
"test/cases/spec/1_0-final/test_construct_request_url.rb",
|
83
|
+
"test/cases/spec/1_0-final/test_normalize_request_parameters.rb",
|
84
|
+
"test/cases/spec/1_0-final/test_parameter_encodings.rb",
|
85
|
+
"test/cases/spec/1_0-final/test_signature_base_strings.rb",
|
86
|
+
"test/integration/consumer_test.rb",
|
87
|
+
"test/keys/rsa.cert",
|
88
|
+
"test/keys/rsa.pem",
|
89
|
+
"test/test_access_token.rb",
|
90
|
+
"test/test_action_controller_request_proxy.rb",
|
91
|
+
"test/test_consumer.rb",
|
92
|
+
"test/test_curb_request_proxy.rb",
|
93
|
+
"test/test_em_http_client.rb",
|
94
|
+
"test/test_em_http_request_proxy.rb",
|
95
|
+
"test/test_helper.rb",
|
96
|
+
"test/test_hmac_sha1.rb",
|
97
|
+
"test/test_net_http_client.rb",
|
98
|
+
"test/test_net_http_request_proxy.rb",
|
99
|
+
"test/test_oauth_helper.rb",
|
100
|
+
"test/test_rack_request_proxy.rb",
|
101
|
+
"test/test_request_token.rb",
|
102
|
+
"test/test_rsa_sha1.rb",
|
103
|
+
"test/test_server.rb",
|
104
|
+
"test/test_signature.rb",
|
105
|
+
"test/test_signature_base.rb",
|
106
|
+
"test/test_signature_plain_text.rb",
|
107
|
+
"test/test_token.rb",
|
108
|
+
"test/test_typhoeus_request_proxy.rb"
|
109
|
+
]
|
110
|
+
s.require_paths = ["lib"]
|
111
|
+
s.rubyforge_project = "oauth"
|
112
|
+
s.rubygems_version = "1.8.23"
|
113
|
+
s.summary = "OAuth Core Ruby implementation"
|
114
|
+
|
115
|
+
if s.respond_to? :specification_version then
|
116
|
+
s.specification_version = 3
|
117
|
+
|
118
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
119
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
120
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
121
|
+
s.add_development_dependency(%q<actionpack>, [">= 2.3.5"])
|
122
|
+
s.add_development_dependency(%q<rack>, [">= 1.0.0"])
|
123
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
124
|
+
s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
|
125
|
+
s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
|
126
|
+
s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
|
127
|
+
else
|
128
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
129
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
130
|
+
s.add_dependency(%q<actionpack>, [">= 2.3.5"])
|
131
|
+
s.add_dependency(%q<rack>, [">= 1.0.0"])
|
132
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
133
|
+
s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
|
134
|
+
s.add_dependency(%q<em-http-request>, [">= 0.2.10"])
|
135
|
+
s.add_dependency(%q<curb>, [">= 0.6.6.0"])
|
136
|
+
end
|
137
|
+
else
|
138
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
139
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
140
|
+
s.add_dependency(%q<actionpack>, [">= 2.3.5"])
|
141
|
+
s.add_dependency(%q<rack>, [">= 1.0.0"])
|
142
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
143
|
+
s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
|
144
|
+
s.add_dependency(%q<em-http-request>, [">= 0.2.10"])
|
145
|
+
s.add_dependency(%q<curb>, [">= 0.6.6.0"])
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'oauth/signature'
|
3
|
+
require 'oauth/request_proxy/mock_request'
|
4
|
+
|
5
|
+
|
6
|
+
class OAuthCase < Test::Unit::TestCase
|
7
|
+
# avoid whining about a lack of tests
|
8
|
+
def run(*args)
|
9
|
+
return if @method_name.to_s == "default_test"
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
# Creates a fake request
|
16
|
+
def request(params={},method='GET',uri="http://photos.example.net/photos")
|
17
|
+
OAuth::RequestProxy.proxy({'parameters'=>params,'method'=>method,'uri'=>uri})
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path('../../../oauth_case', __FILE__)
|
2
|
+
|
3
|
+
# See http://oauth.net/core/1.0/#anchor14
|
4
|
+
#
|
5
|
+
#9.1.2. Construct Request URL
|
6
|
+
#
|
7
|
+
#The Signature Base String includes the request absolute URL, tying the signature to a specific endpoint. The URL used in the Signature Base String MUST include the scheme, authority, and path, and MUST exclude the query and fragment as defined by [RFC3986] section 3.
|
8
|
+
#
|
9
|
+
#If the absolute request URL is not available to the Service Provider (it is always available to the Consumer), it can be constructed by combining the scheme being used, the HTTP Host header, and the relative HTTP request URL. If the Host header is not available, the Service Provider SHOULD use the host name communicated to the Consumer in the documentation or other means.
|
10
|
+
#
|
11
|
+
#The Service Provider SHOULD document the form of URL used in the Signature Base String to avoid ambiguity due to URL normalization. Unless specified, URL scheme and authority MUST be lowercase and include the port number; http default port 80 and https default port 443 MUST be excluded.
|
12
|
+
#
|
13
|
+
#For example, the request:
|
14
|
+
#
|
15
|
+
# HTTP://Example.com:80/resource?id=123
|
16
|
+
#Is included in the Signature Base String as:
|
17
|
+
#
|
18
|
+
# http://example.com/resource
|
19
|
+
|
20
|
+
|
21
|
+
class ConstructRequestUrlTest < OAuthCase
|
22
|
+
|
23
|
+
def test_from_spec
|
24
|
+
assert_request_url("http://example.com/resource","HTTP://Example.com:80/resource?id=123")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_simple_url_with_ending_slash
|
28
|
+
assert_request_url("http://example.com/","http://example.com/")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_simple_url_without_ending_slash
|
32
|
+
assert_request_url("http://example.com/","http://example.com")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_of_normalized_http
|
36
|
+
assert_request_url("http://example.com/resource","http://example.com/resource")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_of_https
|
40
|
+
assert_request_url("https://example.com/resource","HTTPS://Example.com:443/resource?id=123")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_of_normalized_https
|
44
|
+
assert_request_url("https://example.com/resource","https://example.com/resource")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_of_http_with_non_standard_port
|
48
|
+
assert_request_url("http://example.com:8080/resource","http://example.com:8080/resource")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_of_https_with_non_standard_port
|
52
|
+
assert_request_url("https://example.com:8080/resource","https://example.com:8080/resource")
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
|
58
|
+
def assert_request_url(expected,given,message=nil)
|
59
|
+
assert_equal expected, request({},'GET',given).normalized_uri, message
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|