blob: a1f664f2d6d23db12f28ef49adba55a77cc080fc [file] [log] [blame]
Jane Zadorozhna9c938c62015-07-01 17:06:16 +03001# Copyright 2015 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import copy
17
18from tempest_lib.common.utils import data_utils
19from tempest_lib import exceptions
20
21from tempest.api.identity import base
22from tempest import manager
23from tempest import test
24
25
26class IdentityV3UsersTest(base.BaseIdentityV3Test):
27
28 @classmethod
29 def resource_setup(cls):
30 super(IdentityV3UsersTest, cls).resource_setup()
31 cls.creds = cls.os.credentials
32 cls.user_id = cls.creds.user_id
33 cls.username = cls.creds.username
34 cls.password = cls.creds.password
35
36 @test.idempotent_id('ad71bd23-12ad-426b-bb8b-195d2b635f27')
37 def test_user_update_own_password(self):
38 self.new_creds = copy.copy(self.creds.credentials)
39 self.new_creds.password = data_utils.rand_password()
40 # we need new non-admin Identity V3 Client with new credentials, since
41 # current non_admin_client token will be revoked after updating
42 # password
43 self.non_admin_client_for_cleanup = copy.copy(self.non_admin_client)
44 self.non_admin_client_for_cleanup.auth_provider = (
45 manager.get_auth_provider(self.new_creds))
46 user_id = self.creds.credentials.user_id
47 old_pass = self.creds.credentials.password
48 new_pass = self.new_creds.password
49 # to change password back. important for allow_tenant_isolation = false
50 self.addCleanup(
51 self.non_admin_client_for_cleanup.update_user_password,
52 user_id=user_id,
53 password=old_pass,
54 original_password=new_pass)
55
56 # user updates own password
57 self.non_admin_client.update_user_password(
58 user_id=user_id, password=new_pass, original_password=old_pass)
59
60 # check authorization with new password
61 self.non_admin_token.auth(user_id=self.user_id, password=new_pass)
62
63 # authorize with old token should lead to IdentityError (404 code)
64 self.assertRaises(exceptions.IdentityError,
65 self.non_admin_token.auth,
66 token=self.non_admin_client.token)
67
68 # authorize with old password should lead to Unauthorized
69 self.assertRaises(exceptions.Unauthorized,
70 self.non_admin_token.auth,
71 user_id=self.user_id,
72 password=old_pass)