Sha256: 7bd65124782b861a217a7e24d046d096d459546a1706d957b12a73c37d1f23a9

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

require_relative './common.rb'

describe Deltacloud::EC2::API do

  before do
    def app; Deltacloud::EC2::API; end
  end

  it 'has the config set property' do
    Deltacloud::config[:ec2].must_be_kind_of Deltacloud::Server
    root_url.must_equal Deltacloud[:ec2].root_url
  end

  it 'must do a redirection when no Action parameter' do
    get root_url
    status.must_equal 301
    headers['Location'].must_equal 'http://example.org/'
  end

  it 'must set the Connection header to close' do
    get root_url
    headers['Connection'].must_equal 'close'
  end

  it 'must advertise current API version in response headers' do
    get root_url
    headers['Server'].must_equal 'Apache-Deltacloud-EC2/2012-04-01'
  end

  it 'must return EC2 exception when unknown action' do
    get root_url + '?Action=UnknownActionTest'
    xml.root.name.must_equal 'Response'
    (xml/'Response/Errors/Code').first.text.strip.must_equal 'InvalidAction'
  end

  it 'must return EC2 exception when authentication failed' do
    authorize 'unknownuser', 'password'
    get root_url + '?Action=DescribeAvailabilityZones'
    status.must_equal 401
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deltacloud-core-1.0.2 tests/ec2/server_test.rb