monkeyhelper-oauth 0.3.1 → 0.3.5
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/History.txt +62 -17
- data/Manifest.txt +14 -1
- data/README.rdoc +7 -9
- data/Rakefile +7 -5
- data/TODO +17 -0
- data/bin/oauth +2 -2
- data/examples/yql.rb +44 -0
- data/lib/oauth/cli.rb +267 -31
- data/lib/oauth/client/action_controller_request.rb +14 -12
- data/lib/oauth/client/helper.rb +22 -14
- data/lib/oauth/client/net_http.rb +53 -22
- data/lib/oauth/consumer.rb +217 -111
- 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/errors.rb +3 -0
- data/lib/oauth/helper.rb +67 -6
- data/lib/oauth/oauth.rb +11 -0
- data/lib/oauth/oauth_test_helper.rb +12 -13
- data/lib/oauth/request_proxy/action_controller_request.rb +8 -8
- data/lib/oauth/request_proxy/base.rb +102 -44
- data/lib/oauth/request_proxy/jabber_request.rb +1 -2
- data/lib/oauth/request_proxy/mock_request.rb +8 -0
- data/lib/oauth/request_proxy/net_http.rb +2 -2
- data/lib/oauth/request_proxy/rack_request.rb +7 -7
- data/lib/oauth/server.rb +31 -33
- data/lib/oauth/signature/base.rb +23 -21
- data/lib/oauth/signature/hmac/base.rb +1 -1
- data/lib/oauth/signature/hmac/sha1.rb +0 -1
- data/lib/oauth/signature/plaintext.rb +2 -2
- data/lib/oauth/signature/rsa/sha1.rb +5 -4
- data/lib/oauth/signature.rb +9 -0
- data/lib/oauth/token.rb +6 -136
- data/lib/oauth/tokens/access_token.rb +68 -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/lib/oauth/version.rb +1 -1
- data/lib/oauth.rb +1 -0
- data/oauth.gemspec +12 -6
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +1 -1
- data/test/test_access_token.rb +28 -0
- data/test/test_action_controller_request_proxy.rb +105 -6
- data/test/test_consumer.rb +41 -5
- data/test/test_helper.rb +0 -5
- data/test/test_net_http_client.rb +38 -20
- data/test/test_net_http_request_proxy.rb +43 -8
- data/test/test_oauth_helper.rb +50 -0
- data/test/test_request_token.rb +53 -0
- data/test/test_server.rb +1 -1
- data/test/test_signature.rb +19 -11
- data/website/index.html +2 -2
- metadata +41 -3
| @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            require File.dirname(__FILE__) + '/test_helper.rb'
         | 
| 2 2 | 
             
            require 'oauth/client/net_http'
         | 
| 3 | 
            +
            require 'oauth/version'
         | 
| 3 4 |  | 
| 4 5 | 
             
            class NetHTTPClientTest < Test::Unit::TestCase
         | 
| 5 6 |  | 
| @@ -16,7 +17,7 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 16 17 | 
             
              def test_that_using_auth_headers_on_get_requests_works
         | 
| 17 18 | 
             
                request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s)
         | 
| 18 19 | 
             
                request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
         | 
| 19 | 
            -
             | 
| 20 | 
            +
             | 
| 20 21 | 
             
                assert_equal 'GET', request.method
         | 
| 21 22 | 
             
                assert_equal '/test?key=value', request.path
         | 
| 22 23 | 
             
                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
         | 
| @@ -32,16 +33,22 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 32 33 | 
             
                assert_equal 'key=value', request.body
         | 
| 33 34 | 
             
                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
         | 
| 34 35 | 
             
              end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
              def  | 
| 36 | 
            +
             | 
| 37 | 
            +
              def test_that_version_is_added_to_existing_user_agent
         | 
| 37 38 | 
             
                request = Net::HTTP::Post.new(@request_uri.path)
         | 
| 39 | 
            +
                request['User-Agent'] = "MyApp"
         | 
| 38 40 | 
             
                request.set_form_data( @request_parameters )
         | 
