<s> import pytest <EOL> import sys <EOL> from . test_base_class import TestBaseClass <EOL> from aerospike import exception as e <EOL> aerospike = pytest . importorskip ( "<STR_LIT>" ) <EOL> try : <EOL> import aerospike <EOL> except : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> class TestSetPassword ( TestBaseClass ) : <EOL> pytestmark = pytest . mark . skipif ( <EOL> TestBaseClass ( ) . get_hosts ( ) [ <NUM_LIT:1> ] == None , <EOL> reason = "<STR_LIT>" ) <EOL> def setup_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> hostlist , user , password = TestBaseClass ( ) . get_hosts ( ) <EOL> config = { "<STR_LIT>" : hostlist } <EOL> TestSetPassword . Me = self <EOL> self . client = aerospike . client ( config ) . connect ( user , password ) <EOL> try : <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> self . client . admin_create_user ( <EOL> "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] , { } ) <EOL> self . delete_users = [ ] <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> self . client . close ( ) <EOL> def test_set_password_without_any_parameters ( self ) : <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> self . client . admin_set_password ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_set_password_with_proper_parameters ( self ) : <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" <EOL> status = self . client . admin_set_password ( user , password ) <EOL> assert status == <NUM_LIT:0> <EOL> def test_set_password_with_invalid_timeout_policy_value ( self ) : <EOL> policy = { '<STR_LIT>' : <NUM_LIT:0.1> } <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_set_password ( user , password , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_set_password_with_proper_timeout_policy_value ( self ) : <EOL> policy = { '<STR_LIT>' : <NUM_LIT:50> } <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" <EOL> status = self . client . admin_set_password ( user , password , policy ) <EOL> assert status == <NUM_LIT:0> <EOL> def test_set_password_with_none_username ( self ) : <EOL> user = None <EOL> password = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_set_password ( user , password ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_set_password_with_none_password ( self ) : <EOL> user = "<STR_LIT>" <EOL> password = None <EOL> try : <EOL> self . client . admin_set_password ( user , password ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_set_password_with_non_existent_user ( self ) : <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" <EOL> try : <EOL> self . client . admin_set_password ( user , password , policy ) <EOL> except e . InvalidUser as exception : <EOL> assert exception . code == <NUM_LIT> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_set_password_with_too_long_password ( self ) : <EOL> policy = { } <EOL> user = "<STR_LIT>" <EOL> password = "<STR_LIT>" * <NUM_LIT:1000> <EOL> status = self . client . admin_set_password ( user , password , policy ) <EOL> assert status == <NUM_LIT:0> </s>
