Created
November 29, 2008 17:17
-
-
Save julesfern/30260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should verify that a correctly-signed GET request is signed using GET parameters" do | |
# set the api key to a known value for the purposes of this test | |
@authenticating_client.send(:"api_key=", "fishsticks") | |
@authenticating_client.save! | |
get_params = { | |
"a"=>"1", "BBB"=>"3", "c"=>"2", | |
"1"=>"a", "2"=>"b", | |
"api_key"=>"fishsticks" | |
} | |
get_params[:api_signature] = Digest::SHA1.hexdigest("#{@authenticating_client.secret}httptest.fullfat.com/secret/#{get_params.keys.sort.join("")}#{get_params.values.sort.join("")}") | |
param_string = get_params.collect{|k,v| "#{k}=#{v}"}.join("&") | |
req = fake_request( | |
:request_method => "GET", | |
:query_string => param_string, | |
:http_host => "test.fullfat.com", | |
:request_uri=>"/secret/" | |
) | |
req.full_uri.should == "http://test.fullfat.com/secret/" | |
req.authenticating_client.should == @authenticating_client | |
req.signed?.should be_true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment