<s> """<STR_LIT>""" <EOL> import unittest <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . compute . common . types import ComputeHypervisors , InstanceAuthStrategies , NovaServerStatusTypes as ServerStates <EOL> from cloudcafe . compute . config import ComputeConfig <EOL> from cloudroast . compute . fixtures import ServerFromImageFixture <EOL> compute_config = ComputeConfig ( ) <EOL> hypervisor = compute_config . hypervisor . lower ( ) <EOL> @ unittest . skipIf ( <EOL> hypervisor in [ ComputeHypervisors . KVM , ComputeHypervisors . QEMU , <EOL> ComputeHypervisors . IRONIC , ComputeHypervisors . LXC_LIBVIRT ] , <EOL> '<STR_LIT>' ) <EOL> class ChangeServerPasswordTests ( object ) : <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT>' ) <EOL> def test_change_password_response ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <NUM_LIT> , self . resp . status_code ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT:yes>' ) <EOL> def test_can_log_in_with_new_password ( self ) : <EOL> """<STR_LIT>""" <EOL> server = self . servers_client . get_server ( self . server . id ) . entity <EOL> server . admin_pass = self . new_password <EOL> public_address = self . server_behaviors . get_public_ip_address ( server ) <EOL> remote_client = self . server_behaviors . get_remote_instance_client ( <EOL> server , config = self . servers_config , <EOL> auth_strategy = InstanceAuthStrategies . PASSWORD ) <EOL> self . assertTrue ( <EOL> remote_client . can_authenticate ( ) , <EOL> "<STR_LIT>" % <EOL> ( public_address , self . new_password ) ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT>' ) <EOL> def test_password_changed_server_instance_actions ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = self . servers_client . get_instance_actions ( <EOL> self . server . id ) . entity <EOL> self . assertTrue ( any ( a . action == '<STR_LIT>' for a in actions ) ) <EOL> filtered_actions = [ a for a in actions <EOL> if a . action == '<STR_LIT>' ] <EOL> self . assertEquals ( len ( filtered_actions ) , <NUM_LIT:1> ) <EOL> password_action = filtered_actions [ <NUM_LIT:0> ] <EOL> self . validate_instance_action ( <EOL> password_action , self . server . id , self . compute . user . user_id , <EOL> self . compute . user . project_id , <EOL> self . resp . headers [ '<STR_LIT>' ] ) <EOL> class ChangePasswordBaseFixture ( object ) : <EOL> @ classmethod <EOL> def change_password ( self ) : <EOL> """<STR_LIT>""" <EOL> self . new_password = "<STR_LIT>" <EOL> self . resp = self . servers_client . change_password ( <EOL> self . server . id , <EOL> self . new_password ) <EOL> self . server_behaviors . wait_for_server_status ( <EOL> self . server . id , <EOL> ServerStates . ACTIVE ) <EOL> class ServerFromImageChangePasswordTests ( ServerFromImageFixture , <EOL> ChangeServerPasswordTests , <EOL> ChangePasswordBaseFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ServerFromImageChangePasswordTests , cls ) . setUpClass ( ) <EOL> cls . create_server ( ) <EOL> cls . change_password ( ) </s>
