comparison sat_pubsub/test/test_gateway.py @ 274:6641ea7990ee

Fix checking for malformed XMPP URI in DeleteResource.
author Ralph Meijer <ralphm@ik.nu>
date Mon, 07 Oct 2013 12:14:54 +0200
parents 6ba0d6def7f5
children 002c59dbc23f
comparison
equal deleted inserted replaced
273:6ba0d6def7f5 274:6641ea7990ee
345 d = _render(self.resource, request) 345 d = _render(self.resource, request)
346 d.addCallback(rendered) 346 d.addCallback(rendered)
347 return d 347 return d
348 348
349 349
350 def test_postURIMissing(self): 350 def test_postMalformedXMPPURI(self):
351 """ 351 """
352 If no URI is passed, 400 Bad Request is returned. 352 If the XMPP URI is malformed, Bad Request is returned.
353 """ 353 """
354 request = DummyRequest([b'']) 354 request = DummyRequest([b''])
355 request.method = b'POST' 355 request.method = b'POST'
356 356
357 def rendered(result): 357 def rendered(result):
358 self.assertEqual(http.BAD_REQUEST, request.responseCode) 358 self.assertEqual(http.BAD_REQUEST, request.responseCode)
359 359
360 uri = 'xmpp:@@@@'
361 request.args[b'uri'] = [uri]
360 request.content = StringIO(b'') 362 request.content = StringIO(b'')
361 363
362 d = _render(self.resource, request) 364 d = _render(self.resource, request)
363 d.addCallback(rendered) 365 d.addCallback(rendered)
364 return d 366 return d
367
368
369 def test_postURIMissing(self):
370 """
371 If no URI is passed, 400 Bad Request is returned.
372 """
373 request = DummyRequest([b''])
374 request.method = b'POST'
375
376 def rendered(result):
377 self.assertEqual(http.BAD_REQUEST, request.responseCode)
378
379 request.content = StringIO(b'')
380
381 d = _render(self.resource, request)
382 d.addCallback(rendered)
383 return d
384
365 385
366 386
367 class CallbackResourceTest(unittest.TestCase): 387 class CallbackResourceTest(unittest.TestCase):
368 """ 388 """
369 Tests for L{gateway.CallbackResource}. 389 Tests for L{gateway.CallbackResource}.