Sha256: fcb7bbdcc7849770cdf3233d27f20d623aeac369ac81d1bad819f9795a3a2d9c

Contents?: true

Size: 872 Bytes

Versions: 5

Compression:

Stored size: 872 Bytes

Contents

require 'spec_helper'
require 'fernet'
require 'json'
require 'base64'

describe Fernet::Generator do
  it 'generates tokens according to the spec' do
    path = File.expand_path(
      './../fernet-spec/generate.json', File.dirname(__FILE__)
    )
    generate_json  = JSON.parse(File.read(path))
    generate_json.each do |test_data|
      message        = test_data['src']
      iv             = test_data['iv'].pack("C*")
      secret         = test_data['secret']
      now            = DateTime.parse(test_data['now']).to_time
      expected_token = test_data['token']

      generator = Fernet::Generator.new(secret:  secret,
                                        message: message,
                                        iv:      iv,
                                        now:     now)

      expect(generator.generate).to eq(expected_token)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fernet-2.1.1 spec/acceptance/generate_spec.rb
fernet-2.1 spec/acceptance/generate_spec.rb
fernet-2.0 spec/acceptance/generate_spec.rb
fernet-2.0.rc2 spec/acceptance/generate_spec.rb
fernet-2.0.rc1 spec/acceptance/generate_spec.rb