Skip to content

Commit bfae5db

Browse files
Tankanowhaotianw465
authored andcommitted
Resolves #84: Whitelist TopicArn for SNS Publish Operation (#93)
* ISSUE-84: Whitelist TopicArn for SNS Publish Operation * ISSUE-84: Test sns Publish parameters
1 parent 3038610 commit bfae5db

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

aws_xray_sdk/ext/resources/aws_para_whitelist.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"services": {
3+
"sns": {
4+
"operations": {
5+
"Publish": {
6+
"request_parameters": [
7+
"TopicArn"
8+
]
9+
}
10+
}
11+
},
312
"dynamodb": {
413
"operations": {
514
"BatchGetItem": {

tests/ext/botocore/test_botocore.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,26 @@ def test_pass_through_on_context_missing():
150150
assert result is not None
151151

152152
xray_recorder.configure(context_missing='RUNTIME_ERROR')
153+
154+
155+
def test_sns_publish_parameters():
156+
sns = session.create_client('sns', region_name='us-west-2')
157+
response = {
158+
'ResponseMetadata': {
159+
'RequestId': REQUEST_ID,
160+
'HTTPStatusCode': 200,
161+
}
162+
}
163+
164+
with Stubber(sns) as stubber:
165+
stubber.add_response('publish', response, {'TopicArn': 'myAmazingTopic', 'Message': 'myBodaciousMessage'})
166+
sns.publish(TopicArn='myAmazingTopic', Message='myBodaciousMessage')
167+
168+
subsegment = xray_recorder.current_segment().subsegments[0]
169+
assert subsegment.http['response']['status'] == 200
170+
171+
aws_meta = subsegment.aws
172+
assert aws_meta['topic_arn'] == 'myAmazingTopic'
173+
assert aws_meta['request_id'] == REQUEST_ID
174+
assert aws_meta['region'] == 'us-west-2'
175+
assert aws_meta['operation'] == 'Publish'

0 commit comments

Comments
 (0)