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

b/snf-astakos-app/astakos/im/tests/api.py
471 471
        self.assertEqual(body['unauthorized']['message'],
472 472
                         'Invalid credentials')
473 473

  
474
        # Check inconsistent tenant
475
        url = '/astakos/api/tokens'
476
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
477
                                                       "password":"%s"},
478
                                "tenantName":"%s"}}""" % (
479
            self.user1.uuid, self.user1.auth_token, self.user2.uuid)
480
        r = client.post(url, post_data, content_type='application/json')
481
        self.assertEqual(r.status_code, 401)
482
        body = json.loads(r.content)
483
        self.assertEqual(body['unauthorized']['message'],
484
                         'Invalid tenant')
485

  
486 474
        # Check invalid json data
487 475
        url = '/astakos/api/tokens'
488 476
        r = client.post(url, "not json", content_type='application/json')
......
577 565
        r = client.get(url, **headers)
578 566
        self.assertEqual(r.status_code, 403)
579 567

  
568
        # Check belongsTo BadRequest
569
        url = '/astakos/api/tokens/%s/endpoints?belongsTo=%s' % (
570
            quote(self.user1.auth_token), quote(self.user2.uuid))
571
        headers = {'HTTP_X_AUTH_TOKEN': self.user1.auth_token}
572
        r = client.get(url, **headers)
573
        self.assertEqual(r.status_code, 400)
574

  
575
        # Check successful request
580 576
        url = '/astakos/api/tokens/%s/endpoints' % quote(self.user1.auth_token)
581 577
        headers = {'HTTP_X_AUTH_TOKEN': self.user1.auth_token}
582 578
        r = client.get(url, **headers)
......
589 585
        endpoints = body.get('endpoints')
590 586
        self.assertEqual(len(endpoints), 3)
591 587

  
592
        # Check belongsTo BadRequest
593
        url = '/astakos/api/tokens/%s/endpoints?belongsTo=%s' % (
594
            quote(self.user1.auth_token), quote(self.user2.uuid))
595
        headers = {'HTTP_X_AUTH_TOKEN': self.user1.auth_token}
596
        r = client.get(url, **headers)
597
        self.assertEqual(r.status_code, 400)
598

  
599 588
         # Check xml serialization
600 589
        url = '/astakos/api/tokens/%s/endpoints?format=xml' %\
601 590
            quote(self.user1.auth_token)

Also available in: Unified diff