Fix sns.subscribe validation for sms numbers

This commit is contained in:
gruebel 2019-11-04 22:57:53 +01:00
commit 58daa428f3
3 changed files with 28 additions and 10 deletions

View file

@ -19,7 +19,10 @@ def test_subscribe_sms():
arn = resp["TopicArn"]
resp = client.subscribe(TopicArn=arn, Protocol="sms", Endpoint="+15551234567")
resp.should.contain("SubscriptionArn")
resp.should.have.key("SubscriptionArn")
resp = client.subscribe(TopicArn=arn, Protocol="sms", Endpoint="+15/55-123.4567")
resp.should.have.key("SubscriptionArn")
@mock_sns
@ -51,6 +54,18 @@ def test_subscribe_bad_sms():
except ClientError as err:
err.response["Error"]["Code"].should.equal("InvalidParameter")
client.subscribe.when.called_with(
TopicArn=arn, Protocol="sms", Endpoint="+15--551234567"
).should.throw(ClientError, "Invalid SMS endpoint: +15--551234567")
client.subscribe.when.called_with(
TopicArn=arn, Protocol="sms", Endpoint="+15551234567."
).should.throw(ClientError, "Invalid SMS endpoint: +15551234567.")
client.subscribe.when.called_with(
TopicArn=arn, Protocol="sms", Endpoint="/+15551234567"
).should.throw(ClientError, "Invalid SMS endpoint: /+15551234567")
@mock_sns
def test_creating_subscription():