Compare commits

...

2 Commits

Author SHA1 Message Date
Thomas NOËL 266bbff89f Jenkinsfile: build hotfix for all dists
gitea-wip/passerelle/pipeline/head There was a failure building this commit Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details
2020-09-25 16:35:11 +02:00
Thomas NOËL 06ac4e4c40 sms: allow nostop parameter (#47034) 2020-09-25 16:25:36 +02:00
3 changed files with 20 additions and 3 deletions

2
Jenkinsfile vendored
View File

@ -29,7 +29,7 @@ pipeline {
if (env.JOB_NAME == 'passerelle' && env.GIT_BRANCH == 'origin/master') {
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder passerelle'
} else if (env.GIT_BRANCH.startsWith('hotfix/')) {
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d stretch --branch ${env.GIT_BRANCH} --hotfix passerelle"
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder --branch ${env.GIT_BRANCH} --hotfix passerelle"
}
}
}

View File

@ -87,12 +87,13 @@ class SMSResource(BaseResource):
@endpoint(perm='can_send_messages', methods=['post'],
description=_('Send a SMS message'),
parameters={'nostop': {'description': _('Do not send STOP instruction'), 'example_value': '1'}},
post={'request_body': {'schema': {'application/json': SEND_SCHEMA}}})
def send(self, request, post_data):
def send(self, request, post_data, nostop=None):
post_data['message'] = post_data['message'][:self.max_message_length]
post_data['to'] = self.clean_numbers(post_data['to'])
logging.info('sending SMS to %r from %r', post_data['to'], post_data['from'])
stop = not bool('nostop' in request.GET)
stop = nostop is None # ?nostop in not in query string
self.add_job('send_job',
text=post_data['message'], sender=post_data['from'], destinations=post_data['to'],
stop=stop)

View File

@ -167,6 +167,22 @@ def test_sms_log(app, connector):
assert SMSLog.objects.filter(appname=connector.get_connector_slug(), slug=connector.slug).exists()
def test_sms_nostop_parameter(app, connector):
base_path = '/%s/%s/send/?nostop=1' % (connector.get_connector_slug(), connector.slug)
payload = {
'message': 'not a spam',
'from': '+33699999999',
'to': ['+33688888888'],
}
for path in (base_path, base_path + '?nostop=1', base_path + '?nostop=foo', base_path + '?nostop'):
with mock.patch.object(connector, 'send_msg') as send_function:
send_function.return_value = {}
result = app.post_json(base_path, params=payload)
connector.jobs()
assert send_function.call_args[1]['text'] == 'not a spam'
assert send_function.call_args[1]['stop'] == ('nostop' not in path)
def test_ovh_new_api(app, freezer):
connector = OVHSMSGateway.objects.create(
slug='ovh', account='sms-test42', username='john',