Sha256: c2bcf46f254d637b6521a09446e3978a339dcd8b565dcd1f9d93b2951be8c46e

Contents?: true

Size: 821 Bytes

Versions: 15

Compression:

Stored size: 821 Bytes

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

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

describe Mushikago::Auth::Signature do
  before do
    @request = TestRequest.new
    @request.host = 'mushikago.org'
    @request.path = '/1/someapi.json'
    @request['api_key'] = 'api_key'
    @request['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['signature'] }
    it{ should == 'sJSFFQREYbNPd2kJK3kuAR3uSgvcbuWtxGFjan+R3w8=' }
  end
end

Version data entries

15 entries across 12 versions & 1 rubygems

Version Path
mushikago-sdk-2.4.3 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.4.3 spec//mushikago/auth/signature_spec.rb
mushikago-sdk-2.4.2 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.4.2 spec//mushikago/auth/signature_spec.rb
mushikago-sdk-2.4.1 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.4 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.2 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.2 spec//mushikago/auth/signature_spec.rb
mushikago-sdk-2.1.1 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.1.0 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-2.0.0 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-0.4.3 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-0.4.2 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-0.4.1 spec/mushikago/auth/signature_spec.rb
mushikago-sdk-0.4.0 spec/mushikago/auth/signature_spec.rb