| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import uuid |
| 14 |
|
| 15 |
from keystoneauth1 import fixture |
| 16 |
|
| 17 |
from keystoneclient.tests.unit.v3 import utils |
| 18 |
from keystoneclient.v3 import auth |
| 19 |
|
| 20 |
|
| 21 |
class AuthProjectsTest(utils.ClientTestCase): |
| 22 |
|
| 23 |
def setUp(self): |
| 24 |
super(AuthProjectsTest, self).setUp() |
| 25 |
|
| 26 |
self.v3token = fixture.V3Token() |
| 27 |
self.stub_auth(json=self.v3token) |
| 28 |
|
| 29 |
self.stub_url('GET', |
| 30 |
[], |
| 31 |
json={'version': fixture.V3Discovery(self.TEST_URL)}) |
| 32 |
|
| 33 |
def create_resource(self, id=None, name=None, **kwargs): |
| 34 |
kwargs['id'] = id or uuid.uuid4().hex |
| 35 |
kwargs['name'] = name or uuid.uuid4().hex |
| 36 |
return kwargs |
| 37 |
|
| 38 |
def test_get_projects(self): |
| 39 |
body = {'projects': [self.create_resource(), |
| 40 |
self.create_resource(), |
| 41 |
self.create_resource()]} |
| 42 |
|
| 43 |
self.stub_url('GET', ['auth', 'projects'], json=body) |
| 44 |
|
| 45 |
projects = self.client.auth.projects() |
| 46 |
|
| 47 |
self.assertEqual(3, len(projects)) |
| 48 |
|
| 49 |
for p in projects: |
| 50 |
self.assertIsInstance(p, auth.Project) |
| 51 |
|
| 52 |
def test_get_domains(self): |
| 53 |
body = {'domains': [self.create_resource(), |
| 54 |
self.create_resource(), |
| 55 |
self.create_resource()]} |
| 56 |
|
| 57 |
self.stub_url('GET', ['auth', 'domains'], json=body) |
| 58 |
|
| 59 |
domains = self.client.auth.domains() |
| 60 |
|
| 61 |
self.assertEqual(3, len(domains)) |
| 62 |
|
| 63 |
for d in domains: |
| 64 |
self.assertIsInstance(d, auth.Domain) |
| 65 |
|
| 66 |
def test_get_systems(self): |
| 67 |
body = {'system': [{ |
| 68 |
'all': True, |
| 69 |
}]} |
| 70 |
|
| 71 |
self.stub_url('GET', ['auth', 'system'], json=body) |
| 72 |
|
| 73 |
systems = self.client.auth.systems() |
| 74 |
system = systems[0] |
| 75 |
|
| 76 |
self.assertEqual(1, len(systems)) |
| 77 |
self.assertIsInstance(system, auth.System) |
| 78 |
self.assertTrue(system.all) |