Sha256: a03a838d7d788f95bb8d7d5ded8bc64a11fd5bf0beae24108ea2c890c409eb6b

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require 'test_helper'

class TestBackendLocalKeyTest < MiniTest::Unit::TestCase
  KRAMOS_KEY = <<KRAMOS_KEY
ssh-rsa wr5nIAGausTqiNhOT00B91x3Yd98qhoJe0Gd6f1eSkzPKdSADFESfiqsVOJrtmTsmoP79ZQKVpZxzF75r59LDmTVd9lxHmrvs30iYxJgWhM8QpbDEL7KrPWz9icb3kxVURXTVzSQSyT2zJ0tCi0xGP3g7TJw0XkZpzVjGdTTgUodN0H4xsTJfBZYHkJRG449u9R9awIx4V47x5oNiddAVlYvjQU4gULXwkCZC8Ho0pGoo7xZ2XYW4BWNPjrl24bXH7hVf6lJLy40ZxRhjnMsVwWxBS5tKMBNu9G8m3xkDLbdf93GI7tfNIfAdqzLvEA0V4oU95UO0O4juxtjr28KGis6ttdEjgGgTzdHICOfSdjMEMFEWxMR kramos@demimbu.info
KRAMOS_KEY

  def test_get_all_keys
    assert_equal 2, Nuvado::Backend::LocalKey.all.count
  end

  def test_get_all_keys_filenames
    assert_equal ["jmendoza.pub", "kramos.pub"], Nuvado::Backend::LocalKey.all.map(&:filename)
  end

  def test_get_keys_content
    key = Nuvado::Backend::LocalKey.all.last
    assert_equal KRAMOS_KEY, key.blob
  end

  def test_find_by_name_finds
    key = Nuvado::Backend::LocalKey.find_by_name("kramos.pub")
    assert_equal "kramos.pub", key.filename
    assert_equal KRAMOS_KEY, key.blob
  end

  def test_find_by_name_doesnt_find
    assert_nil Nuvado::Backend::LocalKey.find_by_name("fakename.pub")
  end

  def test_generate_existing_key_raises_error
    assert_raises Nuvado::SystemExitException do
      Nuvado::Backend::LocalKey.generate("kramos")
    end
  end

  def test_generate_new_key_creates_file
    key = Nuvado::Backend::LocalKey.generate("gollum")
    assert_equal "gollum.pub", key.filename
    key_parts = key.blob.split
    assert_equal 3, key_parts.length
    assert "ssh-rsa", key_parts.first
    File.delete key.filepath
    File.delete key.filepath.chomp(".pub")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nuvado-1.0.0.rc3 test/backend_local_key_test.rb
nuvado-1.0.0.rc2 test/backend_local_key_test.rb
nuvado-1.0.0.rc1 test/backend_local_key_test.rb