0001-sms-allow-space-on-input-destiation-number-48864.patch
passerelle/sms/models.py | ||
---|---|---|
39 | 39 |
'description': 'Sender number', |
40 | 40 |
'type': 'string', |
41 | 41 |
}, |
42 | 42 |
'to': { |
43 | 43 |
'description': 'Destination numbers', |
44 | 44 |
"type": "array", |
45 | 45 |
"items": { |
46 | 46 |
'type': 'string', |
47 |
'pattern': r'^\+?\d+$'
|
|
47 |
'pattern': r'^\+?[\s\d]+$'
|
|
48 | 48 |
}, |
49 | 49 |
}, |
50 | 50 |
} |
51 | 51 |
} |
52 | 52 | |
53 | 53 | |
54 | 54 |
class SMSResource(BaseResource): |
55 | 55 |
category = _('SMS Providers') |
tests/test_sms.py | ||
---|---|---|
185 | 185 |
with mock.patch.object(connector, 'send_msg') as send_function: |
186 | 186 |
send_function.return_value = {} |
187 | 187 |
result = app.post_json(base_path, params=payload) |
188 | 188 |
connector.jobs() |
189 | 189 |
assert send_function.call_args[1]['text'] == 'not a spam' |
190 | 190 |
assert send_function.call_args[1]['stop'] == ('nostop' not in path) |
191 | 191 | |
192 | 192 | |
193 | ||
194 |
@pytest.mark.parametrize('connector', [OVHSMSGateway], indirect=True) |
|
195 |
def test_send_schema(app, connector): |
|
196 |
base_path = '/%s/%s/send/' % (connector.get_connector_slug(), connector.slug) |
|
197 |
payload = { |
|
198 |
'message': 'not a spam', |
|
199 |
'from': '+33699999999', |
|
200 |
'to': ['06 12 34 56 78'], |
|
201 |
} |
|
202 |
with mock.patch.object(connector, 'send_msg') as send_function: |
|
203 |
app.post_json(base_path, params=payload) |
|
204 |
connector.jobs() |
|
205 |
assert send_function.call_args[1]['destinations'] == ['0033612345678'] |
|
206 | ||
207 | ||
193 | 208 |
def test_ovh_new_api(app, freezer): |
194 | 209 |
connector = OVHSMSGateway.objects.create( |
195 | 210 |
slug='ovh', account='sms-test42', |
196 | 211 |
application_key='RHrTdU2oTsrVC0pu', |
197 | 212 |
application_secret='CLjtS69tTcPgCKxedeoZlgMSoQGSiXMa', |
198 | 213 |
consumer_key='iF0zi0MJrbjNcI3hvuvwkhNk8skrigxz' |
199 | 214 |
) |
200 | 215 |
api = ApiUser.objects.create(username='apiuser') |
201 |
- |