Sha256: b60a906f2a5815f8903b982d9e98a05805fcd3f1d1cb6528fa31d49d63fd743d

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require 'rubygems'
require 'require_relative' if RUBY_VERSION < '1.9'

require_relative File.join('..', 'common.rb')

describe Deltacloud::Collections::Keys do

  before do
    def app; run_frontend; end
    authorize 'mockuser', 'mockpassword'
    @collection = Deltacloud::Collections.collection(:keys)
  end

  it 'has index operation' do
    @collection.operation(:index).must_equal Deltacloud::Rabbit::KeysCollection::IndexOperation
  end

  it 'has show operation' do
    @collection.operation(:show).must_equal Deltacloud::Rabbit::KeysCollection::ShowOperation
  end

  it 'returns list of keys in various formats with index operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/keys'
      status.must_equal 200
    end
  end

  it 'returns details about key in various formats with show operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/keys/test-key'
      status.must_equal 200
    end
  end

  it 'provides URL to create new key' do
    header 'Accept', 'text/html'
    get root_url + '/keys/new'
    status.must_equal 200
    response_body.must_include 'Create new SSH key'
  end

  it 'must support creating and destroying keys' do
    post root_url + '/keys', { :name => 'unit-test1' }
    status.must_equal 201
    xml.root.name.must_equal 'key'
    xml.root[:id].must_equal 'unit-test1'
    (xml/'key/pem').wont_be_empty
    delete root_url + '/keys/unit-test1'
    status.must_equal 204
  end

  it 'reports 404 when querying non-existing key' do
    get root_url + '/keys/unknown'
    status.must_equal 404
  end

  it 'properly serialize attributes in JSON' do
    check_json_serialization_for :key, 'test-key'
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.1.3 tests/deltacloud/collections/keys_collection_test.rb
deltacloud-core-1.1.2 tests/deltacloud/collections/keys_collection_test.rb