Sha256: 18d8de31944fc850803124224dd66bd933aca59b1397741f3423159628c8ddbb

Contents?: true

Size: 920 Bytes

Versions: 46

Compression:

Stored size: 920 Bytes

Contents

require 'test_helper'

module Shipit
  class ApiClientTest < ActiveSupport::TestCase
    setup do
      @client = shipit_api_clients(:spy)
    end

    test "#authentication_token is the signed id" do
      assert_match(/^\d+--[\da-f]{40}$/, @client.authentication_token)
    end

    test "#authentication_token casted as integer is the client id" do
      assert_equal @client.id, @client.authentication_token.to_i
    end

    test ".authenticate returns nil if the signature is invalid" do
      assert_nil ApiClient.authenticate("#{@client.id}--foobar")
    end

    test ".authenticate returns nil if the api client do not exists" do
      assert_nil ApiClient.authenticate(ApiClient.new(id: 42).authentication_token)
    end

    test ".authenticate returns the matching ApiClient record if the token is valid" do
      assert_equal @client, ApiClient.authenticate(@client.authentication_token)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 test/models/api_client_test.rb
shipit-engine-0.30.0 test/models/api_client_test.rb
shipit-engine-0.29.0 test/models/api_client_test.rb
shipit-engine-0.28.1 test/models/api_client_test.rb
shipit-engine-0.28.0 test/models/api_client_test.rb
shipit-engine-0.27.1 test/models/api_client_test.rb
shipit-engine-0.27.0 test/models/api_client_test.rb
shipit-engine-0.26.0 test/models/api_client_test.rb
shipit-engine-0.25.1 test/models/api_client_test.rb
shipit-engine-0.25.0 test/models/api_client_test.rb
shipit-engine-0.24.0 test/models/api_client_test.rb
shipit-engine-0.23.1 test/models/api_client_test.rb
shipit-engine-0.23.0 test/models/api_client_test.rb
shipit-engine-0.22.0 test/models/api_client_test.rb
shipit-engine-0.21.0 test/models/api_client_test.rb
shipit-engine-0.20.1 test/models/api_client_test.rb
shipit-engine-0.20.0 test/models/api_client_test.rb
shipit-engine-0.19.0 test/models/api_client_test.rb
shipit-engine-0.18.1 test/models/api_client_test.rb
shipit-engine-0.18.0 test/models/api_client_test.rb