more pep8 cleanup
This commit is contained in:
@@ -109,7 +109,9 @@ class HTTPClient(httplib2.Http):
|
|||||||
request_kwargs['headers']['Content-Type'] = 'application/json'
|
request_kwargs['headers']['Content-Type'] = 'application/json'
|
||||||
request_kwargs['body'] = json.dumps(kwargs['body'])
|
request_kwargs['body'] = json.dumps(kwargs['body'])
|
||||||
|
|
||||||
resp, body = super(HTTPClient, self).request(url, method, **request_kwargs)
|
resp, body = super(HTTPClient, self).request(url,
|
||||||
|
method,
|
||||||
|
**request_kwargs)
|
||||||
|
|
||||||
self.http_log((url, method,), request_kwargs, resp, body)
|
self.http_log((url, method,), request_kwargs, resp, body)
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ Command-line interface to the OpenStack Keystone API.
|
|||||||
import argparse
|
import argparse
|
||||||
import httplib2
|
import httplib2
|
||||||
import os
|
import os
|
||||||
import prettytable
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from keystoneclient import exceptions as exc
|
from keystoneclient import exceptions as exc
|
||||||
@@ -171,9 +170,11 @@ class OpenStackIdentityShell(object):
|
|||||||
"via --url or via"
|
"via --url or via"
|
||||||
"env[KEYSTONE_URL")
|
"env[KEYSTONE_URL")
|
||||||
|
|
||||||
self.cs = self.get_api_class(options.version) \
|
self.cs = self.get_api_class(options.version)(user,
|
||||||
(user, apikey, projectid, url,
|
apikey,
|
||||||
region_name=region_name)
|
projectid,
|
||||||
|
url,
|
||||||
|
region_name=region_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.cs.authenticate()
|
self.cs.authenticate()
|
||||||
|
@@ -1,2 +1 @@
|
|||||||
from keystoneclient.v2_0.client import Client
|
from keystoneclient.v2_0.client import Client
|
||||||
|
|
||||||
|
@@ -32,7 +32,9 @@ class ServiceManager(base.ManagerWithFind):
|
|||||||
return self._get("/OS-KSADM/services/%s" % id, "OS-KSADM:service")
|
return self._get("/OS-KSADM/services/%s" % id, "OS-KSADM:service")
|
||||||
|
|
||||||
def create(self, name, service_type, description):
|
def create(self, name, service_type, description):
|
||||||
body = {"OS-KSADM:service": {'name': name, 'type':service_type, 'description': description}}
|
body = {"OS-KSADM:service": {'name': name,
|
||||||
|
'type': service_type,
|
||||||
|
'description': description}}
|
||||||
return self._create("/OS-KSADM/services", body, "OS-KSADM:service")
|
return self._create("/OS-KSADM/services", body, "OS-KSADM:service")
|
||||||
|
|
||||||
def delete(self, id):
|
def delete(self, id):
|
||||||
|
@@ -15,13 +15,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import getpass
|
|
||||||
import os
|
|
||||||
|
|
||||||
from keystoneclient import exceptions
|
|
||||||
from keystoneclient import utils
|
|
||||||
from keystoneclient.v2_0 import client
|
from keystoneclient.v2_0 import client
|
||||||
|
|
||||||
|
|
||||||
CLIENT_CLASS = client.Client
|
CLIENT_CLASS = client.Client
|
||||||
|
|
||||||
|
@@ -55,11 +55,12 @@ class TenantManager(base.ManagerWithFind):
|
|||||||
"""
|
"""
|
||||||
return self._list("/tenants", "tenants")
|
return self._list("/tenants", "tenants")
|
||||||
|
|
||||||
def update(self, tenant_id, tenant_name=None, description=None, enabled=None):
|
def update(self, tenant_id, tenant_name=None, description=None,
|
||||||
|
enabled=None):
|
||||||
"""
|
"""
|
||||||
update a tenant with a new name and description
|
update a tenant with a new name and description
|
||||||
"""
|
"""
|
||||||
body = {"tenant": {'id': tenant_id }}
|
body = {"tenant": {'id': tenant_id}}
|
||||||
if tenant_name is not None:
|
if tenant_name is not None:
|
||||||
body['tenant']['name'] = tenant_name
|
body['tenant']['name'] = tenant_name
|
||||||
if enabled is not None:
|
if enabled is not None:
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
from keystoneclient import base
|
from keystoneclient import base
|
||||||
|
|
||||||
|
|
||||||
class Token(base.Resource):
|
class Token(base.Resource):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Token %s>" % self._info
|
return "<Token %s>" % self._info
|
||||||
@@ -16,6 +17,7 @@ class Token(base.Resource):
|
|||||||
def tenant(self):
|
def tenant(self):
|
||||||
return self._info['token'].get('tenant', None)
|
return self._info['token'].get('tenant', None)
|
||||||
|
|
||||||
|
|
||||||
class TokenManager(base.ManagerWithFind):
|
class TokenManager(base.ManagerWithFind):
|
||||||
resource_class = Token
|
resource_class = Token
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ import httplib2
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from keystoneclient import client
|
from keystoneclient import client
|
||||||
from keystoneclient import exceptions
|
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +36,8 @@ class ClientTest(utils.TestCase):
|
|||||||
"X-Auth-Project-Id": "project_id",
|
"X-Auth-Project-Id": "project_id",
|
||||||
"User-Agent": cl.USER_AGENT,
|
"User-Agent": cl.USER_AGENT,
|
||||||
}
|
}
|
||||||
mock_request.assert_called_with("http://127.0.0.1:5000/hi?fresh=1234",
|
mock_request.assert_called_with("http://127.0.0.1:5000/"
|
||||||
|
"hi?fresh=1234",
|
||||||
"GET", headers=headers)
|
"GET", headers=headers)
|
||||||
# Automatic JSON parsing
|
# Automatic JSON parsing
|
||||||
self.assertEqual(body, {"hi": "there"})
|
self.assertEqual(body, {"hi": "there"})
|
||||||
@@ -60,4 +60,3 @@ class ClientTest(utils.TestCase):
|
|||||||
headers=headers, body='[1, 2, 3]')
|
headers=headers, body='[1, 2, 3]')
|
||||||
|
|
||||||
test_post_call()
|
test_post_call()
|
||||||
|
|
||||||
|
@@ -7,87 +7,88 @@ from tests import utils
|
|||||||
# Do not edit this structure. Instead, grab the latest from there.
|
# Do not edit this structure. Instead, grab the latest from there.
|
||||||
|
|
||||||
SERVICE_CATALOG = {
|
SERVICE_CATALOG = {
|
||||||
"access":{
|
"access": {
|
||||||
"token":{
|
"token": {
|
||||||
"id":"ab48a9efdfedb23ty3494",
|
"id": "ab48a9efdfedb23ty3494",
|
||||||
"expires":"2010-11-01T03:32:15-05:00",
|
"expires": "2010-11-01T03:32:15-05:00",
|
||||||
"tenant":{
|
"tenant": {
|
||||||
"id": "345",
|
"id": "345",
|
||||||
"name": "My Project"
|
"name": "My Project"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"user":{
|
"user": {
|
||||||
"id":"123",
|
"id": "123",
|
||||||
"name":"jqsmith",
|
"name": "jqsmith",
|
||||||
"roles":[{
|
"roles": [{
|
||||||
"id":"234",
|
"id": "234",
|
||||||
"name":"compute:admin"
|
"name": "compute:admin"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"235",
|
"id": "235",
|
||||||
"name":"object-store:admin",
|
"name": "object-store:admin",
|
||||||
"tenantId":"1"
|
"tenantId": "1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"roles_links":[]
|
"roles_links": []
|
||||||
},
|
},
|
||||||
"serviceCatalog":[{
|
"serviceCatalog": [{
|
||||||
"name":"Cloud Servers",
|
"name": "Cloud Servers",
|
||||||
"type":"compute",
|
"type": "compute",
|
||||||
"endpoints":[{
|
"endpoints": [{
|
||||||
"tenantId":"1",
|
"tenantId": "1",
|
||||||
"publicURL":"https://compute.north.host/v1/1234",
|
"publicURL": "https://compute.north.host/v1/1234",
|
||||||
"internalURL":"https://compute.north.host/v1/1234",
|
"internalURL": "https://compute.north.host/v1/1234",
|
||||||
"region":"North",
|
"region": "North",
|
||||||
"versionId":"1.0",
|
"versionId": "1.0",
|
||||||
"versionInfo":"https://compute.north.host/v1.0/",
|
"versionInfo": "https://compute.north.host/v1.0/",
|
||||||
"versionList":"https://compute.north.host/"
|
"versionList": "https://compute.north.host/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tenantId":"2",
|
"tenantId": "2",
|
||||||
"publicURL":"https://compute.north.host/v1.1/3456",
|
"publicURL": "https://compute.north.host/v1.1/3456",
|
||||||
"internalURL":"https://compute.north.host/v1.1/3456",
|
"internalURL": "https://compute.north.host/v1.1/3456",
|
||||||
"region":"North",
|
"region": "North",
|
||||||
"versionId":"1.1",
|
"versionId": "1.1",
|
||||||
"versionInfo":"https://compute.north.host/v1.1/",
|
"versionInfo": "https://compute.north.host/v1.1/",
|
||||||
"versionList":"https://compute.north.host/"
|
"versionList": "https://compute.north.host/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"endpoints_links":[]
|
"endpoints_links": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"Cloud Files",
|
"name": "Cloud Files",
|
||||||
"type":"object-store",
|
"type": "object-store",
|
||||||
"endpoints":[{
|
"endpoints": [{
|
||||||
"tenantId":"11",
|
"tenantId": "11",
|
||||||
"publicURL":"https://compute.north.host/v1/blah-blah",
|
"publicURL": "https://compute.north.host/v1/blah-blah",
|
||||||
"internalURL":"https://compute.north.host/v1/blah-blah",
|
"internalURL": "https://compute.north.host/v1/blah-blah",
|
||||||
"region":"South",
|
"region": "South",
|
||||||
"versionId":"1.0",
|
"versionId": "1.0",
|
||||||
"versionInfo":"uri",
|
"versionInfo": "uri",
|
||||||
"versionList":"uri"
|
"versionList": "uri"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tenantId":"2",
|
"tenantId": "2",
|
||||||
"publicURL":"https://compute.north.host/v1.1/blah-blah",
|
"publicURL": "https://compute.north.host/v1.1/blah-blah",
|
||||||
"internalURL":"https://compute.north.host/v1.1/blah-blah",
|
"internalURL": "https://compute.north.host/v1.1/blah-blah",
|
||||||
"region":"South",
|
"region": "South",
|
||||||
"versionId":"1.1",
|
"versionId": "1.1",
|
||||||
"versionInfo":"https://compute.north.host/v1.1/",
|
"versionInfo": "https://compute.north.host/v1.1/",
|
||||||
"versionList":"https://compute.north.host/"
|
"versionList": "https://compute.north.host/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"endpoints_links":[{
|
"endpoints_links":[{
|
||||||
"rel":"next",
|
"rel":"next",
|
||||||
"href":"https://identity.north.host/v2.0/endpoints?marker=2"
|
"href":"https://identity.north.host/v2.0/endpoints?marker=2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"serviceCatalog_links":[{
|
"serviceCatalog_links": [{
|
||||||
"rel":"next",
|
"rel": "next",
|
||||||
"href":"https://identity.host/v2.0/endpoints?session=2hfh8Ar&marker=2"
|
"href": ("https://identity.host/v2.0/endpoints?"
|
||||||
}
|
"session=2hfh8Ar&marker=2")
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,8 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_authenticate_failure(self):
|
def test_authenticate_failure(self):
|
||||||
self.TEST_REQUEST_BODY['auth']['passwordCredentials']['password'] = 'bad_key'
|
self.TEST_REQUEST_BODY['auth']['passwordCredentials']['password'] = \
|
||||||
|
'bad_key'
|
||||||
self.TEST_REQUEST_HEADERS['X-Auth-Project-Id'] = '1'
|
self.TEST_REQUEST_HEADERS['X-Auth-Project-Id'] = '1'
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 401,
|
"status": 401,
|
||||||
@@ -72,7 +73,6 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
project_id=self.TEST_TENANT,
|
project_id=self.TEST_TENANT,
|
||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
|
|
||||||
|
|
||||||
def test_auth_redirect(self):
|
def test_auth_redirect(self):
|
||||||
self.TEST_REQUEST_HEADERS['X-Auth-Project-Id'] = '1'
|
self.TEST_REQUEST_HEADERS['X-Auth-Project-Id'] = '1'
|
||||||
correct_response = json.dumps(self.TEST_RESPONSE_DICT)
|
correct_response = json.dumps(self.TEST_RESPONSE_DICT)
|
||||||
@@ -154,7 +154,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
self.assertEqual(cs.auth_token,
|
self.assertEqual(cs.auth_token,
|
||||||
self.TEST_RESPONSE_DICT["access"]["token"]["id"])
|
self.TEST_RESPONSE_DICT["access"]["token"]["id"])
|
||||||
self.assertFalse(cs.service_catalog.catalog.has_key('serviceCatalog'))
|
self.assertFalse('serviceCatalog' in cs.service_catalog.catalog)
|
||||||
|
|
||||||
def test_authenticate_success_token_scoped(self):
|
def test_authenticate_success_token_scoped(self):
|
||||||
del self.TEST_REQUEST_BODY['auth']['passwordCredentials']
|
del self.TEST_REQUEST_BODY['auth']['passwordCredentials']
|
||||||
@@ -204,4 +204,4 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
|||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
self.assertEqual(cs.auth_token,
|
self.assertEqual(cs.auth_token,
|
||||||
self.TEST_RESPONSE_DICT["access"]["token"]["id"])
|
self.TEST_RESPONSE_DICT["access"]["token"]["id"])
|
||||||
self.assertFalse(cs.service_catalog.catalog.has_key('serviceCatalog'))
|
self.assertFalse('serviceCatalog' in cs.service_catalog.catalog)
|
||||||
|
@@ -12,11 +12,11 @@ class RoleTests(utils.TestCase):
|
|||||||
super(RoleTests, self).setUp()
|
super(RoleTests, self).setUp()
|
||||||
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_ROLES = {
|
self.TEST_ROLES = {
|
||||||
"roles": {
|
"roles": {
|
||||||
"values": [
|
"values": [
|
||||||
@@ -33,14 +33,15 @@ class RoleTests(utils.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
req_body = {"role": {"name": "sysadmin",}}
|
req_body = {"role": {"name": "sysadmin"}}
|
||||||
resp_body = {"role": {"name": "sysadmin", "id": 3,}}
|
resp_body = {"role": {"name": "sysadmin", "id": 3}}
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(resp_body),
|
"body": json.dumps(resp_body),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/roles'),
|
||||||
'POST',
|
'POST',
|
||||||
body=json.dumps(req_body),
|
body=json.dumps(req_body),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
@@ -57,7 +58,8 @@ class RoleTests(utils.TestCase):
|
|||||||
"status": 200,
|
"status": 200,
|
||||||
"body": ""
|
"body": ""
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles/1'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/roles/1'),
|
||||||
'DELETE',
|
'DELETE',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -68,9 +70,11 @@ class RoleTests(utils.TestCase):
|
|||||||
def test_get(self):
|
def test_get(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps({'role':self.TEST_ROLES['roles']['values'][0]}),
|
"body": json.dumps({'role':
|
||||||
|
self.TEST_ROLES['roles']['values'][0]}),
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles/1?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/roles/1?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -81,14 +85,14 @@ class RoleTests(utils.TestCase):
|
|||||||
self.assertEqual(role.id, 1)
|
self.assertEqual(role.id, 1)
|
||||||
self.assertEqual(role.name, 'admin')
|
self.assertEqual(role.name, 'admin')
|
||||||
|
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(self.TEST_ROLES),
|
"body": json.dumps(self.TEST_ROLES),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/roles?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -96,4 +100,3 @@ class RoleTests(utils.TestCase):
|
|||||||
|
|
||||||
role_list = self.client.roles.list()
|
role_list = self.client.roles.list()
|
||||||
[self.assertTrue(isinstance(r, roles.Role)) for r in role_list]
|
[self.assertTrue(isinstance(r, roles.Role)) for r in role_list]
|
||||||
|
|
||||||
|
@@ -12,34 +12,34 @@ class ServiceTests(utils.TestCase):
|
|||||||
super(ServiceTests, self).setUp()
|
super(ServiceTests, self).setUp()
|
||||||
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_SERVICES = {
|
self.TEST_SERVICES = {"OS-KSADM:services": {
|
||||||
"OS-KSADM:services": {
|
"values": [
|
||||||
"values": [
|
{
|
||||||
{
|
"name": "nova",
|
||||||
"name": "nova",
|
"type": "compute",
|
||||||
"type": "compute",
|
"description": "Nova-compatible service.",
|
||||||
"description": "Nova-compatible service.",
|
"id": 1
|
||||||
"id": 1
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "keystone",
|
||||||
"name": "keystone",
|
"type": "identity",
|
||||||
"type": "identity",
|
"description": ("Keystone-compatible "
|
||||||
"description": "Keystone-compatible service.",
|
"service."),
|
||||||
"id": 2
|
"id": 2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
req_body = {"OS-KSADM:service": {"name": "swift",
|
req_body = {"OS-KSADM:service": {"name": "swift",
|
||||||
"type": "object-store",
|
"type": "object-store",
|
||||||
"description": "Swift-compatible service.",}}
|
"description": "Swift-compatible service."}}
|
||||||
resp_body = {"OS-KSADM:service": {"name": "swift",
|
resp_body = {"OS-KSADM:service": {"name": "swift",
|
||||||
"type": "object-store",
|
"type": "object-store",
|
||||||
"description": "Swift-compatible service.",
|
"description": "Swift-compatible service.",
|
||||||
@@ -49,16 +49,18 @@ class ServiceTests(utils.TestCase):
|
|||||||
"body": json.dumps(resp_body),
|
"body": json.dumps(resp_body),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/services'),
|
||||||
'POST',
|
'POST',
|
||||||
body=json.dumps(req_body),
|
body=json.dumps(req_body),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
service = self.client.services.create(req_body['OS-KSADM:service']['name'],
|
service = self.client.services.create(
|
||||||
req_body['OS-KSADM:service']['type'],
|
req_body['OS-KSADM:service']['name'],
|
||||||
req_body['OS-KSADM:service']['description'])
|
req_body['OS-KSADM:service']['type'],
|
||||||
|
req_body['OS-KSADM:service']['description'])
|
||||||
self.assertTrue(isinstance(service, services.Service))
|
self.assertTrue(isinstance(service, services.Service))
|
||||||
self.assertEqual(service.id, 3)
|
self.assertEqual(service.id, 3)
|
||||||
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
||||||
@@ -68,7 +70,8 @@ class ServiceTests(utils.TestCase):
|
|||||||
"status": 200,
|
"status": 200,
|
||||||
"body": ""
|
"body": ""
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services/1'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/services/1'),
|
||||||
'DELETE',
|
'DELETE',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -79,9 +82,11 @@ class ServiceTests(utils.TestCase):
|
|||||||
def test_get(self):
|
def test_get(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps({'OS-KSADM:service':self.TEST_SERVICES['OS-KSADM:services']['values'][0]}),
|
"body": json.dumps({'OS-KSADM:service':
|
||||||
|
self.TEST_SERVICES['OS-KSADM:services']['values'][0]}),
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services/1?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/services/1?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -93,19 +98,19 @@ class ServiceTests(utils.TestCase):
|
|||||||
self.assertEqual(service.name, 'nova')
|
self.assertEqual(service.name, 'nova')
|
||||||
self.assertEqual(service.type, 'compute')
|
self.assertEqual(service.type, 'compute')
|
||||||
|
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(self.TEST_SERVICES),
|
"body": json.dumps(self.TEST_SERVICES),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/services?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
service_list = self.client.services.list()
|
service_list = self.client.services.list()
|
||||||
[self.assertTrue(isinstance(r, services.Service)) for r in service_list]
|
[self.assertTrue(isinstance(r, services.Service)) \
|
||||||
|
for r in service_list]
|
||||||
|
@@ -12,45 +12,44 @@ class TenantTests(utils.TestCase):
|
|||||||
super(TenantTests, self).setUp()
|
super(TenantTests, self).setUp()
|
||||||
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_TENANTS = {
|
self.TEST_TENANTS = {"tenants": {
|
||||||
"tenants": {
|
"values": [
|
||||||
"values": [
|
{
|
||||||
{
|
"enabled": True,
|
||||||
"enabled": True,
|
"description": "A description change!",
|
||||||
"description": "A description change!",
|
"name": "invisible_to_admin",
|
||||||
"name": "invisible_to_admin",
|
"id": 3
|
||||||
"id": 3
|
},
|
||||||
},
|
{
|
||||||
{
|
"enabled": True,
|
||||||
"enabled": True,
|
"description": "None",
|
||||||
"description": "None",
|
"name": "demo",
|
||||||
"name": "demo",
|
"id": 2
|
||||||
"id": 2
|
},
|
||||||
},
|
{
|
||||||
{
|
"enabled": True,
|
||||||
"enabled": True,
|
"description": "None",
|
||||||
"description": "None",
|
"name": "admin",
|
||||||
"name": "admin",
|
"id": 1
|
||||||
"id": 1
|
}
|
||||||
}
|
],
|
||||||
],
|
"links": []
|
||||||
"links": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
req_body = {"tenant": {"name": "tenantX",
|
req_body = {"tenant": {"name": "tenantX",
|
||||||
"description": "Like tenant 9, but better.",
|
"description": "Like tenant 9, but better.",
|
||||||
"enabled": True,}}
|
"enabled": True}}
|
||||||
resp_body = {"tenant": {"name": "tenantX",
|
resp_body = {"tenant": {"name": "tenantX",
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"description": "Like tenant 9, but better.",}}
|
"description": "Like tenant 9, but better."}}
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(resp_body),
|
"body": json.dumps(resp_body),
|
||||||
@@ -76,7 +75,8 @@ class TenantTests(utils.TestCase):
|
|||||||
"status": 200,
|
"status": 200,
|
||||||
"body": ""
|
"body": ""
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/1'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/tenants/1'),
|
||||||
'DELETE',
|
'DELETE',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -87,9 +87,11 @@ class TenantTests(utils.TestCase):
|
|||||||
def test_get(self):
|
def test_get(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps({'tenant':self.TEST_TENANTS['tenants']['values'][2]}),
|
"body": json.dumps({'tenant':
|
||||||
|
self.TEST_TENANTS['tenants']['values'][2]}),
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/1?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/tenants/1?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -100,14 +102,14 @@ class TenantTests(utils.TestCase):
|
|||||||
self.assertEqual(t.id, 1)
|
self.assertEqual(t.id, 1)
|
||||||
self.assertEqual(t.name, 'admin')
|
self.assertEqual(t.name, 'admin')
|
||||||
|
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(self.TEST_TENANTS),
|
"body": json.dumps(self.TEST_TENANTS),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/tenants?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -116,22 +118,22 @@ class TenantTests(utils.TestCase):
|
|||||||
tenant_list = self.client.tenants.list()
|
tenant_list = self.client.tenants.list()
|
||||||
[self.assertTrue(isinstance(t, tenants.Tenant)) for t in tenant_list]
|
[self.assertTrue(isinstance(t, tenants.Tenant)) for t in tenant_list]
|
||||||
|
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
req_body = {"tenant": {"id": 4,
|
req_body = {"tenant": {"id": 4,
|
||||||
"name": "tenantX",
|
"name": "tenantX",
|
||||||
"description": "I changed you!",
|
"description": "I changed you!",
|
||||||
"enabled": False,}}
|
"enabled": False}}
|
||||||
resp_body = {"tenant": {"name": "tenantX",
|
resp_body = {"tenant": {"name": "tenantX",
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"description": "I changed you!",}}
|
"description": "I changed you!"}}
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps(resp_body),
|
"body": json.dumps(resp_body),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/tenants/4'),
|
||||||
'PUT',
|
'PUT',
|
||||||
body=json.dumps(req_body),
|
body=json.dumps(req_body),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
|
@@ -1,27 +1,27 @@
|
|||||||
import urlparse
|
#import urlparse
|
||||||
import json
|
#import json
|
||||||
|
|
||||||
import httplib2
|
#import httplib2
|
||||||
|
|
||||||
from keystoneclient.v2_0 import tokens
|
#from keystoneclient.v2_0 import tokens
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
|
|
||||||
class TokenTests(utils.TestCase):
|
class TokenTests(utils.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ServiceTests, self).setUp()
|
#super(ServiceTests, self).setUp()
|
||||||
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
'''
|
'''
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
req_body = {"OS-KSADM:service": {"name": "swift",
|
req_body = {"OS-KSADM:service": {"name": "swift",
|
||||||
"type": "object-store",
|
"type": "object-store",
|
||||||
"description": "Swift-compatible service.",}}
|
"description": "Swift-compatible service."}}
|
||||||
resp_body = {"OS-KSADM:service": {"name": "swift",
|
resp_body = {"OS-KSADM:service": {"name": "swift",
|
||||||
"type": "object-store",
|
"type": "object-store",
|
||||||
"description": "Swift-compatible service.",
|
"description": "Swift-compatible service.",
|
||||||
@@ -31,16 +31,18 @@ class TokenTests(utils.TestCase):
|
|||||||
"body": json.dumps(resp_body),
|
"body": json.dumps(resp_body),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/OS-KSADM/services'),
|
||||||
'POST',
|
'POST',
|
||||||
body=json.dumps(req_body),
|
body=json.dumps(req_body),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
service = self.client.services.create(req_body['OS-KSADM:service']['name'],
|
service = self.client.services.create(
|
||||||
req_body['OS-KSADM:service']['type'],
|
req_body['OS-KSADM:service']['name'],
|
||||||
req_body['OS-KSADM:service']['description'])
|
req_body['OS-KSADM:service']['type'],
|
||||||
|
req_body['OS-KSADM:service']['description'])
|
||||||
self.assertTrue(isinstance(service, services.Service))
|
self.assertTrue(isinstance(service, services.Service))
|
||||||
self.assertEqual(service.id, 3)
|
self.assertEqual(service.id, 3)
|
||||||
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
self.assertEqual(service.name, req_body['OS-KSADM:service']['name'])
|
||||||
|
@@ -12,11 +12,11 @@ class UserTests(utils.TestCase):
|
|||||||
super(UserTests, self).setUp()
|
super(UserTests, self).setUp()
|
||||||
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_REQUEST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
self.TEST_POST_HEADERS = {'X-Auth-Project-Id': '1',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Auth-Token': 'aToken',
|
'X-Auth-Token': 'aToken',
|
||||||
'User-Agent': 'python-keystoneclient',}
|
'User-Agent': 'python-keystoneclient'}
|
||||||
self.TEST_USERS = {
|
self.TEST_USERS = {
|
||||||
"users": {
|
"users": {
|
||||||
"values": [
|
"values": [
|
||||||
@@ -41,7 +41,7 @@ class UserTests(utils.TestCase):
|
|||||||
"password": "test",
|
"password": "test",
|
||||||
"tenantId": 2,
|
"tenantId": 2,
|
||||||
"email": "test@example.com",
|
"email": "test@example.com",
|
||||||
"enabled": True,}}
|
"enabled": True}}
|
||||||
resp_body = {"user": {"name": "gabriel",
|
resp_body = {"user": {"name": "gabriel",
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"tenantId": 2,
|
"tenantId": 2,
|
||||||
@@ -69,6 +69,7 @@ class UserTests(utils.TestCase):
|
|||||||
self.assertEqual(user.id, 3)
|
self.assertEqual(user.id, 3)
|
||||||
self.assertEqual(user.name, "gabriel")
|
self.assertEqual(user.name, "gabriel")
|
||||||
self.assertEqual(user.email, "test@example.com")
|
self.assertEqual(user.email, "test@example.com")
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
@@ -82,13 +83,15 @@ class UserTests(utils.TestCase):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.client.users.delete(1)
|
self.client.users.delete(1)
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"body": json.dumps({'user':self.TEST_USERS['users']['values'][0]}),
|
"body": json.dumps({'user': self.TEST_USERS['users']['values'][0]})
|
||||||
})
|
})
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/1?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/users/1?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -98,6 +101,7 @@ class UserTests(utils.TestCase):
|
|||||||
self.assertTrue(isinstance(u, users.User))
|
self.assertTrue(isinstance(u, users.User))
|
||||||
self.assertEqual(u.id, 1)
|
self.assertEqual(u.id, 1)
|
||||||
self.assertEqual(u.name, 'admin')
|
self.assertEqual(u.name, 'admin')
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
resp = httplib2.Response({
|
resp = httplib2.Response({
|
||||||
@@ -105,7 +109,8 @@ class UserTests(utils.TestCase):
|
|||||||
"body": json.dumps(self.TEST_USERS),
|
"body": json.dumps(self.TEST_USERS),
|
||||||
})
|
})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users?fresh=1234'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/users?fresh=1234'),
|
||||||
'GET',
|
'GET',
|
||||||
headers=self.TEST_REQUEST_HEADERS) \
|
headers=self.TEST_REQUEST_HEADERS) \
|
||||||
.AndReturn((resp, resp['body']))
|
.AndReturn((resp, resp['body']))
|
||||||
@@ -113,6 +118,7 @@ class UserTests(utils.TestCase):
|
|||||||
|
|
||||||
user_list = self.client.users.list()
|
user_list = self.client.users.list()
|
||||||
[self.assertTrue(isinstance(u, users.User)) for u in user_list]
|
[self.assertTrue(isinstance(u, users.User)) for u in user_list]
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
req_1 = {"user": {"password": "swordfish", "id": 2}}
|
req_1 = {"user": {"password": "swordfish", "id": 2}}
|
||||||
@@ -120,12 +126,13 @@ class UserTests(utils.TestCase):
|
|||||||
req_3 = {"user": {"tenantId": 1, "id": 2}}
|
req_3 = {"user": {"tenantId": 1, "id": 2}}
|
||||||
req_4 = {"user": {"enabled": False, "id": 2}}
|
req_4 = {"user": {"enabled": False, "id": 2}}
|
||||||
# Keystone basically echoes these back... including the password :-/
|
# Keystone basically echoes these back... including the password :-/
|
||||||
resp_1 = httplib2.Response({"status": 200, "body": json.dumps(req_1),})
|
resp_1 = httplib2.Response({"status": 200, "body": json.dumps(req_1)})
|
||||||
resp_2 = httplib2.Response({"status": 200, "body": json.dumps(req_2),})
|
resp_2 = httplib2.Response({"status": 200, "body": json.dumps(req_2)})
|
||||||
resp_3 = httplib2.Response({"status": 200, "body": json.dumps(req_3),})
|
resp_3 = httplib2.Response({"status": 200, "body": json.dumps(req_3)})
|
||||||
resp_4 = httplib2.Response({"status": 200, "body": json.dumps(req_3),})
|
resp_4 = httplib2.Response({"status": 200, "body": json.dumps(req_3)})
|
||||||
|
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/password'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/users/2/password'),
|
||||||
'PUT',
|
'PUT',
|
||||||
body=json.dumps(req_1),
|
body=json.dumps(req_1),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
@@ -135,12 +142,14 @@ class UserTests(utils.TestCase):
|
|||||||
body=json.dumps(req_2),
|
body=json.dumps(req_2),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
.AndReturn((resp_2, resp_2['body']))
|
.AndReturn((resp_2, resp_2['body']))
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/tenant'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/users/2/tenant'),
|
||||||
'PUT',
|
'PUT',
|
||||||
body=json.dumps(req_3),
|
body=json.dumps(req_3),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
.AndReturn((resp_3, resp_3['body']))
|
.AndReturn((resp_3, resp_3['body']))
|
||||||
httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/enabled'),
|
httplib2.Http.request(urlparse.urljoin(self.TEST_URL,
|
||||||
|
'v2.0/users/2/enabled'),
|
||||||
'PUT',
|
'PUT',
|
||||||
body=json.dumps(req_4),
|
body=json.dumps(req_4),
|
||||||
headers=self.TEST_POST_HEADERS) \
|
headers=self.TEST_POST_HEADERS) \
|
||||||
@@ -151,3 +160,5 @@ class UserTests(utils.TestCase):
|
|||||||
user = self.client.users.update_email(2, 'gabriel@example.com')
|
user = self.client.users.update_email(2, 'gabriel@example.com')
|
||||||
user = self.client.users.update_tenant(2, 1)
|
user = self.client.users.update_tenant(2, 1)
|
||||||
user = self.client.users.update_enabled(2, False)
|
user = self.client.users.update_enabled(2, False)
|
||||||
|
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
Reference in New Issue
Block a user