| 39 | 
            -
                request.oauth!(@http, @consumer, @token, {: | 
| 41 | 
            +
                request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
         | 
| 40 42 |  | 
| 41 | 
            -
                assert_equal  | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 43 | 
            +
                assert_equal "MyApp (OAuth gem v#{OAuth::VERSION})", request['User-Agent']
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def test_that_version_is_set_when_no_user_agent
         | 
| 47 | 
            +
                request = Net::HTTP::Post.new(@request_uri.path)
         | 
| 48 | 
            +
                request.set_form_data( @request_parameters )
         | 
| 49 | 
            +
                request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                assert_equal "OAuth gem v#{OAuth::VERSION}", request['User-Agent']
         | 
| 45 52 | 
             
              end
         | 
| 46 53 |  | 
| 47 54 | 
             
              def test_that_using_get_params_works
         | 
| @@ -56,7 +63,18 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 56 63 | 
             
                assert_equal nil, request['authorization']
         | 
| 57 64 | 
             
              end
         | 
| 58 65 |  | 
| 59 | 
            -
              def  | 
| 66 | 
            +
              def test_that_using_post_params_works
         | 
| 67 | 
            +
                request = Net::HTTP::Post.new(@request_uri.path)
         | 
| 68 | 
            +
                request.set_form_data( @request_parameters )
         | 
| 69 | 
            +
                request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp})
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                assert_equal 'POST', request.method
         | 
| 72 | 
            +
                assert_equal '/test', request.path
         | 
| 73 | 
            +
                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("&")
         | 
| 74 | 
            +
                assert_equal nil, request['authorization']
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              def test_that_using_post_with_uri_params_works
         | 
| 60 78 | 
             
                request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
         | 
| 61 79 | 
             
                request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp})
         | 
| 62 80 |  | 
| @@ -69,7 +87,7 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 69 87 | 
             
                assert_equal nil, request['authorization']
         | 
| 70 88 | 
             
              end
         | 
| 71 89 |  | 
| 72 | 
            -
              def  | 
| 90 | 
            +
              def test_that_using_post_with_uri_and_form_params_works
         | 
| 73 91 | 
             
                request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
         | 
| 74 92 | 
             
                request.set_form_data( { 'key2' => 'value2' } )
         | 
| 75 93 | 
             
                request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp})
         | 
| @@ -82,8 +100,8 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 82 100 | 
             
                assert_equal "key2=value2", request.body
         | 
| 83 101 | 
             
                assert_equal nil, request['authorization']
         | 
| 84 102 | 
             
              end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 103 | 
            +
             | 
| 104 | 
            +
             | 
| 87 105 | 
             
              def test_example_from_specs
         | 
| 88 106 | 
             
                consumer=OAuth::Consumer.new("dpf43f3p2l4k3l03","kd94hf93k423kf44")
         | 
| 89 107 | 
             
                token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
         | 
| @@ -101,22 +119,22 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 101 119 |  | 
| 102 120 | 
             
                assert_equal 'GET', request.method
         | 
| 103 121 | 
             
                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
         | 
| 104 | 
            -
             | 
| 122 | 
            +
             | 
| 105 123 | 
             
              end
         | 
| 106 | 
            -
             | 
| 124 | 
            +
             | 
| 107 125 | 
             
              def test_step_by_step_token_request
         | 
