From 8ccc210eef4a5592bc97033a54ffb5833e47047e Mon Sep 17 00:00:00 2001 From: Kieran Doonan Date: Mon, 4 Jul 2016 11:01:48 +0100 Subject: [PATCH] added tests for encrypted ec2 volumes --- tests/test_ec2/test_elastic_block_store.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/test_ec2/test_elastic_block_store.py b/tests/test_ec2/test_elastic_block_store.py index 05a0e72d0..8eb421f3c 100644 --- a/tests/test_ec2/test_elastic_block_store.py +++ b/tests/test_ec2/test_elastic_block_store.py @@ -20,6 +20,7 @@ def test_create_and_delete_volume(): all_volumes.should.have.length_of(1) all_volumes[0].size.should.equal(80) all_volumes[0].zone.should.equal("us-east-1a") + all_volumes[0].encrypted.should.equal(False) volume = all_volumes[0] volume.delete() @@ -34,6 +35,15 @@ def test_create_and_delete_volume(): cm.exception.request_id.should_not.be.none +@mock_ec2 +def test_create_encrypted_volume(): + conn = boto.connect_ec2('the_key', 'the_secret') + conn.create_volume(80, "us-east-1a", encrypted=True) + + all_volumes = conn.get_all_volumes() + all_volumes[0].encrypted.should.equal(True) + + @mock_ec2 def test_filter_volume_by_id(): conn = boto.connect_ec2('the_key', 'the_secret') @@ -57,9 +67,9 @@ def test_volume_filters(): instance.update() - volume1 = conn.create_volume(80, "us-east-1a") - volume2 = conn.create_volume(36, "us-east-1b") - volume3 = conn.create_volume(20, "us-east-1c") + volume1 = conn.create_volume(80, "us-east-1a", encrypted=True) + volume2 = conn.create_volume(36, "us-east-1b", encrypted=False) + volume3 = conn.create_volume(20, "us-east-1c", encrypted=False) snapshot = volume3.create_snapshot(description='testsnap') volume4 = conn.create_volume(25, "us-east-1a", snapshot=snapshot) @@ -107,6 +117,9 @@ def test_volume_filters(): volumes_by_tag = conn.get_all_volumes(filters={'tag:testkey1': 'testvalue1'}) set([vol.id for vol in volumes_by_tag]).should.equal(set([volume1.id])) + volumes_by_encrypted = conn.get_all_volumes(filters={'encrypted': 'true'}) + set([vol.id for vol in volumes_by_encrypted]).should.equal(set([volume1.id])) + @mock_ec2 def test_volume_attach_and_detach(): @@ -208,7 +221,7 @@ def test_snapshot_filters(): snapshot1 = volume1.create_snapshot(description='testsnapshot1') snapshot2 = volume1.create_snapshot(description='testsnapshot2') snapshot3 = volume2.create_snapshot(description='testsnapshot3') - + conn.create_tags([snapshot1.id], {'testkey1': 'testvalue1'}) conn.create_tags([snapshot2.id], {'testkey2': 'testvalue2'})