keystone_user: added test for logging with token

This commit is contained in:
Przemyslaw Kaminski 2015-07-09 12:44:23 +02:00
parent 6240670895
commit 8127d0ce58

View File

@ -0,0 +1,24 @@
import json
import requests
def test(resource):
print 'Testing keystone_user {}'.format(resource.args['user_name'].value)
token_data = requests.post(
'http://%s:%s/v2.0/tokens' % (resource.args['keystone_host'].value, resource.args['keystone_port'].value),
json.dumps({
'auth': {
'tenantName': resource.args['tenant_name'].value,
'passwordCredentials': {
'username': resource.args['user_name'].value,
'password': resource.args['user_password'].value,
},
},
}),
headers={'Content-Type': 'application/json'}
)
token = token_data.json()['access']['token']['id']
print '{} TOKEN: {}'.format(resource.args['user_name'].value, token)