Skip to content

Commit b193793

Browse files
author
Jamie Lennox
committed
Use fixtures from keystoneclient for static data
We should use the fixture generation code from keystoneclient rather than keep our own copies of the token and discovery structure. Change-Id: I53c1d2935d1d65c39b8abea89427af2fc3edd181
1 parent 2c9d263 commit b193793

1 file changed

Lines changed: 11 additions & 134 deletions

File tree

‎openstackclient/tests/fakes.py‎

Lines changed: 11 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -17,147 +17,24 @@
1717
import six
1818
import sys
1919

20+
from keystoneclient import fixture
2021
import requests
2122

2223

2324
AUTH_TOKEN = "foobar"
2425
AUTH_URL = "http://0.0.0.0"
2526
USERNAME = "itchy"
2627
PASSWORD = "scratchy"
27-
TEST_RESPONSE_DICT = {
28-
"access": {
29-
"metadata": {
30-
"is_admin": 0,
31-
"roles": [
32-
"1234",
33-
]
34-
},
35-
"serviceCatalog": [
36-
{
37-
"endpoints": [
38-
{
39-
"adminURL": AUTH_URL + "/v2.0",
40-
"id": "1234",
41-
"internalURL": AUTH_URL + "/v2.0",
42-
"publicURL": AUTH_URL + "/v2.0",
43-
"region": "RegionOne"
44-
}
45-
],
46-
"endpoints_links": [],
47-
"name": "keystone",
48-
"type": "identity"
49-
}
50-
],
51-
"token": {
52-
"expires": "2035-01-01T00:00:01Z",
53-
"id": AUTH_TOKEN,
54-
"issued_at": "2013-01-01T00:00:01.692048",
55-
"tenant": {
56-
"description": None,
57-
"enabled": True,
58-
"id": "1234",
59-
"name": "testtenant"
60-
}
61-
},
62-
"user": {
63-
"id": "5678",
64-
"name": USERNAME,
65-
"roles": [
66-
{
67-
"name": "testrole"
68-
},
69-
],
70-
"roles_links": [],
71-
"username": USERNAME
72-
}
73-
}
74-
}
75-
TEST_RESPONSE_DICT_V3 = {
76-
"token": {
77-
"audit_ids": [
78-
"a"
79-
],
80-
"catalog": [
81-
],
82-
"expires_at": "2034-09-29T18:27:15.978064Z",
83-
"extras": {},
84-
"issued_at": "2014-09-29T17:27:15.978097Z",
85-
"methods": [
86-
"password"
87-
],
88-
"project": {
89-
"domain": {
90-
"id": "default",
91-
"name": "Default"
92-
},
93-
"id": "bbb",
94-
"name": "project"
95-
},
96-
"roles": [
97-
],
98-
"user": {
99-
"domain": {
100-
"id": "default",
101-
"name": "Default"
102-
},
103-
"id": "aaa",
104-
"name": USERNAME
105-
}
106-
}
107-
}
108-
TEST_VERSIONS = {
109-
"versions": {
110-
"values": [
111-
{
112-
"id": "v3.0",
113-
"links": [
114-
{
115-
"href": AUTH_URL,
116-
"rel": "self"
117-
}
118-
],
119-
"media-types": [
120-
{
121-
"base": "application/json",
122-
"type": "application/vnd.openstack.identity-v3+json"
123-
},
124-
{
125-
"base": "application/xml",
126-
"type": "application/vnd.openstack.identity-v3+xml"
127-
}
128-
],
129-
"status": "stable",
130-
"updated": "2013-03-06T00:00:00Z"
131-
},
132-
{
133-
"id": "v2.0",
134-
"links": [
135-
{
136-
"href": AUTH_URL,
137-
"rel": "self"
138-
},
139-
{
140-
"href": "http://docs.openstack.org/",
141-
"rel": "describedby",
142-
"type": "text/html"
143-
}
144-
],
145-
"media-types": [
146-
{
147-
"base": "application/json",
148-
"type": "application/vnd.openstack.identity-v2.0+json"
149-
},
150-
{
151-
"base": "application/xml",
152-
"type": "application/vnd.openstack.identity-v2.0+xml"
153-
}
154-
],
155-
"status": "stable",
156-
"updated": "2014-04-17T00:00:00Z"
157-
}
158-
]
159-
}
160-
}
28+
29+
TEST_RESPONSE_DICT = fixture.V2Token(token_id=AUTH_TOKEN,
30+
user_name=USERNAME)
31+
_s = TEST_RESPONSE_DICT.add_service('identity', name='keystone')
32+
_s.add_endpoint(AUTH_URL + '/v2.0')
33+
34+
TEST_RESPONSE_DICT_V3 = fixture.V3Token(user_name=USERNAME)
35+
TEST_RESPONSE_DICT_V3.set_project_scope()
36+
37+
TEST_VERSIONS = fixture.DiscoveryList(href=AUTH_URL)
16138

16239

16340
class FakeStdout:

0 commit comments

Comments
 (0)