Revision 11366070 snf-astakos-app/astakos/im/tests/api.py

b/snf-astakos-app/astakos/im/tests/api.py
462 462
        r = client.post(url, post_data, content_type='application/json')
463 463
        self.assertEqual(r.status_code, 400)
464 464
        body = json.loads(r.content)
465
        self.assertEqual(body['badRequest']['message'],
466
                         'Malformed request')
465
        self.assertTrue(body['badRequest']['message'].
466
                        startswith('Malformed request'))
467 467

  
468 468
        # Check malformed request: missing username
469 469
        url = reverse('astakos.api.tokens.authenticate')
......
473 473
        r = client.post(url, post_data, content_type='application/json')
474 474
        self.assertEqual(r.status_code, 400)
475 475
        body = json.loads(r.content)
476
        self.assertEqual(body['badRequest']['message'],
477
                         'Malformed request')
476
        self.assertTrue(body['badRequest']['message'].
477
                        startswith('Malformed request'))
478 478

  
479 479
        # Check invalid pass
480 480
        url = reverse('astakos.api.tokens.authenticate')
......
520 520
        except Exception, e:
521 521
            self.fail(e)
522 522

  
523
        # Check malformed request: missing token
524
        url = reverse('astakos.api.tokens.authenticate')
525
        post_data = """{"auth":{"auth_token":{"id":"%s"},
526
                                "tenantName":"%s"}}""" % (
527
            self.user1.auth_token, self.user1.uuid)
528
        r = client.post(url, post_data, content_type='application/json')
529
        self.assertEqual(r.status_code, 400)
530
        body = json.loads(r.content)
531
        self.assertTrue(body['badRequest']['message'].
532
                        startswith('Malformed request'))
533

  
534
        # Check bad request: inconsistent tenant
535
        url = reverse('astakos.api.tokens.authenticate')
536
        post_data = """{"auth":{"token":{"id":"%s"},
537
                                "tenantName":"%s"}}""" % (
538
            self.user1.auth_token, self.user2.uuid)
539
        r = client.post(url, post_data, content_type='application/json')
540
        self.assertEqual(r.status_code, 400)
541
        body = json.loads(r.content)
542
        self.assertEqual(body['badRequest']['message'],
543
                         'Not conforming tenantName')
544

  
523 545
        # Check successful json response
524 546
        url = reverse('astakos.api.tokens.authenticate')
525 547
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
......
560 582
#            body = minidom.parseString(r.content)
561 583
#        except Exception, e:
562 584
#            self.fail(e)
563

  
564
        # test public mode: json response

Also available in: Unified diff