Fix: redshift:EnableSnapshotCopy raises incorrect Exception (#3485)
The previous code was trying to raise a botocore ClientError directly, which was actually generating a secondary AttributeError because the arguments passed to ClientError() were incorrect. This replaces the ClientError() call with a proper moto exception class for Redshift and fixes the test assertions appropriately. Supersedes #1957
This commit is contained in:
parent
689cd8f285
commit
4245497a97
@ -573,10 +573,8 @@ class RedshiftBackend(BaseBackend):
|
|||||||
cluster.encrypted == "true"
|
cluster.encrypted == "true"
|
||||||
and kwargs["snapshot_copy_grant_name"] is None
|
and kwargs["snapshot_copy_grant_name"] is None
|
||||||
):
|
):
|
||||||
raise ClientError(
|
raise InvalidParameterValueError(
|
||||||
"InvalidParameterValue",
|
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
||||||
"SnapshotCopyGrantName is required for Snapshot Copy "
|
|
||||||
"on KMS encrypted clusters.",
|
|
||||||
)
|
)
|
||||||
status = {
|
status = {
|
||||||
"DestinationRegion": kwargs["destination_region"],
|
"DestinationRegion": kwargs["destination_region"],
|
||||||
|
@ -12,6 +12,7 @@ from boto.redshift.exceptions import (
|
|||||||
InvalidSubnet,
|
InvalidSubnet,
|
||||||
)
|
)
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
from moto import mock_ec2
|
from moto import mock_ec2
|
||||||
@ -1260,6 +1261,14 @@ def test_enable_snapshot_copy():
|
|||||||
MasterUserPassword="password",
|
MasterUserPassword="password",
|
||||||
NodeType="ds2.xlarge",
|
NodeType="ds2.xlarge",
|
||||||
)
|
)
|
||||||
|
with pytest.raises(ClientError) as ex:
|
||||||
|
client.enable_snapshot_copy(
|
||||||
|
ClusterIdentifier="test", DestinationRegion="us-west-2", RetentionPeriod=3,
|
||||||
|
)
|
||||||
|
ex.value.response["Error"]["Code"].should.equal("InvalidParameterValue")
|
||||||
|
ex.value.response["Error"]["Message"].should.contain(
|
||||||
|
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
||||||
|
)
|
||||||
client.enable_snapshot_copy(
|
client.enable_snapshot_copy(
|
||||||
ClusterIdentifier="test",
|
ClusterIdentifier="test",
|
||||||
DestinationRegion="us-west-2",
|
DestinationRegion="us-west-2",
|
||||||
|
Loading…
Reference in New Issue
Block a user