Disallow termination of protected EMR job flows (#4015)

Error message verified against real AWS backend.
This commit is contained in:
Brian Pandola 2021-06-17 04:20:45 -07:00 committed by GitHub
commit b0e2a750dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 5 deletions

View file

@ -708,6 +708,25 @@ def test_set_termination_protection():
resp["Cluster"]["TerminationProtected"].should.equal(expected)
@mock_emr
def test_terminate_protected_job_flow_raises_error():
client = boto3.client("emr", region_name="us-east-1")
resp = client.run_job_flow(**run_job_flow_args)
cluster_id = resp["JobFlowId"]
client.set_termination_protection(
JobFlowIds=[cluster_id], TerminationProtected=True
)
with pytest.raises(ClientError) as ex:
client.terminate_job_flows(
JobFlowIds=[cluster_id,]
)
error = ex.value.response["Error"]
error["Code"].should.equal("ValidationException")
error["Message"].should.equal(
"Could not shut down one or more job flows since they are termination protected."
)
@mock_emr
def test_set_visible_to_all_users():
client = boto3.client("emr", region_name="us-east-1")