<s> import pytest <EOL> import sys <EOL> import time <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 TestDropRole ( 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 = { <EOL> "<STR_LIT>" : hostlist <EOL> } <EOL> self . client = aerospike . client ( config ) . connect ( user , password ) <EOL> self . delete_users = [ ] <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> for user in self . delete_users : <EOL> self . client . admin_drop_user ( user , policy ) <EOL> self . client . close ( ) <EOL> def test_drop_role_without_any_parameters ( self ) : <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> self . client . admin_drop_role ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_drop_role_positive_with_policy ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . client . admin_query_role ( "<STR_LIT>" ) <EOL> self . client . admin_drop_role ( "<STR_LIT>" ) <EOL> except e . InvalidRole : <EOL> pass <EOL> self . client . admin_create_role ( "<STR_LIT>" , <EOL> [ { "<STR_LIT:code>" : aerospike . PRIV_READ , <EOL> "<STR_LIT>" : "<STR_LIT:test>" , "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> { '<STR_LIT>' : <NUM_LIT:1000> } ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> roles = self . client . admin_query_role ( "<STR_LIT>" ) <EOL> assert roles == [ { "<STR_LIT:code>" : <NUM_LIT:10> , "<STR_LIT>" : "<STR_LIT:test>" , "<STR_LIT>" : "<STR_LIT>" } ] <EOL> try : <EOL> self . client . admin_query_user ( "<STR_LIT>" ) <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> except e . AdminError : <EOL> pass <EOL> status = self . client . admin_create_user ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> assert status == <NUM_LIT:0> <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> users = self . client . admin_query_user ( "<STR_LIT>" ) <EOL> assert users == [ "<STR_LIT>" ] <EOL> status = self . client . admin_drop_role ( <EOL> "<STR_LIT>" , { '<STR_LIT>' : <NUM_LIT:1000> } ) <EOL> assert status == <NUM_LIT:0> <EOL> users = self . client . admin_query_user ( "<STR_LIT>" ) <EOL> assert users == [ ] <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> def test_drop_role_positive ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . client . admin_query_role ( "<STR_LIT>" ) <EOL> self . client . admin_drop_role ( "<STR_LIT>" ) <EOL> except e . InvalidRole : <EOL> pass <EOL> self . client . admin_create_role ( "<STR_LIT>" , <EOL> [ { "<STR_LIT:code>" : aerospike . PRIV_USER_ADMIN } , <EOL> { "<STR_LIT:code>" : aerospike . PRIV_SYS_ADMIN } ] ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> roles = self . client . admin_query_role ( "<STR_LIT>" ) <EOL> assert roles == [ <EOL> { "<STR_LIT:code>" : <NUM_LIT:0> , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , { "<STR_LIT:code>" : <NUM_LIT:1> , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] <EOL> try : <EOL> self . client . admin_query_user ( "<STR_LIT>" ) <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> except e . AdminError : <EOL> pass <EOL> status = self . client . admin_create_user ( "<STR_LIT>" , "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> assert status == <NUM_LIT:0> <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> users = self . client . admin_query_user ( "<STR_LIT>" ) <EOL> assert users == [ "<STR_LIT>" ] <EOL> status = self . client . admin_drop_role ( "<STR_LIT>" ) <EOL> assert status == <NUM_LIT:0> <EOL> users = self . client . admin_query_user ( "<STR_LIT>" ) <EOL> assert users == [ ] <EOL> self . client . admin_drop_user ( "<STR_LIT>" ) <EOL> def test_drop_non_existent_role ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . client . admin_drop_role ( "<STR_LIT>" ) <EOL> except e . InvalidRole as exception : <EOL> assert exception . code == <NUM_LIT> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_drop_role_rolename_None ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . client . admin_drop_role ( None ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_drop_role_with_incorrect_policy ( self ) : <EOL> """<STR_LIT>""" <EOL> status = self . client . admin_create_role ( <EOL> "<STR_LIT>" , <EOL> [ { "<STR_LIT:code>" : aerospike . PRIV_USER_ADMIN } ] ) <EOL> assert status == <NUM_LIT:0> <EOL> try : <EOL> self . client . admin_drop_role ( "<STR_LIT>" , { "<STR_LIT>" : <NUM_LIT> } ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> self . client . admin_drop_role ( "<STR_LIT>" ) </s>
