Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Add test for opted out recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudi Giesler committed Jan 20, 2015
1 parent 9596fbb commit e8ccb8d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions go/apps/http_api_nostream/tests/test_vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,32 @@ def test_send_to_with_evil_to_addr(self):
self.assert_bad_request(
response, "Invalid or missing value for payload key 'to_addr'")

@inlineCallbacks
def test_send_to_opted_out(self):
yield self.start_app_worker()
# Create optout for user
vumi_api = self.app_helper.vumi_helper.get_vumi_api()
optout_store = vumi_api.get_user_api(
self.conversation.user_account.key).optout_store
optout_store.new_opt_out('msisdn', '+5432', {'message_id': '111'})
msg = {
'to_addr': '+5432',
'content': 'foo',
'message_id': 'evil_id',
}

url = '%s/%s/messages.json' % (self.url, self.conversation.key)
response = yield http_request_full(url, json.dumps(msg),
self.auth_headers, method='PUT')

self.assertEqual(response.code, http.BAD_REQUEST)
self.assertEqual(
response.headers.getRawHeaders('content-type'),
['application/json; charset=utf-8'])
put_msg = json.loads(response.delivered_body)
self.assertEqual(put_msg['success'], False)
self.assertEqual(put_msg['reason'], 'Recipient has opted out')

@inlineCallbacks
def test_in_reply_to(self):
yield self.start_app_worker()
Expand Down

0 comments on commit e8ccb8d

Please sign in to comment.