45 |
45 |
import simplejson
|
46 |
46 |
|
47 |
47 |
import astakosclient
|
48 |
|
from astakosclient import AstakosClient, AstakosClientException
|
|
48 |
from astakosclient import AstakosClient, AstakosClientException, \
|
|
49 |
AstakosClientEInvalid, AstakosClientEMethod, AstakosClientENotFound
|
49 |
50 |
|
50 |
51 |
# Use backported unittest functionality if Python < 2.7
|
51 |
52 |
try:
|
... | ... | |
295 |
296 |
try:
|
296 |
297 |
client = AstakosClient("https://example.com", use_pool=pool)
|
297 |
298 |
client._callAstakos(token, "/im/authenticate")
|
298 |
|
except AstakosClientException as err:
|
299 |
|
if err.status != 401:
|
300 |
|
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
|
299 |
except AstakosClientEInvalid:
|
|
300 |
pass
|
|
301 |
except Exception:
|
|
302 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
301 |
303 |
else:
|
302 |
304 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
303 |
305 |
|
... | ... | |
317 |
319 |
try:
|
318 |
320 |
client = AstakosClient("https://example.com", use_pool=pool)
|
319 |
321 |
client._callAstakos(token_1, "/im/misspelled")
|
320 |
|
except AstakosClientException as err:
|
321 |
|
if err.status != 404:
|
322 |
|
self.fail("Should have returned 404 (Not Found)")
|
|
322 |
except AstakosClientENotFound:
|
|
323 |
pass
|
|
324 |
except Exception:
|
|
325 |
self.fail("Should have returned 404 (Not Found)")
|
323 |
326 |
else:
|
324 |
327 |
self.fail("Should have returned 404 (Not Found)")
|
325 |
328 |
|
... | ... | |
384 |
387 |
try:
|
385 |
388 |
client = AstakosClient("https://example.com", use_pool=pool)
|
386 |
389 |
client._callAstakos(token_1, "/im/authenticate", method="POST")
|
387 |
|
except AstakosClientException as err:
|
388 |
|
if err.status != 400:
|
389 |
|
self.fail("Should have returned 400 (Method not allowed)")
|
|
390 |
except AstakosClientEMethod:
|
|
391 |
pass
|
|
392 |
except Exception:
|
|
393 |
self.fail("Should have returned 400 (Method not allowed)")
|
390 |
394 |
else:
|
391 |
395 |
self.fail("Should have returned 400 (Method not allowed)")
|
392 |
396 |
|
... | ... | |
406 |
410 |
try:
|
407 |
411 |
client = AstakosClient("https://example.com", use_pool=pool)
|
408 |
412 |
client._callAstakos(token_1, "/user_catalogs")
|
409 |
|
except AstakosClientException as err:
|
410 |
|
if err.status != 400:
|
411 |
|
self.fail("Should have returned 400 (Method not allowed)")
|
|
413 |
except AstakosClientEMethod:
|
|
414 |
pass
|
|
415 |
except Exception:
|
|
416 |
self.fail("Should have returned 400 (Method not allowed)")
|
412 |
417 |
else:
|
413 |
418 |
self.fail("Should have returned 400 (Method not allowed)")
|
414 |
419 |
|
... | ... | |
446 |
451 |
try:
|
447 |
452 |
client = AstakosClient("https://example.com", use_pool=pool)
|
448 |
453 |
client.authenticate(token)
|
449 |
|
except AstakosClientException as err:
|
450 |
|
if err.status != 401:
|
451 |
|
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
|
454 |
except AstakosClientEInvalid:
|
|
455 |
pass
|
|
456 |
except Exception:
|
|
457 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
452 |
458 |
else:
|
453 |
459 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
454 |
460 |
|
... | ... | |
532 |
538 |
try:
|
533 |
539 |
client = AstakosClient("https://example.com")
|
534 |
540 |
client.getDisplayNames(token, [user_1['uuid']])
|
535 |
|
except AstakosClientException as err:
|
536 |
|
if err.status != 401:
|
537 |
|
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
|
541 |
except AstakosClientEInvalid:
|
|
542 |
pass
|
|
543 |
except Exception:
|
|
544 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
538 |
545 |
else:
|
539 |
546 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
540 |
547 |
|
... | ... | |
581 |
588 |
try:
|
582 |
589 |
client = AstakosClient("https://example.com")
|
583 |
590 |
client.getUUIDs(token, [user_1['username']])
|
584 |
|
except AstakosClientException as err:
|
585 |
|
if err.status != 401:
|
586 |
|
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
|
591 |
except AstakosClientEInvalid:
|
|
592 |
pass
|
|
593 |
except Exception:
|
|
594 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
587 |
595 |
else:
|
588 |
596 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)")
|
589 |
597 |
|