api.py 24.8 KB
Newer Older
1
# Copyright 2011, 2012, 2013 GRNET S.A. All rights reserved.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
#   1. Redistributions of source code must retain the above
#      copyright notice, this list of conditions and the following
#      disclaimer.
#
#   2. Redistributions in binary form must reproduce the above
#      copyright notice, this list of conditions and the following
#      disclaimer in the documentation and/or other materials
#      provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from astakos.im.tests.common import *
35
36
37
from astakos.im.settings import astakos_services, BASE_HOST
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
38

39
from django.test import TestCase
40
41
42
from django.core.urlresolvers import reverse

#from xml.dom import minidom
43
44
45

import json

Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
46
47
ROOT = "/%s/%s/%s/" % (
    astakos_settings.BASE_PATH, astakos_settings.ACCOUNTS_PREFIX, 'v1.0')
48
49
50
51
52
53
u = lambda url: ROOT + url


class QuotaAPITest(TestCase):
    def test_0(self):
        client = Client()
54
        backend = activation_backends.get_backend()
55
56
57

        component1 = Component.objects.create(name="comp1")
        register.add_service(component1, "service1", "type1", [])
58
59
60
        # custom service resources
        resource11 = {"name": "service1.resource11",
                      "desc": "resource11 desc",
61
                      "service_type": "type1",
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
62
                      "service_origin": "service1",
63
                      "allow_in_projects": True}
64
65
        r, _ = register.add_resource(resource11)
        register.update_resource(r, 100)
66
67
        resource12 = {"name": "service1.resource12",
                      "desc": "resource11 desc",
68
                      "service_type": "type1",
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
69
                      "service_origin": "service1",
70
                      "unit": "bytes"}
71
72
        r, _ = register.add_resource(resource12)
        register.update_resource(r, 1024)
73
74
75

        # create user
        user = get_local_user('test@grnet.gr')
76
        backend.accept_user(user)
77
78
79
80
81
        non_moderated_user = get_local_user('nonmon@example.com',
                                            is_active=False)
        r_user = get_local_user('rej@example.com',
                                is_active=False, email_verified=True)
        backend.reject_user(r_user, "reason")
82

83
84
        component2 = Component.objects.create(name="comp2")
        register.add_service(component2, "service2", "type2", [])
85
86
87
        # create another service
        resource21 = {"name": "service2.resource21",
                      "desc": "resource11 desc",
88
                      "service_type": "type2",
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
89
                      "service_origin": "service2",
90
                      "allow_in_projects": False}
