Sha256: 197fbdc15dea2efc403d02b5070c26f3ecb203dbef20b62aa9d359ee90a51e9d
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe InkFilePicker::Policy do let(:secret) { '6U5CWAU57NAHDC2ICXQKMXYZ4Q' } subject do described_class.new( secret: secret, call: 'read', expiry: 1394363896 ) end it { expect(subject.policy).to eq 'eyJleHBpcnkiOjEzOTQzNjM4OTYsImNhbGwiOiJyZWFkIn0=' } it { expect(subject.signature).to eq '4c50ca71d9e123274a01eb00a7facd52069e07c2e9312517f55bf1b94447792e' } describe "the policy" do let(:decoded) do JSON.parse Base64.urlsafe_decode64 subject.policy end it { expect(decoded['call']).to eq 'read' } it { expect(decoded['expiry']).to eq 1394363896 } it "ensures expiry is a number" do time = Time.parse('2016-01-01 00:00:00 +0100') subject.expiry = time decoded = JSON.parse Base64.urlsafe_decode64 subject.policy expect(decoded['expiry']).to eq 1451602800 end end describe "#to_hash" do it "contains policy and signature when secret is given" do expect(subject.to_hash).to eq({ policy: subject.policy, signature: subject.signature }) end it "returns an empty hash when no secret is given" do subject.secret = nil expect(subject.to_hash).to eq({}) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ink_file_picker-0.0.4 | spec/ink_file_picker/policy_spec.rb |