blob: 2541e25fcf12b3d553a64e9106f50e6776f2ca31 [file] [log] [blame]
nayna-patelb35f7232013-06-28 07:08:44 +00001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2012 OpenStack Foundation
nayna-patelb35f7232013-06-28 07:08:44 +00004# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18from tempest.api.identity import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090019from tempest.common.utils import data_utils
nayna-patelb35f7232013-06-28 07:08:44 +000020from tempest import exceptions
21from tempest.test import attr
22
23
24class UsersTestJSON(base.BaseIdentityAdminTest):
25 _interface = 'json'
26
nayna-patelb35f7232013-06-28 07:08:44 +000027 @attr(type='smoke')
28 def test_tokens(self):
29 # Valid user's token is authenticated
30 # Create a User
Masayuki Igawa259c1132013-10-31 17:48:44 +090031 u_name = data_utils.rand_name('user-')
nayna-patelb35f7232013-06-28 07:08:44 +000032 u_desc = '%s-description' % u_name
33 u_email = '%s@testmail.tm' % u_name
Masayuki Igawa259c1132013-10-31 17:48:44 +090034 u_password = data_utils.rand_name('pass-')
nayna-patelb35f7232013-06-28 07:08:44 +000035 resp, user = self.v3_client.create_user(
36 u_name, description=u_desc, password=u_password,
37 email=u_email)
38 self.assertTrue(resp['status'].startswith('2'))
39 self.addCleanup(self.v3_client.delete_user, user['id'])
40 # Perform Authentication
41 resp, body = self.v3_token.auth(user['id'], u_password)
42 self.assertEqual(resp['status'], '201')
43 subject_token = resp['x-subject-token']
44 # Perform GET Token
45 resp, token_details = self.v3_client.get_token(subject_token)
46 self.assertEqual(resp['status'], '200')
47 self.assertEqual(resp['x-subject-token'], subject_token)
48 self.assertEqual(token_details['user']['id'], user['id'])
49 self.assertEqual(token_details['user']['name'], u_name)
50 # Perform Delete Token
51 resp, _ = self.v3_client.delete_token(subject_token)
Morgan Fainberg69a69ea2013-09-30 12:11:05 -070052 self.assertRaises(exceptions.NotFound, self.v3_client.get_token,
nayna-patelb35f7232013-06-28 07:08:44 +000053 subject_token)
54
55
56class UsersTestXML(UsersTestJSON):
57 _interface = 'xml'