91
92
        r, _ = register.add_resource(resource21)
        register.update_resource(r, 3)
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

        resource_names = [r['name'] for r in
                          [resource11, resource12, resource21]]

        # get resources
        r = client.get(u('resources'))
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        for name in resource_names:
            assertIn(name, body)

        # get quota
        r = client.get(u('quotas'))
        self.assertEqual(r.status_code, 401)

        headers = {'HTTP_X_AUTH_TOKEN': user.auth_token}
        r = client.get(u('quotas/'), **headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        system_quota = body['system']
        assertIn('system', body)
        for name in resource_names:
            assertIn(name, system_quota)

117
118
        nmheaders = {'HTTP_X_AUTH_TOKEN': non_moderated_user.auth_token}
        r = client.get(u('quotas/'), **nmheaders)
119
120
121
122
123
124
125
        self.assertEqual(r.status_code, 401)

        q = quotas.get_user_quotas(non_moderated_user)
        self.assertEqual(q, {})

        q = quotas.get_user_quotas(r_user)
        self.assertEqual(q, {})
126

127
128
129
        r = client.get(u('service_quotas'))
        self.assertEqual(r.status_code, 401)

130
        s1_headers = {'HTTP_X_AUTH_TOKEN': component1.auth_token}
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
        r = client.get(u('service_quotas'), **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        assertIn(user.uuid, body)

        r = client.get(u('commissions'), **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        self.assertEqual(body, [])

        # issue some commissions
        commission_request = {
            "force": False,
            "auto_accept": False,
            "name": "my commission",
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": 1
                },
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource12['name'],
                    "quantity": 30000
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 413)

        commission_request = {
            "force": False,
            "auto_accept": False,
            "name": "my commission",
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": 1
                },
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource12['name'],
                    "quantity": 100
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)
        body = json.loads(r.content)
        serial = body['serial']
        self.assertEqual(serial, 1)

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)
        body = json.loads(r.content)
        self.assertEqual(body['serial'], 2)

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)
        body = json.loads(r.content)
        self.assertEqual(body['serial'], 3)

        r = client.get(u('commissions'), **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        self.assertEqual(body, [1, 2, 3])

        r = client.get(u('commissions/' + str(serial)), **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        self.assertEqual(body['serial'], serial)
        assertIn('issue_time', body)
215
216
        provisions = sorted(body['provisions'], key=lambda p: p['resource'])
        self.assertEqual(provisions, commission_request['provisions'])
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
        self.assertEqual(body['name'], commission_request['name'])

        r = client.get(u('service_quotas?user=' + user.uuid), **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        user_quota = body[user.uuid]
        system_quota = user_quota['system']
        r11 = system_quota[resource11['name']]
        self.assertEqual(r11['usage'], 3)
        self.assertEqual(r11['pending'], 3)

        # resolve pending commissions
        resolve_data = {
            "accept": [1, 3],
            "reject": [2, 3, 4],
        }
        post_data = json.dumps(resolve_data)

        r = client.post(u('commissions/action'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        self.assertEqual(body['accepted'], [1])
        self.assertEqual(body['rejected'], [2])
        failed = body['failed']
        self.assertEqual(len(failed), 2)

        r = client.get(u('commissions/' + str(serial)), **s1_headers)
        self.assertEqual(r.status_code, 404)

        # auto accept
        commission_request = {
            "auto_accept": True,
            "name": "my commission",
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": 1
                },
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource12['name'],
                    "quantity": 100
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)
        body = json.loads(r.content)
        serial = body['serial']
        self.assertEqual(serial, 4)

        r = client.get(u('commissions/' + str(serial)), **s1_headers)
        self.assertEqual(r.status_code, 404)

        # malformed
        commission_request = {
            "auto_accept": True,
            "name": "my commission",
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                }
            ]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 400)

        commission_request = {
            "auto_accept": True,
            "name": "my commission",
            "provisions": "dummy"}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 400)

        r = client.post(u('commissions'), commission_request,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 400)

        # no holding
        commission_request = {
            "auto_accept": True,
            "name": "my commission",
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": "non existent",
                    "quantity": 1
                },
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource12['name'],
                    "quantity": 100
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 404)

        # release
        commission_request = {
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": -1
                }
            ]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)
        body = json.loads(r.content)
        serial = body['serial']

        accept_data = {'accept': ""}
        post_data = json.dumps(accept_data)
        r = client.post(u('commissions/' + str(serial) + '/action'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 200)

        reject_data = {'reject': ""}
        post_data = json.dumps(accept_data)
        r = client.post(u('commissions/' + str(serial) + '/action'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 404)

        # force
        commission_request = {
            "force": True,
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": 100
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 201)

        commission_request = {
            "force": True,
            "provisions": [
                {
                    "holder": user.uuid,
                    "source": "system",
                    "resource": resource11['name'],
                    "quantity": -200
                }]}

        post_data = json.dumps(commission_request)
        r = client.post(u('commissions'), post_data,
                        content_type='application/json', **s1_headers)
        self.assertEqual(r.status_code, 413)

        r = client.get(u('quotas'), **headers)
        self.assertEqual(r.status_code, 200)
        body = json.loads(r.content)
        system_quota = body['system']
        r11 = system_quota[resource11['name']]
        self.assertEqual(r11['usage'], 102)
        self.assertEqual(r11['pending'], 101)
398

399
400
401
402
        # Bad Request
        r = client.head(u('commissions'))
        self.assertEqual(r.status_code, 400)

403
404
405

class TokensApiTest(TestCase):
    def setUp(self):
406
407
408
409
410
411
412
413
414
415
416
417
418
        backend = activation_backends.get_backend()

        self.user1 = AstakosUser.objects.create(
            email='test1', email_verified=True, moderated=True,
            is_rejected=False)
        backend.activate_user(self.user1)
        assert self.user1.is_active is True

        self.user2 = AstakosUser.objects.create(
            email='test2', email_verified=True, moderated=True,
            is_rejected=False)
        backend.activate_user(self.user2)
        assert self.user2.is_active is True
419

420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
        c1 = Component(name='component1', url='http://localhost/component1')
        c1.save()
        s1 = Service(component=c1, type='type1', name='service1')
        s1.save()
        e1 = Endpoint(service=s1)
        e1.save()
        e1.data.create(key='versionId', value='v1.0')
        e1.data.create(key='publicURL', value='http://localhost:8000/s1/v1.0')

        s2 = Service(component=c1, type='type2', name='service2')
        s2.save()
        e2 = Endpoint(service=s2)
        e2.save()
        e2.data.create(key='versionId', value='v1.0')
        e2.data.create(key='publicURL', value='http://localhost:8000/s2/v1.0')

        c2 = Component(name='component2', url='http://localhost/component2')
        c2.save()
        s3 = Service(component=c2, type='type3', name='service3')
        s3.save()
        e3 = Endpoint(service=s3)
        e3.save()
        e3.data.create(key='versionId', value='v2.0')
        e3.data.create(key='publicURL', value='http://localhost:8000/s3/v2.0')
444

445
    def test_authenticate(self):
446
447
        client = Client()

448
        # Check not allowed method
449
        url = reverse('astakos.api.tokens.authenticate')
450
451
452
        r = client.get(url, post_data={})
        self.assertEqual(r.status_code, 400)

453
454
455
456
457
458
459
460
461
462
463
        # check public mode
        r = client.post(url, CONTENT_LENGTH=0)
        self.assertEqual(r.status_code, 200)
        self.assertTrue(r['Content-Type'].startswith('application/json'))
        try:
            body = json.loads(r.content)
        except Exception, e:
            self.fail(e)
        self.assertTrue('token' not in body.get('access'))
        self.assertTrue('user' not in body.get('access'))
        self.assertTrue('serviceCatalog' in body.get('access'))
464
465

        # Check unsupported xml input
466
        url = reverse('astakos.api.tokens.authenticate')
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
        post_data = """
            <?xml version="1.0" encoding="UTF-8"?>
                <auth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns="http://docs.openstack.org/identity/api/v2.0"
                 tenantName="%s">
                  <passwordCredentials username="%s" password="%s"/>
                </auth>""" % (self.user1.uuid, self.user1.uuid,
                              self.user1.auth_token)
        r = client.post(url, post_data, content_type='application/xml')
        self.assertEqual(r.status_code, 400)
        body = json.loads(r.content)
        self.assertEqual(body['badRequest']['message'],
                         "Unsupported Content-type: 'application/xml'")

        # Check malformed request: missing password
482
        url = reverse('astakos.api.tokens.authenticate')
483
484
485
486
487
488
        post_data = """{"auth":{"passwordCredentials":{"username":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.uuid, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 400)
        body = json.loads(r.content)
489
490
        self.assertTrue(body['badRequest']['message'].
                        startswith('Malformed request'))
491
492

        # Check malformed request: missing username
493
        url = reverse('astakos.api.tokens.authenticate')
494
495
496
497
498
499
        post_data = """{"auth":{"passwordCredentials":{"password":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.auth_token, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 400)
        body = json.loads(r.content)
500
501
        self.assertTrue(body['badRequest']['message'].
                        startswith('Malformed request'))
502
503

        # Check invalid pass
504
        url = reverse('astakos.api.tokens.authenticate')
505
506
507
508
509
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                       "password":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.uuid, '', self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
510
        self.assertEqual(r.status_code, 401)
511
512
513
514
515
        body = json.loads(r.content)
        self.assertEqual(body['unauthorized']['message'],
                         'Invalid token')

        # Check inconsistent pass
516
        url = reverse('astakos.api.tokens.authenticate')
517
518
519
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                       "password":"%s"},
                                "tenantName":"%s"}}""" % (
520
            self.user1.uuid, self.user2.auth_token, self.user2.uuid)
521
522
523
524
525
526
527
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 401)
        body = json.loads(r.content)
        self.assertEqual(body['unauthorized']['message'],
                         'Invalid credentials')

        # Check invalid json data
528
        url = reverse('astakos.api.tokens.authenticate')
529
530
531
532
533
534
        r = client.post(url, "not json", content_type='application/json')
        self.assertEqual(r.status_code, 400)
        body = json.loads(r.content)
        self.assertEqual(body['badRequest']['message'], 'Invalid JSON data')

        # Check auth with token
535
        url = reverse('astakos.api.tokens.authenticate')
536
537
538
539
540
541
542
543
544
545
546
        post_data = """{"auth":{"token": {"id":"%s"},
                        "tenantName":"%s"}}""" % (
            self.user1.auth_token, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 200)
        self.assertTrue(r['Content-Type'].startswith('application/json'))
        try:
            body = json.loads(r.content)
        except Exception, e:
            self.fail(e)

547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
        # Check malformed request: missing token
        url = reverse('astakos.api.tokens.authenticate')
        post_data = """{"auth":{"auth_token":{"id":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.auth_token, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 400)
        body = json.loads(r.content)
        self.assertTrue(body['badRequest']['message'].
                        startswith('Malformed request'))

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

569
570
571
572
573
574
575
576
        # Check bad request: inconsistent tenant
        url = reverse('astakos.api.tokens.authenticate')
        post_data = """{"auth":{"token":{"id":"%s"},
                                "tenantName":""}}""" % (
            self.user1.auth_token)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 200)

577
        # Check successful json response
578
        url = reverse('astakos.api.tokens.authenticate')
579
580
581
582
583
584
585
586
587
588
589
590
591
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                       "password":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.uuid, self.user1.auth_token, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json')
        self.assertEqual(r.status_code, 200)
        self.assertTrue(r['Content-Type'].startswith('application/json'))
        try:
            body = json.loads(r.content)
        except Exception, e:
            self.fail(e)

        try:
592
593
594
            token = body['access']['token']['id']
            user = body['access']['user']['id']
            service_catalog = body['access']['serviceCatalog']
595
596
597
598
599
600
601
602
        except KeyError:
            self.fail('Invalid response')

        self.assertEqual(token, self.user1.auth_token)
        self.assertEqual(user, self.user1.uuid)
        self.assertEqual(len(service_catalog), 3)

        # Check successful xml response
603
        url = reverse('astakos.api.tokens.authenticate')
604
605
606
607
608
609
610
611
612
        headers = {'HTTP_ACCEPT': 'application/xml'}
        post_data = """{"auth":{"passwordCredentials":{"username":"%s",
                                                       "password":"%s"},
                                "tenantName":"%s"}}""" % (
            self.user1.uuid, self.user1.auth_token, self.user1.uuid)
        r = client.post(url, post_data, content_type='application/json',
                        **headers)
        self.assertEqual(r.status_code, 200)
        self.assertTrue(r['Content-Type'].startswith('application/xml'))
613
614
615
616
#        try:
#            body = minidom.parseString(r.content)
#        except Exception, e:
#            self.fail(e)
617
618
619


class WrongPathAPITest(TestCase):
620
    def test_catch_wrong_account_paths(self, *args):
621
622
623
624
625
626
627
628
629
        path = get_service_path(astakos_services, 'account', 'v1.0')
        path = join_urls(BASE_HOST, path, 'nonexistent')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 400)
        try:
            error = json.loads(response.content)
        except ValueError:
            self.assertTrue(False)

630
    def test_catch_wrong_identity_paths(self, *args):
631
632
633
634
635
636
637
638
        path = get_service_path(astakos_services, 'identity', 'v2.0')
        path = join_urls(BASE_HOST, path, 'nonexistent')
        response = self.client.get(path)
        self.assertEqual(response.status_code, 400)
        try:
            error = json.loads(response.content)
        except ValueError:
            self.assertTrue(False)