Sha256: f691ff790ff0da096f4d3fa4088c20895f1faf1213d2ead125cc9bf13579e3e0

Contents?: true

Size: 1.7 KB

Versions: 21

Compression:

Stored size: 1.7 KB

Contents

require 'helper'
require 'uuidtools'

class UserTest < Vault::TestCase
  # User.id_to_hid converts a user ID to a Heroku user ID.
  def test_id_to_hid
    assert_equal('user1234@heroku.com', Vault::User.id_to_hid(1234))
  end

  # User.id_to_uuid converts a user ID to a v5 UUID based on a URL scheme.
  def test_id_to_uuid
    url = "https://vault.heroku.com/users/1234"
    uuid = UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, url).to_s
    assert_equal(uuid, Vault::User.id_to_uuid(1234))
  end

  # User.hid_to_id converts a Heroku user ID into a core integer user ID.
  def test_hid_to_id
    assert_equal(1234, Vault::User.hid_to_id('user1234@heroku.com'))
  end

  # User.hid_to_id raises an ArgumentError if the specified ID doesn't match
  # the expected format.
  def test_hid_to_id_with_invalid_heroku_id
    error = assert_raises(ArgumentError) do
      Vault::User.hid_to_id('invalid1234@heroku.com')
    end
    assert_equal('invalid1234@heroku.com is not a valid Heroku user ID.',
                 error.message)
  end

  # User.hid_to_uuid converts a Heroku user ID to a v5 UUID based on a URL
  # scheme.
  def test_hid_to_uuid
    url = "https://vault.heroku.com/users/1234"
    uuid = UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, url).to_s
    assert_equal(uuid, Vault::User.hid_to_uuid('user1234@heroku.com'))
  end

  # User.hid_to_uuid raises an ArgumentError if the specified ID doesn't match
  # the expected format.
  def test_hid_to_uuid_with_invalid_heroku_id
    error = assert_raises(ArgumentError) do
      Vault::User.hid_to_uuid('invalid1234@heroku.com')
    end
    assert_equal('invalid1234@heroku.com is not a valid Heroku user ID.',
                 error.message)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
vault-tools-0.4.6 test/user_test.rb
vault-tools-0.4.5 test/user_test.rb
vault-tools-0.4.4 test/user_test.rb
vault-tools-0.4.3 test/user_test.rb
vault-tools-0.4.2 test/user_test.rb
vault-tools-0.4.1 test/user_test.rb
vault-tools-0.4.0 test/user_test.rb
vault-tools-0.3.11 test/user_test.rb
vault-tools-0.3.10 test/user_test.rb
vault-tools-0.3.9 test/user_test.rb
vault-tools-0.3.8 test/user_test.rb
vault-tools-0.3.7 test/user_test.rb
vault-tools-0.3.6 test/user_test.rb
vault-tools-0.3.5 test/user_test.rb
vault-tools-0.3.4 test/user_test.rb
vault-tools-0.3.3 test/user_test.rb
vault-tools-0.3.2 test/user_test.rb
vault-tools-0.3.1 test/user_test.rb
vault-tools-0.3.0 test/user_test.rb
vault-tools-0.2.1 test/user_test.rb