| 108 | 
            -
                consumer=OAuth::Consumer.new( | 
| 126 | 
            +
                consumer=OAuth::Consumer.new(
         | 
| 109 127 | 
             
                    "key",
         | 
| 110 128 | 
             
                    "secret")
         | 
| 111 129 | 
             
                request_uri = URI.parse('http://term.ie/oauth/example/request_token.php')
         | 
| 112 130 | 
             
                nonce = rand(2**128).to_s
         | 
| 113 131 | 
             
                timestamp = Time.now.to_i.to_s
         | 
| 114 132 | 
             
                http = Net::HTTP.new(request_uri.host, request_uri.port)
         | 
| 115 | 
            -
             | 
| 133 | 
            +
             | 
| 116 134 | 
             
                request = Net::HTTP::Get.new(request_uri.path)
         | 
| 117 135 | 
             
                signature_base_string=request.signature_base_string(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
         | 
| 118 136 | 
             
                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
         | 
| 119 | 
            -
             | 
| 137 | 
            +
             | 
| 120 138 | 
             
            #    request = Net::HTTP::Get.new(request_uri.path)
         | 
| 121 139 | 
             
                request.oauth!(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
         | 
| 122 140 | 
             
                assert_equal 'GET', request.method
         | 
| @@ -129,7 +147,7 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 129 147 | 
             
            #    assert_equal request['authorization'],response.body
         | 
| 130 148 | 
             
                assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body
         | 
| 131 149 | 
             
              end
         | 
| 132 | 
            -
             | 
| 150 | 
            +
             | 
| 133 151 | 
             
              def test_that_put_bodies_not_signed
         | 
| 134 152 | 
             
                request = Net::HTTP::Put.new(@request_uri.path)
         | 
| 135 153 | 
             
                request.body = "<?xml version=\"1.0\"?><foo><bar>baz</bar></foo>"
         | 
| @@ -144,14 +162,14 @@ class NetHTTPClientTest < Test::Unit::TestCase | |
| 144 162 | 
             
                signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp })
         | 
| 145 163 | 
             
                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
         | 
| 146 164 | 
             
              end
         | 
| 147 | 
            -
             | 
| 165 | 
            +
             | 
| 148 166 | 
             
              def test_that_post_bodies_signed_if_form_urlencoded
         | 
| 149 167 | 
             
                request = Net::HTTP::Post.new(@request_uri.path)
         | 
| 150 168 | 
             
                request.set_form_data( { 'key2' => 'value2' } )
         | 
| 151 169 | 
             
                signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp })
         | 
| 152 170 | 
             
                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
         | 
| 153 171 | 
             
              end
         | 
| 154 | 
            -
             | 
| 172 | 
            +
             | 
| 155 173 | 
             
              def test_that_post_bodies_not_signed_if_other_content_type
         | 
| 156 174 | 
             
                request = Net::HTTP::Post.new(@request_uri.path)
         | 
| 157 175 | 
             
                request.body = "<?xml version=\"1.0\"?><foo><bar>baz</bar></foo>"
         | 
| @@ -8,29 +8,64 @@ class NetHTTPRequestProxyTest < Test::Unit::TestCase | |
| 8 8 | 
             
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
         | 
| 9 9 |  | 
| 10 10 | 
             
                expected_parameters = {'key' => ['value']}
         | 
| 11 | 
            -
                assert_equal expected_parameters, request_proxy. | 
| 11 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 12 12 | 
             
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 13 13 | 
             
                assert_equal 'GET', request_proxy.method
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 | 
            -
              def  | 
| 16 | 
            +
              def test_that_proxy_simple_post_request_works_with_arguments
         | 
| 17 17 | 
             
                request = Net::HTTP::Post.new('/test')
         | 
| 18 18 | 
             
                params = {'key' => 'value'}
         | 
| 19 19 | 
             
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
         | 
| 20 20 |  | 
| 21 21 | 
             
                expected_parameters = {'key' => ['value']}
         | 
| 22 | 
            -
                assert_equal expected_parameters, request_proxy. | 
| 22 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 23 23 | 
             
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 24 24 | 
             
                assert_equal 'POST', request_proxy.method
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
              def  | 
| 27 | 
            +
              def test_that_proxy_simple_post_request_works_with_form_data
         | 
| 28 | 
            +
                request = Net::HTTP::Post.new('/test')
         | 
| 29 | 
            +
                params = {'key' => 'value'}
         | 
| 30 | 
            +
                request.set_form_data(params)
         | 
| 31 | 
            +
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                expected_parameters = {'key' => ['value']}
         | 
| 34 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 35 | 
            +
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 36 | 
            +
                assert_equal 'POST', request_proxy.method
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def test_that_proxy_simple_put_request_works_with_argugments
         | 
| 40 | 
            +
                request = Net::HTTP::Put.new('/test')
         | 
| 41 | 
            +
                params = {'key' => 'value'}
         | 
| 42 | 
            +
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                expected_parameters = {'key' => ['value']}
         | 
| 45 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 46 | 
            +
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 47 | 
            +
                assert_equal 'PUT', request_proxy.method
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              def test_that_proxy_simple_put_request_works_with_form_data
         | 
| 51 | 
            +
                request = Net::HTTP::Put.new('/test')
         | 
| 52 | 
            +
                params = {'key' => 'value'}
         | 
| 53 | 
            +
                request.set_form_data(params)
         | 
| 54 | 
            +
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                expected_parameters = {}
         | 
