spec/direct_spec.rb in chargify2-0.1.0 vs spec/direct_spec.rb in chargify2-0.2.0
- old
+ new
@@ -57,76 +57,14 @@
# Used the HMAC-SHA1 generator here: http://hash.online-convert.com/sha1-generator
Direct.signature(message, secret).should == "459cceb1ad074a9082daba5c0788f12fdd6cdbd6"
end
end
- describe "#result" do
+ describe "#response_parameters" do
let(:direct) { Direct.new(client) }
- it "generates a new Result instance given a hash of result params" do
- direct.result({}).should be_a(Direct::Result)
- end
- end
-
- describe Direct::Result do
- describe "#verified?" do
- it "returns true when the calculated signature of the result params matches the received signature" do
- api_id = '1c016050-498a-012e-91b1-005056a216ab'
- status_code = '200'
- result_code = '2000'
- call_id = '1234'
-
- # Used the generator here: http://hash.online-convert.com/sha1-generator
- # ... with message: "1c016050-498a-012e-91b1-005056a216ab20020001234"
- # ... and secret: "p5lxQ804MYtwZecFWNOT"
- # ... to get: "9d1b9139d6c49720faa0b2b6207c95060e6695d4"
- signature = "9d1b9139d6c49720faa0b2b6207c95060e6695d4"
-
- r = Direct::Result.new({
- 'api_id' => api_id,
- 'status_code' => status_code,
- 'result_code' => result_code,
- 'call_id' => call_id,
- 'signature' => signature}, client)
-
- r.verified?.should be_true
- end
-
- it "returns false when the calculated signature of the result params is different from the received signature" do
- r = Direct::Result.new({
- 'api_id' => client.api_id,
- 'status_code' => '2',
- 'result_code' => '3',
- 'call_id' => '4',
- 'signature' => '5'}, client)
-
- r.verified?.should be_false
- end
-
- it "returns false when the calculated signature is correct but the api_id does not match the client's'" do
- api_id = '1c016050-498a-012e-91b1-005056a216ab'
- status_code = '200'
- result_code = '2000'
- call_id = '1234'
-
- # Used the generator here: http://hash.online-convert.com/sha1-generator
- # ... with message: "1c016050-498a-012e-91b1-005056a216ab20020001234"
- # ... and secret: "p5lxQ804MYtwZecFWNOT"
- # ... to get: "9d1b9139d6c49720faa0b2b6207c95060e6695d4"
- signature = "9d1b9139d6c49720faa0b2b6207c95060e6695d4"
-
- client_credentials = valid_client_credentials
- client_credentials[:api_id] = '1234'
- different_client = Client.new(client_credentials)
- r = Direct::Result.new({
- 'api_id' => api_id,
- 'status_code' => status_code,
- 'result_code' => result_code,
- 'call_id' => call_id,
- 'signature' => signature}, different_client)
-
- r.verified?.should be_false
- end
+ it "generates a new ResponseParameters instance given a hash of response params" do
+ direct.response_parameters({}).should be_a(Direct::ResponseParameters)
end
end
end
end
\ No newline at end of file