<s> import django <EOL> from django . conf import settings <EOL> from django . core . urlresolvers import NoReverseMatch <EOL> from django . core . urlresolvers import reverse <EOL> from django import http <EOL> from django . utils . six . moves . urllib . parse import urlsplit <EOL> from django . utils import unittest <EOL> from mox import IsA <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . test import helpers as test <EOL> INDEX_URL = reverse ( '<STR_LIT>' ) <EOL> class ChangePasswordTests ( test . TestCase ) : <EOL> @ test . create_stubs ( { api . keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_change_password ( self ) : <EOL> api . keystone . user_update_own_password ( IsA ( http . HttpRequest ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> res = self . client . post ( INDEX_URL , formData ) <EOL> self . assertNoFormErrors ( res ) <EOL> def test_change_validation_passwords_not_matching ( self ) : <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> res = self . client . post ( INDEX_URL , formData ) <EOL> self . assertFormError ( res , "<STR_LIT>" , None , [ '<STR_LIT>' ] ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> @ test . create_stubs ( { api . keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_change_password_shows_message_on_login_page ( self ) : <EOL> api . keystone . user_update_own_password ( IsA ( http . HttpRequest ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> res = self . client . post ( INDEX_URL , formData , follow = True ) <EOL> info_msg = "<STR_LIT>" <EOL> self . assertContains ( res , info_msg ) <EOL> @ unittest . skipUnless ( django . VERSION [ <NUM_LIT:0> ] >= <NUM_LIT:1> and django . VERSION [ <NUM_LIT:1> ] >= <NUM_LIT:6> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ test . create_stubs ( { api . keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_change_password_sets_logout_reason ( self ) : <EOL> api . keystone . user_update_own_password ( IsA ( http . HttpRequest ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> res = self . client . post ( INDEX_URL , formData , follow = False ) <EOL> self . assertRedirectsNoFollow ( res , settings . LOGOUT_URL ) <EOL> self . assertIn ( '<STR_LIT>' , res . cookies ) <EOL> self . assertEqual ( res . cookies [ '<STR_LIT>' ] . value , <EOL> "<STR_LIT>" ) <EOL> scheme , netloc , path , query , fragment = urlsplit ( res . url ) <EOL> redirect_response = res . client . get ( path , http . QueryDict ( query ) ) <EOL> self . assertRedirectsNoFollow ( redirect_response , settings . LOGIN_URL ) </s>
