mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
volume#key_id and encrypted tests
This commit is contained in:
parent
2ca24dcbdf
commit
5693a9cf2f
5 changed files with 75 additions and 43 deletions
|
@ -9,10 +9,11 @@ module Fog
|
|||
attribute :created_at, :aliases => 'createTime'
|
||||
attribute :delete_on_termination, :aliases => 'deleteOnTermination'
|
||||
attribute :device
|
||||
attribute :encrypted
|
||||
attribute :key_id, :aliases => ['KmsKeyId', 'kmsKeyId']
|
||||
attribute :iops
|
||||
attribute :server_id, :aliases => 'instanceId'
|
||||
attribute :size
|
||||
attribute :encrypted
|
||||
attribute :snapshot_id, :aliases => 'snapshotId'
|
||||
attribute :state, :aliases => 'status'
|
||||
attribute :tags, :aliases => 'tagSet'
|
||||
|
@ -44,9 +45,8 @@ module Fog
|
|||
requires :iops
|
||||
end
|
||||
|
||||
data = service.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops, 'Encrypted' => encrypted).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
data = service.create_volume(availability_zone, size, create_params).body
|
||||
merge_attributes(data)
|
||||
|
||||
if tags = self.tags
|
||||
# expect eventual consistency
|
||||
|
@ -118,6 +118,16 @@ module Fog
|
|||
reload
|
||||
end
|
||||
end
|
||||
|
||||
def create_params
|
||||
{
|
||||
'Encrypted' => encrypted,
|
||||
'KmsKeyId' => key_id,
|
||||
'Iops' => iops,
|
||||
'SnapshotId' => snapshot_id,
|
||||
'VolumeType' => type
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
class CreateVolume < Fog::Parsers::Base
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'availabilityZone', 'requestId', 'snapshotId', 'status', 'volumeId', 'volumeType'
|
||||
when 'availabilityZone', 'requestId', 'snapshotId', 'status', 'volumeId', 'volumeType', 'kmsKeyId'
|
||||
@response[name] = value
|
||||
when 'createTime'
|
||||
@response[name] = Time.parse(value)
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
@attachment[name] = Time.parse(value)
|
||||
when 'deleteOnTermination'
|
||||
@attachment[name] = value == 'true'
|
||||
when 'device', 'instanceId', 'status', 'volumeId'
|
||||
when 'device', 'instanceId', 'status', 'volumeId', 'kmsKeyId'
|
||||
@attachment[name] = value
|
||||
when 'item'
|
||||
@volume['attachmentSet'] << @attachment
|
||||
|
|
|
@ -87,6 +87,10 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
if options['KmsKeyId'] && !options['Encrypted']
|
||||
raise Fog::Compute::AWS::Error.new("InvalidParameterDependency => The parameter KmsKeyId requires the parameter Encrypted to be set.")
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
volume_id = Fog::AWS::Mock.volume_id
|
||||
data = {
|
||||
|
@ -97,6 +101,7 @@ module Fog
|
|||
'encrypted' => options['Encrypted'] || false,
|
||||
'size' => size,
|
||||
'snapshotId' => options['SnapshotId'],
|
||||
'kmsKeyId' => options['KmsKeyId'] || nil, # @todo validate
|
||||
'status' => 'creating',
|
||||
'volumeId' => volume_id,
|
||||
'volumeType' => options['VolumeType'] || 'standard'
|
||||
|
|
|
@ -59,6 +59,7 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|||
'iops' => Fog::Nullable::Integer,
|
||||
'size' => Integer,
|
||||
'snapshotId' => Fog::Nullable::String,
|
||||
'kmsKeyId' => Fog::Nullable::String,
|
||||
'status' => String,
|
||||
'tagSet' => Hash,
|
||||
'volumeId' => String,
|
||||
|
@ -83,7 +84,11 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|||
|
||||
tests('#create_volume from snapshot').formats(@volume_format) do
|
||||
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
||||
volume.wait_for { ready? }
|
||||
|
||||
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
||||
Fog::Compute[:aws].snapshots.new(snapshot).wait_for { ready? }
|
||||
|
||||
data = Fog::Compute[:aws].create_volume(@server.availability_zone, nil, 'SnapshotId' => snapshot['snapshotId']).body
|
||||
@volume_id = data['volumeId']
|
||||
data
|
||||
|
@ -99,9 +104,21 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|||
|
||||
Fog::Compute[:aws].delete_volume(@volume_id)
|
||||
|
||||
tests('#create_volume with encryption').returns(true) do
|
||||
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1, :encrypted => true)
|
||||
@volume_id = volume.id
|
||||
volume.reload.encrypted
|
||||
end
|
||||
|
||||
Fog::Compute[:aws].delete_volume(@volume_id)
|
||||
|
||||
tests('#create_volume from snapshot with size').formats(@volume_format) do
|
||||
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
||||
volume.wait_for { ready? }
|
||||
|
||||
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
||||
Fog::Compute[:aws].snapshots.new(snapshot).wait_for { ready? }
|
||||
|
||||
data = Fog::Compute[:aws].create_volume(@server.availability_zone, 1, 'SnapshotId' => snapshot['snapshotId']).body
|
||||
@volume_id = data['volumeId']
|
||||
data
|
||||
|
|
Loading…
Reference in a new issue