Merge pull request #2538 from edekadigital/fix-sns-subscribe-sms-validation

Fix sns.subscribe validation for sms numbers
This commit is contained in:
Steve Pulec 2019-11-04 23:02:37 -06:00 committed by GitHub
commit b19abbc63e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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():