Merge pull request #2442 from titibike/sns_subscription_attributes

Issue #2441 Add informations in SNS subscriptions `attributes`
This commit is contained in:
Mike Grima 2019-10-15 10:05:20 -07:00 committed by GitHub
commit 4da9ec1346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -343,6 +343,14 @@ class SNSBackend(BaseBackend):
return old_subscription
topic = self.get_topic(topic_arn)
subscription = Subscription(topic, endpoint, protocol)
attributes = {
'PendingConfirmation': 'false',
'Endpoint': endpoint,
'TopicArn': topic_arn,
'Protocol': protocol,
'SubscriptionArn': subscription.arn
}
subscription.attributes = attributes
self.subscriptions[subscription.arn] = subscription
return subscription

View File

@ -181,6 +181,35 @@ def test_subscription_paging():
int(DEFAULT_PAGE_SIZE / 3))
topic1_subscriptions.shouldnt.have("NextToken")
@mock_sns
def test_subscribe_attributes():
client = boto3.client('sns', region_name='us-east-1')
client.create_topic(Name="some-topic")
resp = client.create_topic(Name="some-topic")
arn = resp['TopicArn']
resp = client.subscribe(
TopicArn=arn,
Protocol='http',
Endpoint='http://test.com'
)
attributes = client.get_subscription_attributes(
SubscriptionArn=resp['SubscriptionArn']
)
attributes.should.contain('Attributes')
attributes['Attributes'].should.contain('PendingConfirmation')
attributes['Attributes']['PendingConfirmation'].should.equal('false')
attributes['Attributes'].should.contain('Endpoint')
attributes['Attributes']['Endpoint'].should.equal('http://test.com')
attributes['Attributes'].should.contain('TopicArn')
attributes['Attributes']['TopicArn'].should.equal(arn)
attributes['Attributes'].should.contain('Protocol')
attributes['Attributes']['Protocol'].should.equal('http')
attributes['Attributes'].should.contain('SubscriptionArn')
attributes['Attributes']['SubscriptionArn'].should.equal(resp['SubscriptionArn'])
@mock_sns
def test_creating_subscription_with_attributes():