| 57 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 58 | 
            +
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 59 | 
            +
                assert_equal 'PUT', request_proxy.method
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              def test_that_proxy_post_request_works_with_mixed_parameter_sources
         | 
| 28 63 | 
             
                request = Net::HTTP::Post.new('/test?key=value')
         | 
| 29 | 
            -
                 | 
| 30 | 
            -
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters =>  | 
| 64 | 
            +
                request.set_form_data({'key2' => 'value2'})
         | 
| 65 | 
            +
                request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
         | 
| 31 66 |  | 
| 32 | 
            -
                expected_parameters = {'key' => ['value'], 'key2' => ['value2']}
         | 
| 33 | 
            -
                assert_equal expected_parameters, request_proxy. | 
| 67 | 
            +
                expected_parameters = {'key' => ['value'], 'key2' => ['value2'], 'key3' => ['value3']}
         | 
| 68 | 
            +
                assert_equal expected_parameters, request_proxy.parameters_for_signature
         | 
| 34 69 | 
             
                assert_equal 'http://example.com/test', request_proxy.normalized_uri
         | 
| 35 70 | 
             
                assert_equal 'POST', request_proxy.method
         | 
| 36 71 | 
             
              end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/test_helper.rb'
         | 
| 2 | 
            +
            require 'oauth/helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class TestOAuthHelper < Test::Unit::TestCase
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def test_parse_valid_header
         | 
| 7 | 
            +
                header = 'OAuth ' \
         | 
| 8 | 
            +
                         'realm="http://example.com/method", ' \
         | 
| 9 | 
            +
                         'oauth_consumer_key="vince_clortho", ' \
         | 
| 10 | 
            +
                         'oauth_token="token_value", ' \
         | 
| 11 | 
            +
                         'oauth_signature_method="HMAC-SHA1", ' \
         | 
| 12 | 
            +
                         'oauth_signature="signature_here", ' \
         | 
| 13 | 
            +
                         'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \
         | 
| 14 | 
            +
                         'oauth_version="1.0" '
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                params = OAuth::Helper.parse_header(header)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                assert_equal "http://example.com/method", params['realm']
         | 
| 19 | 
            +
                assert_equal "vince_clortho", params['oauth_consumer_key']
         | 
| 20 | 
            +
                assert_equal "token_value", params['oauth_token']
         | 
| 21 | 
            +
                assert_equal "HMAC-SHA1", params['oauth_signature_method']
         | 
| 22 | 
            +
                assert_equal "signature_here", params['oauth_signature']
         | 
| 23 | 
            +
                assert_equal "1240004133", params['oauth_timestamp']
         | 
| 24 | 
            +
                assert_equal "nonce", params['oauth_nonce']
         | 
| 25 | 
            +
                assert_equal "1.0", params['oauth_version']
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def test_parse_header_ill_formed
         | 
| 29 | 
            +
                header = "OAuth garbage"
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                assert_raise OAuth::Problem do
         | 
| 32 | 
            +
                  OAuth::Helper.parse_header(header)
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              def test_parse_header_contains_equals
         | 
| 37 | 
            +
                header = 'OAuth ' \
         | 
| 38 | 
            +
                         'realm="http://example.com/method", ' \
         | 
| 39 | 
            +
                         'oauth_consumer_key="vince_clortho", ' \
         | 
| 40 | 
            +
                         'oauth_token="token_value", ' \
         | 
| 41 | 
            +
                         'oauth_signature_method="HMAC-SHA1", ' \
         | 
| 42 | 
            +
                         'oauth_signature="signature_here_with_=", ' \
         | 
| 43 | 
            +
                         'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \
         | 
| 44 | 
            +
                         'oauth_version="1.0" '
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                assert_raise OAuth::Problem do
         | 
| 47 | 
            +
                  OAuth::Helper.parse_header(header)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/test_helper.rb'
         | 
| 2 | 
            +
            require 'oauth/token'
         | 
| 3 | 
            +
            require 'oauth/consumer'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class StubbedToken < OAuth::RequestToken
         | 
| 6 | 
            +
              define_method :build_authorize_url_promoted do |root_domain, params|
         | 
| 7 | 
            +
                build_authorize_url root_domain, params
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            class TestRequestToken < Test::Unit::TestCase
         | 
| 12 | 
            +
              def setup
         | 
| 13 | 
            +
                # setup a fake req. token. mocking Consumer would be more appropriate...
         | 
| 14 | 
            +
                @request_token = OAuth::RequestToken.new(
         | 
| 15 | 
            +
                  OAuth::Consumer.new("key", "secret", {}),
         | 
| 16 | 
            +
                  "key",
         | 
| 17 | 
            +
                  "secret"
         | 
| 18 | 
            +
                )
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def test_request_token_builds_authorize_url_connectly_with_additional_params
         | 
| 22 | 
            +
                auth_url = @request_token.authorize_url({:oauth_callback => "github.com"})
         | 
| 23 | 
            +
                assert_not_nil auth_url
         | 
| 24 | 
            +
                assert_match(/oauth_token/, auth_url)
         | 
| 25 | 
            +
                assert_match(/oauth_callback/, auth_url)
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def test_request_token_builds_authorize_url_connectly_with_no_or_nil_params
         | 
| 29 | 
            +
                # we should only have 1 key in the url returned if we didn't pass anything.
         | 
| 30 | 
            +
                # this is the only required param to authenticate the client.
         | 
| 31 | 
            +
                auth_url = @request_token.authorize_url(nil)
         | 
| 32 | 
            +
                assert_not_nil auth_url
         | 
| 33 | 
            +
                assert_match(/\?oauth_token=/, auth_url)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                auth_url = @request_token.authorize_url
         | 
| 36 | 
            +
                assert_not_nil auth_url
         | 
| 37 | 
            +
                assert_match(/\?oauth_token=/, auth_url)
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              #TODO: mock out the Consumer to test the Consumer/AccessToken interaction.
         | 
| 41 | 
            +
              def test_get_access_token
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def test_build_authorize_url
         | 
| 45 | 
            +
               @stubbed_token = StubbedToken.new(nil, nil, nil)
         | 
| 46 | 
            +
                assert_respond_to @stubbed_token, :build_authorize_url_promoted
         | 
| 47 | 
            +
                url = @stubbed_token.build_authorize_url_promoted(
         | 
| 48 | 
            +
                  "http://github.com/oauth/authorize",
         | 
| 49 | 
            +
                  {:foo => "bar bar"})
         | 
| 50 | 
            +
                assert url
         | 
| 51 | 
            +
                assert_equal "http://github.com/oauth/authorize?foo=bar+bar", url
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
    
        data/test/test_server.rb
    CHANGED
    
    
    
        data/test/test_signature.rb
    CHANGED
    
    | @@ -1,11 +1,19 @@ | |
| 1 | 
            -
            require File.dirname(__FILE__) + '/test_helper.rb'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            class TestOauth < Test::Unit::TestCase
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              def  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 1 | 
            +
            require File.dirname(__FILE__) + '/test_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestOauth < Test::Unit::TestCase
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              def test_parameter_escaping_kcode_invariant
         | 
| 6 | 
            +
                old = $KCODE
         | 
| 7 | 
            +
                begin
         | 
| 8 | 
            +
                  %w(n N e E s S u U).each do |kcode|
         | 
| 9 | 
            +
                    $KCODE = kcode
         | 
| 10 | 
            +
                    assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
         | 
| 11 | 
            +
                                  "Failed to correctly escape Japanese under $KCODE = #{kcode}"
         | 
| 12 | 
            +
                    assert_equal '%C3%A9', OAuth::Helper.escape('é'),
         | 
| 13 | 
            +
                                  "Failed to correctly escape e+acute under $KCODE = #{kcode}"
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                ensure
         | 
| 16 | 
            +
                  $KCODE = old
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
    
        data/website/index.html
    CHANGED
    
    | @@ -33,7 +33,7 @@ | |
| 33 33 | 
             
                <h1>Ruby OAuth GEM</h1>
         | 
| 34 34 | 
             
                <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oauth"; return false'>
         | 
| 35 35 | 
             
                  <p>Get Version</p>
         | 
| 36 | 
            -
                  <a href="http://rubyforge.org/projects/oauth" class="numbers">0.3. | 
| 36 | 
            +
                  <a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.5</a>
         | 
| 37 37 | 
             
                </div>
         | 
| 38 38 | 
             
                <h2>What</h2>
         | 
| 39 39 | 
             
            <p>This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.</p>
         | 
