| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
import uuid |
| 15 |
|
| 16 |
from oslo_utils import timeutils |
| 17 |
|
| 18 |
from keystoneclient import exceptions |
| 19 |
from keystoneclient.tests.unit.v3 import utils |
| 20 |
from keystoneclient.v3.contrib import trusts |
| 21 |
|
| 22 |
|
| 23 |
class TrustTests(utils.ClientTestCase, utils.CrudTests): |
| 24 |
def setUp(self): |
| 25 |
super(TrustTests, self).setUp() |
| 26 |
self.key = 'trust' |
| 27 |
self.collection_key = 'trusts' |
| 28 |
self.model = trusts.Trust |
| 29 |
self.manager = self.client.trusts |
| 30 |
self.path_prefix = 'OS-TRUST' |
| 31 |
|
| 32 |
def new_ref(self, **kwargs): |
| 33 |
kwargs = super(TrustTests, self).new_ref(**kwargs) |
| 34 |
kwargs.setdefault('project_id', uuid.uuid4().hex) |
| 35 |
return kwargs |
| 36 |
|
| 37 |
def test_create(self): |
| 38 |
ref = self.new_ref() |
| 39 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 40 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 41 |
ref['impersonation'] = False |
| 42 |
super(TrustTests, self).test_create(ref=ref) |
| 43 |
|
| 44 |
def test_create_limited_uses(self): |
| 45 |
ref = self.new_ref() |
| 46 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 47 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 48 |
ref['impersonation'] = False |
| 49 |
ref['remaining_uses'] = 5 |
| 50 |
super(TrustTests, self).test_create(ref=ref) |
| 51 |
|
| 52 |
def test_create_roles(self): |
| 53 |
ref = self.new_ref() |
| 54 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 55 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 56 |
ref['impersonation'] = False |
| 57 |
req_ref = ref.copy() |
| 58 |
req_ref.pop('id') |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
ref['role_names'] = ['atestrole'] |
| 64 |
req_ref['roles'] = [{'name': 'atestrole'}] |
| 65 |
super(TrustTests, self).test_create(ref=ref, req_ref=req_ref) |
| 66 |
|
| 67 |
def test_create_role_id_and_names(self): |
| 68 |
ref = self.new_ref() |
| 69 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 70 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 71 |
ref['impersonation'] = False |
| 72 |
req_ref = ref.copy() |
| 73 |
req_ref.pop('id') |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
ref['role_names'] = ['atestrole'] |
| 79 |
ref['role_ids'] = [uuid.uuid4().hex] |
| 80 |
req_ref['roles'] = [{'name': 'atestrole'}, {'id': ref['role_ids'][0]}] |
| 81 |
super(TrustTests, self).test_create(ref=ref, req_ref=req_ref) |
| 82 |
|
| 83 |
def test_create_expires(self): |
| 84 |
ref = self.new_ref() |
| 85 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 86 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 87 |
ref['impersonation'] = False |
| 88 |
ref['expires_at'] = timeutils.parse_isotime( |
| 89 |
'2013-03-04T12:00:01.000000Z') |
| 90 |
req_ref = ref.copy() |
| 91 |
req_ref.pop('id') |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
req_ref['expires_at'] = '2013-03-04T12:00:01.000000Z' |
| 96 |
super(TrustTests, self).test_create(ref=ref, req_ref=req_ref) |
| 97 |
|
| 98 |
def test_create_imp(self): |
| 99 |
ref = self.new_ref() |
| 100 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 101 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 102 |
ref['impersonation'] = True |
| 103 |
super(TrustTests, self).test_create(ref=ref) |
| 104 |
|
| 105 |
def test_create_roles_imp(self): |
| 106 |
ref = self.new_ref() |
| 107 |
ref['trustor_user_id'] = uuid.uuid4().hex |
| 108 |
ref['trustee_user_id'] = uuid.uuid4().hex |
| 109 |
ref['impersonation'] = True |
| 110 |
req_ref = ref.copy() |
| 111 |
req_ref.pop('id') |
| 112 |
ref['role_names'] = ['atestrole'] |
| 113 |
req_ref['roles'] = [{'name': 'atestrole'}] |
| 114 |
super(TrustTests, self).test_create(ref=ref, req_ref=req_ref) |
| 115 |
|
| 116 |
def test_list_filter_trustor(self): |
| 117 |
expected_query = {'trustor_user_id': '12345'} |
| 118 |
super(TrustTests, self).test_list(expected_query=expected_query, |
| 119 |
trustor_user='12345') |
| 120 |
|
| 121 |
def test_list_filter_trustee(self): |
| 122 |
expected_query = {'trustee_user_id': '12345'} |
| 123 |
super(TrustTests, self).test_list(expected_query=expected_query, |
| 124 |
trustee_user='12345') |
| 125 |
|
| 126 |
def test_update(self): |
| 127 |
|
| 128 |
self.assertRaises(exceptions.MethodNotImplemented, self.manager.update) |