1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Remove pending on iam/server_certificate_tests. Start the mocking.

This commit is contained in:
Dylan Egan 2011-07-06 14:23:41 -07:00
parent 0019667ce6
commit 796c5c8809
4 changed files with 64 additions and 11 deletions

View file

@ -43,11 +43,36 @@ module Fog
request :upload_signing_certificate
class Mock
def initialize(options={})
Fog::Mock.not_implemented
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {
:owner_id => Fog::AWS::Mock.owner_id,
:server_certificates => {}
}
end
end
def self.reset
@data = nil
end
def self.server_certificate_id
Fog::Mock.random_hex(16)
end
def initialize(options={})
require 'fog/aws/parsers/iam/basic'
@aws_access_key_id = options[:aws_access_key_id]
end
def data
self.class.data[@aws_access_key_id]
end
def reset_data
self.class.data.delete(@aws_access_key_id)
end
end
class Real

View file

@ -19,11 +19,12 @@ module Fog
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'UploadServerCertificateResult'<~Hash>:
# * 'CertificateId'<~String> -
# * 'UserName'<~String> -
# * 'CertificateBody'<~String> -
# * 'Status'<~String> -
# * 'Certificate'<~Hash>:
# * 'Arn'<~String> -
# * 'Path'<~String> -
# * 'ServerCertificateId'<~String> -
# * 'ServerCertificateName'<~String> -
# * 'UploadDate'<~Time>
# * 'RequestId'<~String> - Id of the request
#
# ==== See Also
@ -40,6 +41,32 @@ module Fog
end
end
class Mock
def upload_server_certificate(certificate, private_key, name, options = {})
response = Excon::Response.new
if self.data[:server_certificates][name]
else
response.status = 200
path = "server-certificates/#{name}"
data = {
'Arn' => Fog::AWS::Mock.arn('iam', self.data[:owner_id], path),
'Path' => path,
'ServerCertificateId' => Fog::AWS::IAM::Mock.server_certificate_id,
'ServerCertificateName' => name,
'UploadDate' => Time.now
}
self.data[:server_certificates][name] = data
response.body = {
'Certificate' => data,
'RequestId' => Fog::AWS::Mock.request_id
}
end
response
end
end
end
end
end

View file

@ -71,6 +71,10 @@ module Fog
class Mock
def self.arn(vendor, account_id, path, region = nil)
"arn:aws:#{vendor}:#{region}:#{account_id}:#{path}"
end
def self.availability_zone(region)
"#{region}#{Fog::Mock.random_selection('abcd', 1)}"
end

View file

@ -1,7 +1,4 @@
Shindo.tests('AWS::IAM | server certificate requests', ['aws']) do
pending if Fog.mocking?
@key_name = 'fog-test'
@certificate_format = {