| @@ -41,7 +41,7 @@ | |
| 41 41 | 
             
            <h2>Installing</h2>
         | 
| 42 42 | 
             
            <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">oauth</span></pre></p>
         | 
| 43 43 | 
             
            <p>You can also install it from the <a href="http://rubyforge.org/projects/oauth/">oauth rubyforge project</a>.</p>
         | 
| 44 | 
            -
            <p>The source code is now hosted on the <a href="http://github.com/ | 
| 44 | 
            +
            <p>The source code is now hosted on the <a href="http://github.com/mojodna/oauth">OAuth GitHub Project</a></p>
         | 
| 45 45 | 
             
            <h2>The basics</h2>
         | 
| 46 46 | 
             
            <p>This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is <span class="caps">NOT</span> a Rails plugin, but could easily be used for the foundation for such a Rails plugin.</p>
         | 
| 47 47 | 
             
            <p>As a matter of fact it has been pulled out from an <a href="http://code.google.com/p/oauth-plugin/">OAuth Rails Plugin</a> which now requires this <span class="caps">GEM</span>.</p>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: monkeyhelper-oauth
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Pelle Braendgaard
         | 
| @@ -10,11 +10,12 @@ authors: | |
| 10 10 | 
             
            - Jesse Clark
         | 
| 11 11 | 
             
            - Jon Crosby
         | 
| 12 12 | 
             
            - Seth Fitzsimmons
         | 
| 13 | 
            +
            - Matt Sanford
         | 
| 13 14 | 
             
            autorequire: 
         | 
| 14 15 | 
             
            bindir: bin
         | 
| 15 16 | 
             
            cert_chain: []
         | 
| 16 17 |  | 
| 17 | 
            -
            date: 2009- | 
| 18 | 
            +
            date: 2009-06-03 00:00:00 -07:00
         | 
| 18 19 | 
             
            default_executable: oauth
         | 
| 19 20 | 
             
            dependencies: 
         | 
| 20 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -37,6 +38,26 @@ dependencies: | |
| 37 38 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 38 39 | 
             
                    version: 1.2.3
         | 
| 39 40 | 
             
                version: 
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 42 | 
            +
              name: actionpack
         | 
| 43 | 
            +
              type: :development
         | 
| 44 | 
            +
              version_requirement: 
         | 
| 45 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 46 | 
            +
                requirements: 
         | 
| 47 | 
            +
                - - ">="
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 49 | 
            +
                    version: "0"
         | 
| 50 | 
            +
                version: 
         | 
| 51 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 52 | 
            +
              name: rack
         | 
| 53 | 
            +
              type: :development
         | 
| 54 | 
            +
              version_requirement: 
         | 
| 55 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 56 | 
            +
                requirements: 
         | 
| 57 | 
            +
                - - ">="
         | 
| 58 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 59 | 
            +
                    version: "0"
         | 
| 60 | 
            +
                version: 
         | 
| 40 61 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 41 62 | 
             
              name: hoe
         | 
| 42 63 | 
             
              type: :development
         | 
| @@ -48,7 +69,7 @@ dependencies: | |
| 48 69 | 
             
                    version: 1.8.0
         | 
| 49 70 | 
             
                version: 
         | 
| 50 71 | 
             
            description: OAuth Core Ruby implementation
         | 
| 51 | 
            -
            email:  | 
| 72 | 
            +
            email: oauth-ruby@googlegroups.com
         | 
| 52 73 | 
             
            executables: 
         | 
| 53 74 | 
             
            - oauth
         | 
| 54 75 | 
             
            extensions: []
         | 
| @@ -67,13 +88,19 @@ files: | |
| 67 88 | 
             
            - Rakefile
         | 
| 68 89 | 
             
            - TODO
         | 
| 69 90 | 
             
            - bin/oauth
         | 
| 91 | 
            +
            - examples/yql.rb
         | 
| 70 92 | 
             
            - lib/oauth.rb
         | 
| 93 | 
            +
            - lib/oauth/oauth.rb
         | 
| 71 94 | 
             
            - lib/oauth/cli.rb
         | 
| 72 95 | 
             
            - lib/oauth/client.rb
         | 
| 73 96 | 
             
            - lib/oauth/client/action_controller_request.rb
         | 
| 74 97 | 
             
            - lib/oauth/client/helper.rb
         | 
| 75 98 | 
             
            - lib/oauth/client/net_http.rb
         | 
| 76 99 | 
             
            - lib/oauth/consumer.rb
         | 
| 100 | 
            +
            - lib/oauth/errors.rb
         | 
| 101 | 
            +
            - lib/oauth/errors/error.rb
         | 
| 102 | 
            +
            - lib/oauth/errors/problem.rb
         | 
| 103 | 
            +
            - lib/oauth/errors/unauthorized.rb
         | 
| 77 104 | 
             
            - lib/oauth/helper.rb
         | 
| 78 105 | 
             
            - lib/oauth/oauth_test_helper.rb
         | 
| 79 106 | 
             
            - lib/oauth/request_proxy.rb
         | 
| @@ -96,6 +123,11 @@ files: | |
| 96 123 | 
             
            - lib/oauth/signature/rsa/sha1.rb
         | 
| 97 124 | 
             
            - lib/oauth/signature/sha1.rb
         | 
| 98 125 | 
             
            - lib/oauth/token.rb
         | 
| 126 | 
            +
            - lib/oauth/tokens/access_token.rb
         | 
| 127 | 
            +
            - lib/oauth/tokens/consumer_token.rb
         | 
| 128 | 
            +
            - lib/oauth/tokens/request_token.rb
         | 
| 129 | 
            +
            - lib/oauth/tokens/server_token.rb
         | 
| 130 | 
            +
            - lib/oauth/tokens/token.rb
         | 
| 99 131 | 
             
            - lib/oauth/version.rb
         | 
| 100 132 | 
             
            - oauth.gemspec
         | 
| 101 133 | 
             
            - script/destroy
         | 
| @@ -112,13 +144,16 @@ files: | |
| 112 144 | 
             
            - test/cases/spec/1_0-final/test_signature_base_strings.rb
         | 
| 113 145 | 
             
            - test/keys/rsa.cert
         | 
| 114 146 | 
             
            - test/keys/rsa.pem
         | 
| 147 | 
            +
            - test/test_access_token.rb
         | 
| 115 148 | 
             
            - test/test_action_controller_request_proxy.rb
         | 
| 116 149 | 
             
            - test/test_consumer.rb
         | 
| 117 150 | 
             
            - test/test_helper.rb
         | 
| 118 151 | 
             
            - test/test_hmac_sha1.rb
         | 
| 119 152 | 
             
            - test/test_net_http_client.rb
         | 
| 120 153 | 
             
            - test/test_net_http_request_proxy.rb
         | 
| 154 | 
            +
            - test/test_oauth_helper.rb
         | 
| 121 155 | 
             
            - test/test_rack_request_proxy.rb
         | 
| 156 | 
            +
            - test/test_request_token.rb
         | 
| 122 157 | 
             
            - test/test_rsa_sha1.rb
         | 
| 123 158 | 
             
            - test/test_server.rb
         | 
| 124 159 | 
             
            - test/test_signature.rb
         | 
| @@ -162,13 +197,16 @@ test_files: | |
| 162 197 | 
             
            - test/cases/spec/1_0-final/test_normalize_request_parameters.rb
         | 
| 163 198 | 
             
            - test/cases/spec/1_0-final/test_parameter_encodings.rb
         | 
| 164 199 | 
             
            - test/cases/spec/1_0-final/test_signature_base_strings.rb
         | 
| 200 | 
            +
            - test/test_access_token.rb
         | 
| 165 201 | 
             
            - test/test_action_controller_request_proxy.rb
         | 
| 166 202 | 
             
            - test/test_consumer.rb
         | 
| 167 203 | 
             
            - test/test_helper.rb
         | 
| 168 204 | 
             
            - test/test_hmac_sha1.rb
         | 
| 169 205 | 
             
            - test/test_net_http_client.rb
         | 
| 170 206 | 
             
            - test/test_net_http_request_proxy.rb
         | 
| 207 | 
            +
            - test/test_oauth_helper.rb
         | 
| 171 208 | 
             
            - test/test_rack_request_proxy.rb
         | 
| 209 | 
            +
            - test/test_request_token.rb
         | 
| 172 210 | 
             
            - test/test_rsa_sha1.rb
         | 
| 173 211 | 
             
            - test/test_server.rb
         | 
| 174 212 | 
             
            - test/test_signature.rb
         |