[V3] Make credentials_client use **kwargs
As we discussed on http://lists.openstack.org/pipermail/openstack-dev/2015-July/068864.html All http POST/PUT methods need to contain **kwargs as their arguments. This patch makes credentials_client use **kwargs. Partially implements blueprint consistent-service-method-names Change-Id: Icf953bf7234376a877831f88313d935aec25f9bb
This commit is contained in:
parent
81b82beef6
commit
17e8c858d1
|
@ -53,11 +53,11 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
@test.attr(type='smoke')
|
||||
@test.idempotent_id('7cd59bf9-bda4-4c72-9467-d21cab278355')
|
||||
def test_credentials_create_get_update_delete(self):
|
||||
keys = [data_utils.rand_name('Access'),
|
||||
data_utils.rand_name('Secret')]
|
||||
blob = '{"access": "%s", "secret": "%s"}' % (
|
||||
data_utils.rand_name('Access'), data_utils.rand_name('Secret'))
|
||||
cred = self.creds_client.create_credential(
|
||||
keys[0], keys[1], self.user_body['id'],
|
||||
self.projects[0])['credential']
|
||||
user_id=self.user_body['id'], project_id=self.projects[0],
|
||||
blob=blob, type='ec2')['credential']
|
||||
self.addCleanup(self._delete_credential, cred['id'])
|
||||
for value1 in self.creds_list[0]:
|
||||
self.assertIn(value1, cred)
|
||||
|
@ -66,9 +66,10 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
|
||||
new_keys = [data_utils.rand_name('NewAccess'),
|
||||
data_utils.rand_name('NewSecret')]
|
||||
blob = '{"access": "%s", "secret": "%s"}' % (new_keys[0], new_keys[1])
|
||||
update_body = self.creds_client.update_credential(
|
||||
cred['id'], access_key=new_keys[0], secret_key=new_keys[1],
|
||||
project_id=self.projects[1])['credential']
|
||||
cred['id'], blob=blob, project_id=self.projects[1],
|
||||
type='ec2')['credential']
|
||||
self.assertEqual(cred['id'], update_body['id'])
|
||||
self.assertEqual(self.projects[1], update_body['project_id'])
|
||||
self.assertEqual(self.user_body['id'], update_body['user_id'])
|
||||
|
@ -89,10 +90,11 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
fetched_cred_ids = list()
|
||||
|
||||
for i in range(2):
|
||||
blob = '{"access": "%s", "secret": "%s"}' % (
|
||||
data_utils.rand_name('Access'), data_utils.rand_name('Secret'))
|
||||
cred = self.creds_client.create_credential(
|
||||
data_utils.rand_name('Access'),
|
||||
data_utils.rand_name('Secret'),
|
||||
self.user_body['id'], self.projects[0])['credential']
|
||||
user_id=self.user_body['id'], project_id=self.projects[0],
|
||||
blob=blob, type='ec2')['credential']
|
||||
created_cred_ids.append(cred['id'])
|
||||
self.addCleanup(self._delete_credential, cred['id'])
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
http://developer.openstack.org/api-ref-identity-v3.html#credentials-v3
|
||||
"""
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.common import service_client
|
||||
|
@ -21,17 +25,13 @@ from tempest.common import service_client
|
|||
class CredentialsClient(service_client.ServiceClient):
|
||||
api_version = "v3"
|
||||
|
||||
def create_credential(self, access_key, secret_key, user_id, project_id):
|
||||
"""Creates a credential."""
|
||||
blob = "{\"access\": \"%s\", \"secret\": \"%s\"}" % (
|
||||
access_key, secret_key)
|
||||
post_body = {
|
||||
"blob": blob,
|
||||
"project_id": project_id,
|
||||
"type": "ec2",
|
||||
"user_id": user_id
|
||||
}
|
||||
post_body = json.dumps({'credential': post_body})
|
||||
def create_credential(self, **kwargs):
|
||||
"""Creates a credential.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v3.html#createCredential
|
||||
"""
|
||||
post_body = json.dumps({'credential': kwargs})
|
||||
resp, body = self.post('credentials', post_body)
|
||||
self.expected_success(201, resp.status)
|
||||
body = json.loads(body)
|
||||
|
@ -39,22 +39,12 @@ class CredentialsClient(service_client.ServiceClient):
|
|||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
def update_credential(self, credential_id, **kwargs):
|
||||
"""Updates a credential."""
|
||||
body = self.get_credential(credential_id)['credential']
|
||||
cred_type = kwargs.get('type', body['type'])
|
||||
access_key = kwargs.get('access_key', body['blob']['access'])
|
||||
secret_key = kwargs.get('secret_key', body['blob']['secret'])
|
||||
project_id = kwargs.get('project_id', body['project_id'])
|
||||
user_id = kwargs.get('user_id', body['user_id'])
|
||||
blob = "{\"access\": \"%s\", \"secret\": \"%s\"}" % (
|
||||
access_key, secret_key)
|
||||
post_body = {
|
||||
"blob": blob,
|
||||
"project_id": project_id,
|
||||
"type": cred_type,
|
||||
"user_id": user_id
|
||||
}
|
||||
post_body = json.dumps({'credential': post_body})
|
||||
"""Updates a credential.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v3.html#updateCredential
|
||||
"""
|
||||
post_body = json.dumps({'credential': kwargs})
|
||||
resp, body = self.patch('credentials/%s' % credential_id, post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
|
|
Loading…
Reference in New Issue