Sha256: 674d8f0fc30e5abdc033502e825ae81a78940a3bca1a7b5c8cb911b8f3e95dc5

Contents?: true

Size: 845 Bytes

Versions: 4

Compression:

Stored size: 845 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe FBGraph do
  describe FBGraph::Canvas do
    before :each do
      @payload = { 'algorithm' => 'HMAC-SHA256', 'foo' => 'bar' }
      @secret = 'thisisasecret'

      encoded_payload = Base64.encode64(@payload.to_json)
      hash = OpenSSL::HMAC.digest('sha256', @secret, encoded_payload)
      encoded_sig = Base64.encode64(hash)

      @valid_request = "#{encoded_sig}.#{encoded_payload}"
    end

    it "should decode a valid request" do
      result = FBGraph::Canvas.parse_signed_request(@secret, @valid_request)
      result.should == @payload
    end

    it "should raise on an invalid request" do
      bad_secret = "notagoodsecret"

      lambda {
        FBGraph::Canvas.parse_signed_request(bad_secret, @valid_request)
      }.should raise_error
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fbgraph-1.10.0 specs/lib/fbauth/canvas_spec.rb
fbgraph-1.9.0 specs/lib/fbauth/canvas_spec.rb
fbgraph-1.8.4 specs/lib/fbauth/canvas_spec.rb
fbgraph-1.8.3 specs/lib/fbauth/canvas_spec.rb