Sha256: 379b8161d81e92d730113dd70a9fb962544a46e06950072c4667ae667287fef0

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

require 'spec_helper'

class TestRequest < Mushikago::Http::Request
  include Mushikago::Auth::Signature
end

describe Mushikago::Auth::Signature do
  before do
    @request = TestRequest.new
    @request.http_method = 'GET'
    @request.host = 'mushikago.org'
    @request.path = '/1/someapi.json'
    @request.set_param('api_key', 'api_key')
    @request.set_param('timestamp', '2011-09-01T00:00:00Z')
  end

  context 'generates string to sign' do
    subject{ @request.string_to_sign }
    it{ should == "GET\nmushikago.org\n/1/someapi.json\napi_key=api_key&timestamp=2011-09-01T00%3A00%3A00Z" }
  end

  context 'add signature' do
    before do
      @request.add_signature!(Mushikago::Auth::Signer.new('secret_key'))
    end
    subject{ @request.get_param('signature') }
    it{ should == 'sJSFFQREYbNPd2kJK3kuAR3uSgvcbuWtxGFjan+R3w8=' }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mushikago-sdk-0.2.1 spec/mushikago/auth/signature_spec.rb