mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
switch to using extracted connection code (excon)
This commit is contained in:
parent
3438860ae8
commit
4086234ddc
45 changed files with 61 additions and 354 deletions
1
Rakefile
1
Rakefile
|
@ -7,6 +7,7 @@ require "#{current_directory}/lib/fog"
|
|||
begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |gem|
|
||||
gem.add_dependency('excon')
|
||||
gem.add_dependency('mime-types')
|
||||
gem.add_dependency('nokogiri')
|
||||
gem.add_dependency('ruby-hmac')
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require 'rubygems'
|
||||
require 'rubygems'
|
||||
require 'base64'
|
||||
require 'cgi'
|
||||
require 'digest/md5'
|
||||
|
@ -26,6 +25,11 @@ module Fog
|
|||
end
|
||||
|
||||
def self.reload
|
||||
load "fog/collection.rb"
|
||||
load "fog/connection.rb"
|
||||
load "fog/model.rb"
|
||||
load "fog/parser.rb"
|
||||
|
||||
load "fog/aws.rb"
|
||||
load "fog/rackspace.rb"
|
||||
end
|
||||
|
|
|
@ -20,12 +20,6 @@ module Fog
|
|||
end
|
||||
|
||||
def self.reload
|
||||
load "fog/collection.rb"
|
||||
load "fog/connection.rb"
|
||||
load "fog/model.rb"
|
||||
load "fog/parser.rb"
|
||||
load "fog/response.rb"
|
||||
|
||||
load "fog/aws/models/ec2/address.rb"
|
||||
load "fog/aws/models/ec2/addresses.rb"
|
||||
load "fog/aws/models/ec2/instance.rb"
|
||||
|
|
|
@ -12,12 +12,6 @@ module Fog
|
|||
end
|
||||
|
||||
def self.reload
|
||||
load "fog/collection.rb"
|
||||
load "fog/connection.rb"
|
||||
load "fog/model.rb"
|
||||
load "fog/parser.rb"
|
||||
load "fog/response.rb"
|
||||
|
||||
load "fog/aws/models/s3/bucket.rb"
|
||||
load "fog/aws/models/s3/buckets.rb"
|
||||
load "fog/aws/models/s3/object.rb"
|
||||
|
|
|
@ -12,10 +12,6 @@ module Fog
|
|||
end
|
||||
|
||||
def self.reload
|
||||
load "fog/connection.rb"
|
||||
load "fog/parser.rb"
|
||||
load "fog/response.rb"
|
||||
|
||||
load "fog/aws/parsers/simpledb/basic.rb"
|
||||
load "fog/aws/parsers/simpledb/domain_metadata.rb"
|
||||
load "fog/aws/parsers/simpledb/get_attributes.rb"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
require 'rubygems'
|
||||
require 'openssl'
|
||||
require 'socket'
|
||||
require 'uri'
|
||||
require 'excon'
|
||||
|
||||
require "fog/errors"
|
||||
require "fog/response"
|
||||
|
@ -11,147 +9,24 @@ unless Fog.mocking?
|
|||
module Fog
|
||||
class Connection
|
||||
|
||||
unless const_defined?(:CHUNK_SIZE)
|
||||
CHUNK_SIZE = 1048576 # 1 megabyte
|
||||
end
|
||||
|
||||
def initialize(url)
|
||||
@uri = URI.parse(url)
|
||||
end
|
||||
|
||||
def connection
|
||||
if @connection && !@connection.closed?
|
||||
@connection
|
||||
else
|
||||
@connection = TCPSocket.open(@uri.host, @uri.port)
|
||||
if @uri.scheme == 'https'
|
||||
@ssl_context = OpenSSL::SSL::SSLContext.new
|
||||
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
@connection = OpenSSL::SSL::SSLSocket.new(@connection, @ssl_context)
|
||||
@connection.sync_close = true
|
||||
@connection.connect
|
||||
end
|
||||
end
|
||||
@excon = Excon.new(url)
|
||||
end
|
||||
|
||||
def request(params)
|
||||
begin
|
||||
params[:path] ||= ''
|
||||
unless params[:path][0..0] == '/'
|
||||
params[:path] = '/' + params[:path].to_s
|
||||
end
|
||||
if params[:query] && !params[:query].empty?
|
||||
params[:path] << "?#{params[:query]}"
|
||||
end
|
||||
request = "#{params[:method]} #{params[:path]} HTTP/1.1\r\n"
|
||||
params[:headers] ||= {}
|
||||
params[:headers]['Host'] = params[:host]
|
||||
if params[:body] && !params[:headers]['Content-Length']
|
||||
params[:headers]['Content-Length'] = params[:body].length
|
||||
end
|
||||
for key, value in params[:headers]
|
||||
request << "#{key}: #{value}\r\n"
|
||||
end
|
||||
request << "\r\n"
|
||||
connection.write(request)
|
||||
|
||||
if params[:body]
|
||||
if params[:body].is_a?(String)
|
||||
connection.write(params[:body])
|
||||
else
|
||||
while chunk = params[:body].read(CHUNK_SIZE)
|
||||
connection.write(chunk)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
response = Fog::Response.new
|
||||
response.request = params
|
||||
response.status = connection.readline[9..11].to_i
|
||||
if params[:expects] && ![*params[:expects]].include?(response.status)
|
||||
error = true
|
||||
end
|
||||
while true
|
||||
data = connection.readline.chomp!
|
||||
if data == ""
|
||||
break
|
||||
end
|
||||
header = data.split(': ')
|
||||
response.headers[capitalize(header[0])] = header[1]
|
||||
end
|
||||
|
||||
unless params[:method] == 'HEAD' || [204, 304, *(100..199)].include?(response.status)
|
||||
if (error && params[:error_parser]) || params[:parser]
|
||||
if error
|
||||
parser = params[:error_parser]
|
||||
elsif params[:parser]
|
||||
parser = params[:parser]
|
||||
end
|
||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||
elsif params[:block]
|
||||
body = nil
|
||||
else
|
||||
body = ''
|
||||
end
|
||||
|
||||
if response.headers['Content-Length']
|
||||
if error || !params[:block]
|
||||
body << connection.read(response.headers['Content-Length'].to_i)
|
||||
else
|
||||
remaining = response.headers['Content-Length'].to_i
|
||||
while remaining > 0
|
||||
params[:block].call(connection.read([CHUNK_SIZE, remaining].min))
|
||||
remaining -= CHUNK_SIZE;
|
||||
end
|
||||
end
|
||||
elsif response.headers['Transfer-Encoding'] == 'chunked'
|
||||
while true
|
||||
chunk_size = connection.readline.chomp!.to_i(16)
|
||||
# 2 == "/r/n".length
|
||||
chunk = connection.read(chunk_size + 2)[0...-2]
|
||||
if chunk_size == 0
|
||||
break
|
||||
else
|
||||
if error || !params[:block]
|
||||
body << chunk
|
||||
else
|
||||
params[:block].call(chunk)
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif response.headers['Connection'] == 'close'
|
||||
body << connection.read
|
||||
@connection = nil
|
||||
end
|
||||
|
||||
if parser
|
||||
body.finish
|
||||
response.body = parser.response
|
||||
else
|
||||
response.body = body
|
||||
end
|
||||
end
|
||||
rescue => connection_error
|
||||
@connection = nil
|
||||
raise(connection_error)
|
||||
if parser = params.delete(:parser)
|
||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||
params[:block] = lambda { |chunk| body << chunk }
|
||||
end
|
||||
|
||||
if error
|
||||
raise(Fog::Errors.status_error(params[:expects], response.status, response))
|
||||
else
|
||||
response
|
||||
end
|
||||
end
|
||||
response = @excon.request(params)
|
||||
|
||||
private
|
||||
|
||||
def capitalize(header)
|
||||
words = header.split('-')
|
||||
header = ''
|
||||
for word in words
|
||||
header << word[0..0].upcase << word[1..-1] << '-'
|
||||
if parser
|
||||
body.finish
|
||||
response.body = parser.response
|
||||
end
|
||||
header.chop!
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
require "fog/parser"
|
||||
|
||||
module Fog
|
||||
module Errors
|
||||
class Continue < StandardError; end # 100
|
||||
class SwitchingProtocols < StandardError; end # 101
|
||||
class OK < StandardError; end # 200
|
||||
class Created < StandardError; end # 201
|
||||
class Accepted < StandardError; end # 202
|
||||
class NonAuthoritativeInformation < StandardError; end # 203
|
||||
class NoContent < StandardError; end # 204
|
||||
class ResetContent < StandardError; end # 205
|
||||
class PartialContent < StandardError; end # 206
|
||||
class MultipleChoices < StandardError; end # 300
|
||||
class MovedPermanently < StandardError; end # 301
|
||||
class Found < StandardError; end # 302
|
||||
class SeeOther < StandardError; end # 303
|
||||
class NotModified < StandardError; end # 304
|
||||
class UseProxy < StandardError; end # 305
|
||||
class TemporaryRedirect < StandardError; end # 307
|
||||
class BadRequest < StandardError; end # 400
|
||||
class Unauthorized < StandardError; end # 401
|
||||
class PaymentRequired < StandardError; end # 402
|
||||
class Forbidden < StandardError; end # 403
|
||||
class NotFound < StandardError; end # 404
|
||||
class MethodNotAllowed < StandardError; end # 405
|
||||
class NotAcceptable < StandardError; end #406
|
||||
class ProxyAuthenticationRequired < StandardError; end #407
|
||||
class RequestTimeout < StandardError; end # 408
|
||||
class Conflict < StandardError; end # 409
|
||||
class Gone < StandardError; end # 410
|
||||
class LengthRequired < StandardError; end # 411
|
||||
class PreconditionFailed < StandardError; end # 412
|
||||
class RequestEntityTooLarge < StandardError; end # 412
|
||||
class RequestURITooLong < StandardError; end # 414
|
||||
class UnsupportedMediaType < StandardError; end # 415
|
||||
class RequestedRangeNotSatisfiable < StandardError; end # 416
|
||||
class ExpectationFailed < StandardError; end # 417
|
||||
class InternalServerError < StandardError; end # 500
|
||||
class NotImplemented < StandardError; end # 501
|
||||
class BadGateway < StandardError; end # 502
|
||||
class ServiceUnavailable < StandardError; end # 503
|
||||
class GatewayTimeout < StandardError; end # 504
|
||||
|
||||
# Messages for nicer exceptions, from rfc2616
|
||||
def self.status_error(expected, actual, response)
|
||||
@errors ||= {
|
||||
100 => Fog::Errors::Continue,
|
||||
101 => Fog::Errors::SwitchingProtocols,
|
||||
200 => Fog::Errors::OK,
|
||||
201 => Fog::Errors::Created,
|
||||
202 => Fog::Errors::Accepted,
|
||||
203 => Fog::Errors::NonAuthoritativeInformation,
|
||||
204 => Fog::Errors::NoContent,
|
||||
205 => Fog::Errors::ResetContent,
|
||||
206 => Fog::Errors::PartialContent,
|
||||
300 => Fog::Errors::MultipleChoices,
|
||||
301 => Fog::Errors::MovedPermanently,
|
||||
302 => Fog::Errors::Found,
|
||||
303 => Fog::Errors::SeeOther,
|
||||
304 => Fog::Errors::NotModified,
|
||||
305 => Fog::Errors::UseProxy,
|
||||
307 => Fog::Errors::TemporaryRedirect,
|
||||
400 => Fog::Errors::BadRequest,
|
||||
401 => Fog::Errors::Unauthorized,
|
||||
402 => Fog::Errors::PaymentRequired,
|
||||
403 => Fog::Errors::Forbidden,
|
||||
404 => Fog::Errors::NotFound,
|
||||
405 => Fog::Errors::MethodNotAllowed,
|
||||
406 => Fog::Errors::NotAcceptable,
|
||||
407 => Fog::Errors::ProxyAuthenticationRequired,
|
||||
408 => Fog::Errors::RequestTimeout,
|
||||
409 => Fog::Errors::Conflict,
|
||||
410 => Fog::Errors::Gone,
|
||||
411 => Fog::Errors::LengthRequired,
|
||||
412 => Fog::Errors::PreconditionFailed,
|
||||
413 => Fog::Errors::RequestEntityTooLarge,
|
||||
414 => Fog::Errors::RequestURITooLong,
|
||||
415 => Fog::Errors::UnsupportedMediaType,
|
||||
416 => Fog::Errors::RequestedRangeNotSatisfiable,
|
||||
417 => Fog::Errors::ExpectationFailed,
|
||||
500 => Fog::Errors::InternalServerError,
|
||||
501 => Fog::Errors::NotImplemented,
|
||||
502 => Fog::Errors::BadGateway,
|
||||
503 => Fog::Errors::ServiceUnavailable,
|
||||
504 => Fog::Errors::GatewayTimeout
|
||||
}
|
||||
@messages ||= {
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
200 => 'OK',
|
||||
201 =>'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
303 => 'See Other',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
402 => 'Payment Required',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Timeout',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Long',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Timeout'
|
||||
}
|
||||
response = "#{response.body['Code']} => #{response.body['Message']}"
|
||||
@errors[actual].new("Expected(#{expected} #{@messages[expected]}) <=> Actual(#{actual} #{@messages[actual]}): #{response}")
|
||||
end
|
||||
|
||||
class Parser < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'Code', 'Message'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class Files
|
||||
|
||||
def self.reload
|
||||
load "fog/rackspace/requests/files/delete_containers.rb"
|
||||
load "fog/rackspace/requests/files/delete_container.rb"
|
||||
load "fog/rackspace/requests/files/get_container.rb"
|
||||
load "fog/rackspace/requests/files/get_containers.rb"
|
||||
load "fog/rackspace/requests/files/head_container.rb"
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
module Fog
|
||||
class Response
|
||||
|
||||
attr_accessor :body, :headers, :request, :status
|
||||
|
||||
def initialize
|
||||
@body = ''
|
||||
@headers = {}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ describe 'EC2.associate_address' do
|
|||
@public_ip = ec2.allocate_address.body['publicIp']
|
||||
lambda {
|
||||
ec2.associate_address('i-00000000', @public_ip)
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
ec2.release_address(@public_ip)
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ describe 'EC2.associate_address' do
|
|||
@instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||
lambda {
|
||||
ec2.associate_address(@instance_id, '127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
ec2.terminate_instances(@instance_id)
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe 'EC2.attach_volume' do
|
|||
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
||||
lambda {
|
||||
ec2.attach_volume('i-00000000', @volume_id, '/dev/sdh')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
ec2.delete_volume(@volume_id)
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ describe 'EC2.attach_volume' do
|
|||
@instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||
lambda {
|
||||
ec2.attach_volume(@instance_id, 'vol-00000000', '/dev/sdh')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
ec2.terminate_instances(@instance_id)
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ describe 'EC2.create_key_pair' do
|
|||
it "should raise a BadRequest when the key pair already exists" do
|
||||
lambda {
|
||||
ec2.create_key_pair('fog_key_pair')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe 'EC2.create_security_group' do
|
|||
it "should raise a BadRequest error when the security group already exists" do
|
||||
lambda {
|
||||
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ describe 'EC2.create_snapshot' do
|
|||
it "should raise a BadRequest error if the volume does not exist" do
|
||||
lambda {
|
||||
ec2.create_snapshot('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe 'EC2.delete_security_group' do
|
|||
it "should raise a BadRequest error if the security group does not exist" do
|
||||
lambda {
|
||||
ec2.delete_security_group('fog_not_a_security_group')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ describe 'EC2.delete_snapshot' do
|
|||
it "should raise a BadRequest error if snapshot does not exist" do
|
||||
lambda {
|
||||
ec2.release_address('snap-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe 'EC2.create_volume' do
|
|||
it "should raise a BadRequest error if volume does not exist" do
|
||||
lambda {
|
||||
ec2.release_address('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ describe 'EC2.describe_addresses' do
|
|||
it "should raise a BadRequest error if ip does not exist" do
|
||||
lambda {
|
||||
ec2.describe_addresses('127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -79,7 +79,7 @@ describe 'EC2.describe_instances' do
|
|||
it 'should raise a BadRequest error if the instance does not exist' do
|
||||
lambda {
|
||||
ec2.describe_instances('i-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ describe 'EC2.describe_key_pairs' do
|
|||
it "should raise a BadRequest error if the key does not exist" do
|
||||
lambda {
|
||||
ec2.describe_key_pairs('fog_not_a_key_name')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ describe 'EC2.describe_security_groups' do
|
|||
it "should raise a BadRequest error if the security group does not exist" do
|
||||
lambda {
|
||||
ec2.describe_security_groups('not_a_security_group')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ describe 'EC2.describe_snapshots' do
|
|||
it "should raise a BadRequest error if the snapshot does not exist" do
|
||||
lambda {
|
||||
ec2.describe_snapshots('snap-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ describe 'EC2.describe_volumes' do
|
|||
it "should raise a BadRequest error if volume does not exist" do
|
||||
lambda {
|
||||
ec2.describe_volumes('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ describe 'EC2.detach_volume' do
|
|||
it "should raise a BadRequest error if the volume does not exist" do
|
||||
lambda {
|
||||
ec2.detach_volume('vol-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe 'EC2.disassociate_address' do
|
|||
it "should raise a BadRequest error if the address does not exist" do
|
||||
lambda {
|
||||
ec2.disassociate_address('127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe 'EC2.get_console_output' do
|
|||
it "should raise a BadRequest error if the instance does not exist" do
|
||||
lambda {
|
||||
ec2.get_console_output('i-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ describe 'EC2.reboot_instances' do
|
|||
it "should raise a BadRequest error if the instance does not exist" do
|
||||
lambda {
|
||||
ec2.reboot_instances('i-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe 'EC2.release_address' do
|
|||
it "should raise a BadRequest error if address does not exist" do
|
||||
lambda {
|
||||
ec2.release_address('127.0.0.1')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ describe 'EC2.terminate_instances' do
|
|||
it 'should raise a BadRequest error if the instance does not exist' do
|
||||
lambda {
|
||||
ec2.terminate_instances('i-00000000')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ describe 'S3.copy_object' do
|
|||
'fognotabucket', 'fog_copy_object_source',
|
||||
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
||||
)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the source_object does not exist' do
|
||||
|
@ -45,7 +45,7 @@ describe 'S3.copy_object' do
|
|||
'fogcopyobjectsource', 'fog_not_an_object',
|
||||
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
||||
)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the target_bucket does not exist' do
|
||||
|
@ -54,7 +54,7 @@ describe 'S3.copy_object' do
|
|||
'fogcopyobjectsource', 'fog_copy_object_source',
|
||||
'fognotabucket', 'fog_copy_object_destination'
|
||||
)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ describe 'S3.delete_bucket' do
|
|||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
s3.delete_bucket('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should raise a Conflict error if the bucket is not empty' do
|
||||
|
@ -27,7 +27,7 @@ describe 'S3.delete_bucket' do
|
|||
s3.put_object('fogdeletebucket', 'fog_delete_object', file)
|
||||
lambda {
|
||||
s3.delete_bucket('fogdeletebucket')
|
||||
}.should raise_error(Fog::Errors::Conflict)
|
||||
}.should raise_error(Excon::Errors::Conflict)
|
||||
s3.delete_object('fogdeletebucket', 'fog_delete_object')
|
||||
s3.delete_bucket('fogdeletebucket')
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ describe 'S3.delete_object' do
|
|||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
s3.delete_object('fognotabucket', 'fog_delete_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should not raise an error if the object does not exist' do
|
||||
|
|
|
@ -23,7 +23,7 @@ describe 'S3.get_bucket_location' do
|
|||
it 'should raise NotFound error if bucket does not exist' do
|
||||
lambda {
|
||||
s3.get_bucket_location('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -103,13 +103,13 @@ describe 'S3.get_bucket' do
|
|||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
s3.get_bucket('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should request non-subdomain buckets and raise a NotFound error' do
|
||||
lambda {
|
||||
s3.get_bucket('A-invalid--name')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -49,13 +49,13 @@ describe 'S3.get_object' do
|
|||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
s3.get_object('fognotabucket', 'fog_get_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
it 'should raise a NotFound error if the object does not exist' do
|
||||
lambda {
|
||||
s3.get_object('foggetobject', 'fog_not_an_object')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ describe 'S3.get_request_payment' do
|
|||
it 'should raise a NotFound error if the bucket does not exist' do
|
||||
lambda {
|
||||
s3.get_request_payment('fognotabucket')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ describe 'S3.put_object' do
|
|||
lambda {
|
||||
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
||||
s3.put_object('fognotabucket', 'fog_put_object', file)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ describe 'S3.put_request_payment' do
|
|||
it 'should raise a NotFound error if bucket does not exist' do
|
||||
lambda {
|
||||
s3.put_request_payment('fognotabucket', 'Requester')
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ describe 'SimpleDB.batch_put_attributes' do
|
|||
it 'should raise a BadRequest error if the domain does not exist' do
|
||||
lambda {
|
||||
sdb.batch_put_attributes('notadomain', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe 'SimpleDB.delete_attributes' do
|
|||
it 'shouild raise a BadRequest error if the domain does not exist' do
|
||||
lambda {
|
||||
sdb.delete_attributes('notadomain', 'notanattribute')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
it 'should not raise an error if the attribute does not exist' do
|
||||
|
|
|
@ -45,7 +45,7 @@ describe 'SimpleDB.domain_metadata' do
|
|||
it 'should raise a BadRequest error if the domain does not exist' do
|
||||
lambda {
|
||||
sdb.domain_metadata('notadomain')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ describe 'SimpleDB.get_attributes' do
|
|||
it 'should raise a BadRequest error if the domain does not exist' do
|
||||
lambda {
|
||||
sdb.get_attributes('notadomain', 'notanattribute')
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
it 'should not raise an error if the attribute does not exist' do
|
||||
|
|
|
@ -24,7 +24,7 @@ describe 'SimpleDB.put_attributes' do
|
|||
it 'should raise a BadRequest error if the domain does not exist' do
|
||||
lambda {
|
||||
sdb.put_attributes(@domain_name, 'notadomain', { 'notanattribute' => 'value' })
|
||||
}.should raise_error(Fog::Errors::BadRequest)
|
||||
}.should raise_error(Excon::Errors::BadRequest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ describe 'Rackspace::Servers.delete_server' do
|
|||
it "should raise a NotFound error if the server does not exist" do
|
||||
lambda {
|
||||
servers.delete_server(0)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ describe 'Rackspace::Servers.get_server_details' do
|
|||
it "should raise a NotFound error if the server does not exist" do
|
||||
lambda {
|
||||
servers.get_server_details(0)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue