Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
fix em_http_client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mojodna committed Feb 6, 2010
1 parent aa35512 commit ffaced9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/oauth/client/em_http.rb
Expand Up @@ -33,7 +33,12 @@ def oauth!(http, consumer = nil, token = nil, options = {})
:timestamp => nil }.merge(options)

@oauth_helper = OAuth::Client::Helper.new(self, options)
self.send("set_oauth_#{options[:scheme]}")

# TODO this isn't executing properly, so it's currently hard-coded to the
# only supported scheme
# self.send("set_oauth_#{options[:scheme]}")

set_oauth_header
end

# Create a string suitable for signing for an HTTP request. This process involves parameter
Expand Down Expand Up @@ -91,4 +96,4 @@ def set_oauth_query_string
raise NotImplementedError, 'please use the set_oauth_header method instead'
end

end
end
8 changes: 4 additions & 4 deletions test/test_em_http_client.rb
Expand Up @@ -21,7 +21,7 @@ def test_that_using_auth_headers_on_get_requests_works
assert_equal 'GET', request.method
assert_equal '/test', request.normalize_uri.path
assert_equal "key=value", request.normalize_uri.query
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, authz_header(request).split(', ').sort
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\""[6..-1].split(', ').sort, authz_header(request)[6..-1].split(', ').sort
end

def test_that_using_auth_headers_on_get_requests_works_with_plaintext
Expand All @@ -35,7 +35,7 @@ def test_that_using_auth_headers_on_get_requests_works_with_plaintext
assert_equal 'GET', request.method
assert_equal '/test', request.normalize_uri.path
assert_equal "key=value", request.normalize_uri.query
assert_equal "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\"".split(', ').sort, authz_header(request).split(', ').sort
assert_equal "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\""[6..-1].split(', ').sort, authz_header(request)[6..-1].split(', ').sort
end

def test_that_using_auth_headers_on_post_requests_works
Expand All @@ -45,7 +45,7 @@ def test_that_using_auth_headers_on_post_requests_works
assert_equal 'POST', request.method
assert_equal '/test', request.uri.path
assert_equal 'key=value', request.normalize_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, authz_header(request).split(', ').sort
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\""[6..-1].split(', ').sort, authz_header(request)[6..-1].split(', ').sort
end

protected
Expand All @@ -65,4 +65,4 @@ def authz_header(request)
headers['Authorization']
end

end
end

0 comments on commit ffaced9

Please sign in to comment.