Expanded assertion in test_create_token for keystone v2, v3
TokensTest.test_create_token and TokensV3Test.test_create_token
tests had very small validation of created token.
Added more assertion to TokensTest.test_create_token and
TokensV3Test.test_create_token tests.
Tests validate token expiration, token type, its user's name, id.
For Keystone V3 there is also validateion for method of token.
Change-Id: Iaf7755168d662d44c5b3ff72ca93c6cd72425e45
diff --git a/tempest/api/identity/v2/test_tokens.py b/tempest/api/identity/v2/test_tokens.py
index 5a8afa0..3b508f4 100644
--- a/tempest/api/identity/v2/test_tokens.py
+++ b/tempest/api/identity/v2/test_tokens.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_utils import timeutils
+import six
from tempest.api.identity import base
from tempest import test
@@ -30,9 +32,19 @@
password = creds.password
tenant_name = creds.tenant_name
- body = token_client.auth(username,
- password,
- tenant_name)
+ body = token_client.auth(username, password, tenant_name)
+ self.assertNotEmpty(body['token']['id'])
+ self.assertIsInstance(body['token']['id'], six.string_types)
+
+ now = timeutils.utcnow()
+ expires_at = timeutils.normalize_time(
+ timeutils.parse_isotime(body['token']['expires']))
+ self.assertGreater(expires_at, now)
+
+ self.assertEqual(body['token']['tenant']['id'],
+ creds.credentials.tenant_id)
self.assertEqual(body['token']['tenant']['name'],
tenant_name)
+
+ self.assertEqual(body['user']['id'], creds.credentials.user_id)
diff --git a/tempest/api/identity/v3/test_tokens.py b/tempest/api/identity/v3/test_tokens.py
index ab4a09f..3151763 100644
--- a/tempest/api/identity/v3/test_tokens.py
+++ b/tempest/api/identity/v3/test_tokens.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_utils import timeutils
+import six
from tempest.api.identity import base
from tempest import test
@@ -26,8 +28,25 @@
user_id = creds.user_id
username = creds.username
password = creds.password
- resp = self.non_admin_token.auth(user_id=user_id,
- password=password)
- subject_name = resp['token']['user']['name']
+ token_id, resp = self.non_admin_token.get_token(user_id=user_id,
+ password=password,
+ auth_data=True)
+
+ self.assertNotEmpty(token_id)
+ self.assertIsInstance(token_id, six.string_types)
+
+ now = timeutils.utcnow()
+ expires_at = timeutils.normalize_time(
+ timeutils.parse_isotime(resp['expires_at']))
+ self.assertGreater(resp['expires_at'],
+ resp['issued_at'])
+ self.assertGreater(expires_at, now)
+
+ subject_id = resp['user']['id']
+ self.assertEqual(subject_id, user_id)
+
+ subject_name = resp['user']['name']
self.assertEqual(subject_name, username)
+
+ self.assertEqual(resp['methods'][0], 'password')