2021-12-19 14:27:23 +00:00
|
|
|
import boto3
|
|
|
|
|
2024-01-07 12:03:33 +00:00
|
|
|
from moto import mock_aws
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
|
2024-01-07 12:03:33 +00:00
|
|
|
@mock_aws
|
2021-12-19 14:27:23 +00:00
|
|
|
def test_disable_ebs_encryption_by_default():
|
|
|
|
ec2 = boto3.client("ec2", "eu-central-1")
|
|
|
|
|
|
|
|
ec2.enable_ebs_encryption_by_default()
|
|
|
|
response = ec2.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert response["EbsEncryptionByDefault"] is True
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
ec2.disable_ebs_encryption_by_default()
|
|
|
|
after_disable_response = ec2.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert after_disable_response["EbsEncryptionByDefault"] is False
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
|
2024-01-07 12:03:33 +00:00
|
|
|
@mock_aws
|
2021-12-19 14:27:23 +00:00
|
|
|
def test_enable_ebs_encryption_by_default():
|
|
|
|
ec2 = boto3.client("ec2", region_name="eu-central-1")
|
|
|
|
response = ec2.enable_ebs_encryption_by_default()
|
|
|
|
|
|
|
|
ec2.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert response["EbsEncryptionByDefault"] is True
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
|
2024-01-07 12:03:33 +00:00
|
|
|
@mock_aws
|
2021-12-19 14:27:23 +00:00
|
|
|
def test_get_ebs_encryption_by_default():
|
|
|
|
ec2 = boto3.client("ec2", region_name="eu-west-1")
|
|
|
|
|
|
|
|
response = ec2.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert response["EbsEncryptionByDefault"] is False
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
|
2024-01-07 12:03:33 +00:00
|
|
|
@mock_aws
|
2021-12-19 14:27:23 +00:00
|
|
|
def test_enable_ebs_encryption_by_default_region():
|
|
|
|
ec2_eu = boto3.client("ec2", region_name="eu-central-1")
|
|
|
|
ec2_eu.enable_ebs_encryption_by_default()
|
|
|
|
|
|
|
|
response = ec2_eu.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert response["EbsEncryptionByDefault"] is True
|
2021-12-19 14:27:23 +00:00
|
|
|
|
|
|
|
ec2_us = boto3.client("ec2", region_name="us-east-1")
|
|
|
|
response = ec2_us.get_ebs_encryption_by_default()
|
2023-07-17 09:31:05 +00:00
|
|
|
assert response["EbsEncryptionByDefault"] is False
|