Skip to content

Commit

Permalink
Test coverage for issue described in bug 919335
Browse files Browse the repository at this point in the history
Change-Id: I5608968ba287e732216da9c883a32a16b2b15523
  • Loading branch information
dolph committed Jan 25, 2012
1 parent 4c680cf commit 2efd311
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions keystone/test/functional/test_auth.py
Expand Up @@ -93,6 +93,64 @@ def setUp(self):
self.create_endpoint_for_tenant(self.tenant['id'],
self.endpoint_templates['id'])

def test_authenticate_twice(self):
"""Authenticating twice in a row should not result in a new token
The original token should not have expired and should be provided again
"""
first_token = self.post_token(as_json={
'auth': {
'passwordCredentials': {
'username': self.user['name'],
'password': self.user['password']}}}).\
json['access']['token']['id']

second_token = self.post_token(as_json={
'auth': {
'passwordCredentials': {
'username': self.user['name'],
'password': self.user['password']}}}).\
json['access']['token']['id']

self.assertEqual(first_token, second_token)

def test_authenticate_twice_for_tenant(self):
"""Authenticating twice in a row should not result in a new token
The original token should not have expired and should be provided again
"""
# Additonal setUp
role = self.create_role().json['role']
self.grant_role_to_user(self.user['id'], role['id'], self.tenant['id'])

self.service_token = self.post_token(as_json={
'auth': {
'passwordCredentials': {
'username': self.user['name'],
'password': self.user['password']}}}).\
json['access']['token']['id']

tenant = self.service_request(method='GET', path='/tenants').\
json['tenants'][0]

first_token = self.post_token(as_json={
'auth': {
'passwordCredentials': {
'username': self.user['name'],
'password': self.user['password']},
'tenantId': tenant['id']}}).json['access']['token']['id']

second_token = self.post_token(as_json={
'auth': {
'passwordCredentials': {
'username': self.user['name'],
'password': self.user['password']},
'tenantId': tenant['id']}}).json['access']['token']['id']

# unscoped token should be different than the two scoped tokens
self.assertNotEqual(self.service_token, first_token)
self.assertEqual(first_token, second_token)

def test_unscoped_user_auth(self):
"""Admin should be able to validate a user's token"""
# Authenticate as user to get a token
Expand Down

0 comments on commit 2efd311

Please sign in to comment.