mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'master' into rs_lb
This commit is contained in:
commit
657b36e795
15 changed files with 135 additions and 63 deletions
|
@ -6,6 +6,7 @@ module Fog
|
|||
class KeyPairMismatch < Fog::AWS::IAM::Error; end
|
||||
class LimitExceeded < Fog::AWS::IAM::Error; end
|
||||
class MalformedCertificate < Fog::AWS::IAM::Error; end
|
||||
class ValidationError < Fog::AWS::IAM::Error; end
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :host, :path, :port, :scheme, :persistent
|
||||
|
@ -155,14 +156,8 @@ module Fog
|
|||
case match[1]
|
||||
when 'CertificateNotFound', 'NoSuchEntity'
|
||||
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
|
||||
when 'EntityAlreadyExists'
|
||||
raise Fog::AWS::IAM::EntityAlreadyExists.slurp(error, match[2])
|
||||
when 'KeyPairMismatch'
|
||||
raise Fog::AWS::IAM::KeyPairMismatch.slurp(error, match[2])
|
||||
when 'LimitExceeded'
|
||||
raise Fog::AWS::IAM::LimitExceeded.slurp(error, match[2])
|
||||
when 'MalformedCertificate'
|
||||
raise Fog::AWS::IAM::MalformedCertificate.slurp(error, match[2])
|
||||
when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError'
|
||||
raise Fog::AWS::IAM.const_get(match[1]).slurp(error, match[2])
|
||||
else
|
||||
raise Fog::AWS::IAM::Error.slurp(error, "#{match[1]} => #{match[2]}") if match[1]
|
||||
raise
|
||||
|
|
|
@ -19,11 +19,11 @@ module Fog
|
|||
dimensions_array = dimensions.collect do |name, value|
|
||||
{'Name' => name, 'Value' => value}
|
||||
end
|
||||
puts dimensions_array.inspect
|
||||
# list_opts.merge!('Dimensions' => dimensions_array)
|
||||
end
|
||||
data = connection.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first
|
||||
new(data)
|
||||
if data = connection.list_metrics(list_opts).body['ListMetricsResult']['Metrics'].first
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -44,9 +44,30 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def upload_server_certificate(certificate, private_key, name, options = {})
|
||||
if certificate.nil? || certificate.empty? || private_key.nil? || private_key.empty?
|
||||
raise Fog::AWS::IAM::ValidationError.new
|
||||
end
|
||||
response = Excon::Response.new
|
||||
|
||||
# Validate cert and key
|
||||
begin
|
||||
cert = OpenSSL::X509::Certificate.new(certificate)
|
||||
key = OpenSSL::PKey::RSA.new(private_key)
|
||||
rescue OpenSSL::X509::CertificateError, OpenSSL::PKey::RSAError => e
|
||||
message = if e.is_a?(OpenSSL::X509::CertificateError)
|
||||
"Invalid Public Key Certificate."
|
||||
else
|
||||
"Invalid Private Key."
|
||||
end
|
||||
raise Fog::AWS::IAM::MalformedCertificate.new(message)
|
||||
end
|
||||
|
||||
unless cert.check_private_key(key)
|
||||
raise Fog::AWS::IAM::KeyPairMismatch.new
|
||||
end
|
||||
|
||||
if self.data[:server_certificates][name]
|
||||
raise Fog::AWS::IAM::EntityAlreadyExists.new
|
||||
else
|
||||
response.status = 200
|
||||
path = "server-certificates/#{name}"
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :directory, :key
|
||||
connection.delete_namespace(directory.key + key)
|
||||
connection.delete_namespace([directory.key, key].join('/'))
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Shindo.tests('AWS::AutoScaling | activities', ['aws', 'auto_scaling_m']) do
|
||||
|
||||
pending # FIXME: activity#save is not implemented
|
||||
collection_tests(AWS[:auto_scaling].activities, {}, false)
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Shindo.tests('AWS::AutoScaling | instances', ['aws', 'auto_scaling_m']) do
|
||||
|
||||
collection_tests(AWS[:auto_scaling].instances, {}, false)
|
||||
pending # FIXME: instance#save is not defined
|
||||
#collection_tests(AWS[:auto_scaling].instances, {}, false)
|
||||
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
Shindo.tests("AWS::CloudWatch | metrics", ['aws', 'cloudwatch']) do
|
||||
|
||||
tests('success') do
|
||||
pending if Fog.mocking?
|
||||
|
||||
pending # FIXME: the hardcoded instance id won't be available
|
||||
tests("#all").succeeds do
|
||||
AWS[:cloud_watch].metrics.all
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ Shindo.tests("AWS::RDS | security_group", ['aws', 'rds']) do
|
|||
tests("#description").returns('fog test') { @instance.description }
|
||||
|
||||
tests("#authorize_ec2_security_group").succeeds do
|
||||
@ec2_sec_group = Compute[:aws].security_groups.create(:name => 'fog-test', :description => 'fog test')
|
||||
@ec2_sec_group = Fog::Compute[:aws].security_groups.create(:name => 'fog-test', :description => 'fog test')
|
||||
|
||||
@instance.authorize_ec2_security_group(@ec2_sec_group.name)
|
||||
returns('authorizing') do
|
||||
|
|
|
@ -85,7 +85,7 @@ Shindo.tests('AWS::CloudFormation | stack requests', ['aws', 'cloudformation'])
|
|||
|
||||
unless Fog.mocking?
|
||||
@stack_name = 'fogstack' << Time.now.to_i.to_s
|
||||
@keypair = Compute[:aws].key_pairs.create(:name => 'cloudformation')
|
||||
@keypair = Fog::Compute[:aws].key_pairs.create(:name => 'cloudformation')
|
||||
@template_url = 'https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2InstanceSample-1.0.0.template'
|
||||
end
|
||||
|
||||
|
|
|
@ -41,6 +41,35 @@ c0AQtoYBTJePxiYyd8i32ypkkK83ar+sFoxKO9jYwD1IkZax2xZ0aoTdMindQPR7
|
|||
Yjs+QiLmOHcbPqX+GHcCQERsSn0RjzKmKirDntseMB59BB/cEN32+gMDVsZuCfb+
|
||||
fOy2ZavFl13afnhbh2/AjKeDhnb19x/uXjF7JCUtwpA=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
}
|
||||
|
||||
SERVER_CERT_PRIV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e2B+1oemPJm26G
|
||||
PfqKgxdKX0R0jl4f5pRBWKoarzWtUge/su8rx/xzbY/1hFKVuimtc6oTeU5xsOTS
|
||||
PVuCz4bxDTVhrbmKqbmMgqy17jfPA4BrF1FMRS0CgYBdMA4i4vQ6fIxKfOUIMsfs
|
||||
hsJn01RAbHXRwu2wMgnayMDQgEKwjtFO1GaN0rA9bXFXQ/1pET/HiJdn7qIKJihP
|
||||
aheO9rHrMdSdsx4AUTaWummtYUhiWobsuwRApeMEmQSKd0yhaI3+KVwkOQoSDbBi
|
||||
oKkE6gUzk7IPt4UuSUD5kwKBgQCjo/IGr8dieegz08gDhF4PfalLdJ4ATaxTHMOH
|
||||
sVFs6SY7Sy72Ou//qGRCcmsAW9KL35nkvw3S2Ukiz9lTGATxqC/93WIPxvMhy5Zc
|
||||
dcLT43XtXdanW5OWqBlGDEFu0O6OERIyoqUVRC1Ss2kUwdbWPbq/id5Qjbd7RoYa
|
||||
cxyt9QKBgF4bFLw1Iw2RBngQxIzoDbElEqme20FUyGGzyFQtxVwmwNr4OY5UzJzX
|
||||
7G6diyzGrvRX81Yw616ppKJUJVr/zRc13K+eRXXKtNpGkf35B+1NDDjjWZpIHqgx
|
||||
Xb9WSr07saxZQbxBPQyTlb0Q9Tu2djAq2/o/nYD1/50/fXUTuWMB
|
||||
-----END RSA PRIVATE KEY-----
|
||||
}
|
||||
|
||||
module Formats
|
||||
|
|
|
@ -52,8 +52,8 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do
|
|||
tests('failure') do
|
||||
tests('get login profile for non existing user') do
|
||||
pending if Fog.mocking?
|
||||
raises(Excon::Errors::NotFound) { AWS[:iam].get_login_profile('idontexist')}
|
||||
raises(Excon::Errors::NotFound) { AWS[:iam].delete_login_profile('fog_user')}
|
||||
raises(Fog::AWS::IAM::NotFound) { AWS[:iam].get_login_profile('idontexist')}
|
||||
raises(Fog::AWS::IAM::NotFound) { AWS[:iam].delete_login_profile('fog_user')}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,10 +13,38 @@ Shindo.tests('AWS::IAM | server certificate requests', ['aws']) do
|
|||
'RequestId' => String
|
||||
}
|
||||
|
||||
tests('#upload_server_certificate').formats(@upload_format) do
|
||||
tests('#upload_server_certificate') do
|
||||
public_key = AWS::IAM::SERVER_CERT_PUBLIC_KEY
|
||||
private_key = AWS::IAM::SERVER_CERT_PRIVATE_KEY
|
||||
AWS[:iam].upload_server_certificate(public_key, private_key, @key_name).body
|
||||
private_key_mismatch = AWS::IAM::SERVER_CERT_PRIVATE_KEY_MISMATCHED
|
||||
|
||||
tests('empty public key').raises(Fog::AWS::IAM::ValidationError) do
|
||||
AWS[:iam].upload_server_certificate('', private_key, @key_name)
|
||||
end
|
||||
|
||||
tests('empty private key').raises(Fog::AWS::IAM::ValidationError) do
|
||||
AWS[:iam].upload_server_certificate(public_key, '', @key_name)
|
||||
end
|
||||
|
||||
tests('invalid public key').raises(Fog::AWS::IAM::MalformedCertificate) do
|
||||
AWS[:iam].upload_server_certificate('abcde', private_key, @key_name)
|
||||
end
|
||||
|
||||
tests('invalid private key').raises(Fog::AWS::IAM::MalformedCertificate) do
|
||||
AWS[:iam].upload_server_certificate(public_key, 'abcde', @key_name)
|
||||
end
|
||||
|
||||
tests('mismatched private key').raises(Fog::AWS::IAM::KeyPairMismatch) do
|
||||
AWS[:iam].upload_server_certificate(public_key, private_key_mismatch, @key_name)
|
||||
end
|
||||
|
||||
tests('format').formats(@upload_format) do
|
||||
AWS[:iam].upload_server_certificate(public_key, private_key, @key_name).body
|
||||
end
|
||||
|
||||
tests('duplicate name').raises(Fog::AWS::IAM::EntityAlreadyExists) do
|
||||
AWS[:iam].upload_server_certificate(public_key, private_key, @key_name)
|
||||
end
|
||||
end
|
||||
|
||||
tests('#get_server_certificate').formats(@upload_format) do
|
||||
|
|
|
@ -90,6 +90,7 @@ class AWS
|
|||
'EngineVersion' => String,
|
||||
'InstanceCreateTime' => Fog::Nullable::Time,
|
||||
'LatestRestorableTime' => Fog::Nullable::Time,
|
||||
'LicenseModel' => String,
|
||||
'MasterUsername' => String,
|
||||
'MultiAZ' => Fog::Boolean,
|
||||
'PendingModifiedValues' => {
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
if storage_providers.keys.include? :ninefold
|
||||
for provider, config in storage_providers
|
||||
|
||||
Shindo.tests("Storage[:ninefold] | nested directories", [provider]) do
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("update a file").succeeds do
|
||||
pending if Fog.mocking?
|
||||
dir = ninefold.directories.create(:key => 'updatefiletests')
|
||||
f = dir.files.create(:key => 'lorem.txt', :body => lorem_file)
|
||||
f.body = "xxxxxx"
|
||||
f.save
|
||||
end
|
||||
end
|
||||
Shindo.tests("Storage[:ninefold] | nested directories", ['ninefold']) do
|
||||
|
||||
unless Fog.mocking?
|
||||
@directory = Fog::Storage[:ninefold].directories.create(:key => 'updatefiletests')
|
||||
end
|
||||
end
|
||||
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("update a file").succeeds do
|
||||
pending if Fog.mocking?
|
||||
file = @directory.files.create(:key => 'lorem.txt', :body => lorem_file)
|
||||
file.body = "xxxxxx"
|
||||
file.save
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
@directory.destroy(:recursive => true)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,29 +1,23 @@
|
|||
if storage_providers.keys.include? :ninefold
|
||||
for provider, config in storage_providers
|
||||
|
||||
Shindo.tests("Storage[:ninefold] | nested directories", [provider]) do
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("create a directory with a / character").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.create(:key => 'sub/path')
|
||||
end
|
||||
|
||||
tests("List of top directory returns sub dir").returns(1) do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').directories.count
|
||||
end
|
||||
|
||||
tests("create a directory in a sub dir").returns('sub/path/newdir/') do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub/path').directories.create(:key => 'newdir').identity
|
||||
end
|
||||
|
||||
tests("Recursively destroy parent dir").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').destroy(:recursive => true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Shindo.tests("Storage[:ninefold] | nested directories", ['ninefold']) do
|
||||
ninefold = Fog::Storage[:ninefold]
|
||||
tests("create a directory with a / character").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.create(:key => 'sub/path')
|
||||
end
|
||||
end
|
||||
|
||||
tests("List of top directory returns sub dir").returns(1) do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').directories.count
|
||||
end
|
||||
|
||||
tests("create a directory in a sub dir").returns('sub/path/newdir/') do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub/path').directories.create(:key => 'newdir').identity
|
||||
end
|
||||
|
||||
tests("Recursively destroy parent dir").succeeds do
|
||||
pending if Fog.mocking?
|
||||
ninefold.directories.get('sub').destroy(:recursive => true)
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue