<s> """<STR_LIT>""" <EOL> from grr . gui import runtests_test <EOL> from grr . lib import flags <EOL> from grr . lib import flow <EOL> from grr . lib import queue_manager <EOL> from grr . lib import test_lib <EOL> from grr . lib . rdfvalues import client as rdf_client <EOL> from grr . lib . rdfvalues import flows as rdf_flows <EOL> class TestInspectViewBase ( test_lib . GRRSeleniumTest ) : <EOL> pass <EOL> class TestClientLoadView ( TestInspectViewBase ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def CreateLeasedClientRequest ( <EOL> client_id = rdf_client . ClientURN ( "<STR_LIT>" ) , <EOL> token = None ) : <EOL> flow . GRRFlow . StartFlow ( client_id = client_id , <EOL> flow_name = "<STR_LIT>" , token = token ) <EOL> with queue_manager . QueueManager ( token = token ) as manager : <EOL> manager . QueryAndOwn ( client_id . Queue ( ) , limit = <NUM_LIT:1> , lease_seconds = <NUM_LIT> ) <EOL> @ staticmethod <EOL> def FillClientStats ( client_id = rdf_client . ClientURN ( "<STR_LIT>" ) , <EOL> token = None ) : <EOL> for minute in range ( <NUM_LIT:6> ) : <EOL> stats = rdf_client . ClientStats ( ) <EOL> for i in range ( minute * <NUM_LIT> , ( minute + <NUM_LIT:1> ) * <NUM_LIT> ) : <EOL> sample = rdf_client . CpuSample ( <EOL> timestamp = int ( i * <NUM_LIT:10> * <NUM_LIT> ) , <EOL> user_cpu_time = <NUM_LIT:10> + i , <EOL> system_cpu_time = <NUM_LIT:20> + i , <EOL> cpu_percent = <NUM_LIT:10> + i ) <EOL> stats . cpu_samples . Append ( sample ) <EOL> sample = rdf_client . IOSample ( <EOL> timestamp = int ( i * <NUM_LIT:10> * <NUM_LIT> ) , <EOL> read_bytes = <NUM_LIT:10> + i , <EOL> write_bytes = <NUM_LIT:10> + i * <NUM_LIT:2> ) <EOL> stats . io_samples . Append ( sample ) <EOL> message = rdf_flows . GrrMessage ( source = client_id , <EOL> args = stats . SerializeToString ( ) ) <EOL> flow . WellKnownFlow . GetAllWellKnownFlows ( <EOL> token = token ) [ "<STR_LIT>" ] . ProcessMessage ( message ) <EOL> def testNoClientActionIsDisplayed ( self ) : <EOL> with self . ACLChecksDisabled ( ) : <EOL> self . RequestAndGrantClientApproval ( "<STR_LIT>" ) <EOL> self . Open ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsTextPresent , "<STR_LIT>" ) <EOL> def testNoClientActionIsDisplayedWhenFlowIsStarted ( self ) : <EOL> with self . ACLChecksDisabled ( ) : <EOL> self . RequestAndGrantClientApproval ( "<STR_LIT>" ) <EOL> self . Open ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsTextPresent , "<STR_LIT>" ) <EOL> flow . GRRFlow . StartFlow ( client_id = rdf_client . ClientURN ( "<STR_LIT>" ) , <EOL> flow_name = "<STR_LIT>" , token = self . token ) <EOL> def testClientActionIsDisplayedWhenItReceiveByTheClient ( self ) : <EOL> with self . ACLChecksDisabled ( ) : <EOL> self . RequestAndGrantClientApproval ( "<STR_LIT>" ) <EOL> self . CreateLeasedClientRequest ( token = self . token ) <EOL> self . Open ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsTextPresent , "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsTextPresent , "<STR_LIT>" ) <EOL> class TestDebugClientRequestsView ( TestInspectViewBase ) : <EOL> """<STR_LIT>""" <EOL> def testInspect ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . ACLChecksDisabled ( ) : <EOL> self . RequestAndGrantClientApproval ( "<STR_LIT>" ) <EOL> self . Open ( "<STR_LIT:/>" ) <EOL> self . Type ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . WaitUntilEqual ( u"<STR_LIT>" , <EOL> self . GetText , "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsElementPresent , "<STR_LIT>" ) <EOL> for request in "<STR_LIT>" . split ( ) : <EOL> self . assertTrue ( self . IsElementPresent ( <EOL> "<STR_LIT>" % request ) ) <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsElementPresent , <EOL> "<STR_LIT>" ) <EOL> self . assertTrue ( <EOL> self . IsElementPresent ( "<STR_LIT>" ) ) <EOL> with self . ACLChecksDisabled ( ) : <EOL> mock = test_lib . MockClient ( rdf_client . ClientURN ( "<STR_LIT>" ) , <EOL> None , token = self . token ) <EOL> while mock . Next ( ) : <EOL> pass <EOL> self . Click ( "<STR_LIT>" ) <EOL> self . WaitUntil ( self . IsElementPresent , "<STR_LIT>" ) <EOL> self . assertTrue ( self . IsElementPresent ( <EOL> "<STR_LIT>" ) ) <EOL> self . assertTrue ( self . IsElementPresent ( <EOL> "<STR_LIT>" ) ) <EOL> def main ( argv ) : <EOL> runtests_test . SeleniumTestProgram ( argv = argv ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> flags . StartMain ( main ) </s>
