def testGetPayload_simple(self):
   string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
   header = string_buffer.readline()
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   payload_string = command_sequence._parser._GetPayloadString(header)
   self.assertEqual(payload_string, '{"param2": 42\n}\n')
Exemplo n.º 2
0
 def testGetPayload_badscript(self):
   string_buffer = StringIO.StringIO(_BAD_SCRIPT)
   header = string_buffer.readline()
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   payload_string = command_sequence._parser._GetPayloadString(header)
   self.assertEqual(payload_string, '{"param2": "))}\\})}/{)}({(})}"\n}\n')
Exemplo n.º 3
0
 def testGetPayload_script(self):
   string_buffer = StringIO.StringIO(_PAYLOAD_SCRIPT)
   header = string_buffer.readline()
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   payload_string = command_sequence._parser._GetPayloadString(header)
   self.assertEqual(payload_string, '{"param2": "function(){func()}"\n}\n')
 def testGetPayload_simple(self):
     string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
     header = string_buffer.readline()
     command_sequence = client_replay.CommandSequence()
     command_sequence._parser = client_replay._Parser(string_buffer)
     payload_string = command_sequence._parser._GetPayloadString(header)
     self.assertEqual(payload_string, '{"param2": 42\n}\n')
 def testGetPayload_badscript(self):
   string_buffer = StringIO.StringIO(_BAD_SCRIPT)
   header = string_buffer.readline()
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   payload_string = command_sequence._parser._GetPayloadString(header)
   self.assertEqual(payload_string, '{"param2": "))}\\})}/{)}({(})}"\n}\n')
 def testGetPayload_script(self):
   string_buffer = StringIO.StringIO(_PAYLOAD_SCRIPT)
   header = string_buffer.readline()
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   payload_string = command_sequence._parser._GetPayloadString(header)
   self.assertEqual(payload_string, '{"param2": "function(){func()}"\n}\n')
Exemplo n.º 7
0
 def testGetNextClientHeaderLine(self):
   string_buffer = StringIO.StringIO(_PAYLOAD_SCRIPT)
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   self.assertEquals(command_sequence._parser._GetNextClientHeaderLine(),
       ("[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]"
           " RESPONSE GetTitle {\n"))
Exemplo n.º 8
0
 def testGetNextClientHeaderLine_readableTime(self):
   string_buffer = StringIO.StringIO(_PAYLOAD_READABLE_TIME)
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   self.assertEquals(command_sequence._parser._GetNextClientHeaderLine(),
       ("[08-12-2019_15:45:34.824002][INFO]:"
        " [b15232d5497ec0d8300a5a1ea56f33ce] RESPONSE GetTitle {\n"))
  def testParserGetNext(self):
    string_buffer = StringIO.StringIO(_WITH_PARAMS)
    command_sequence = client_replay.CommandSequence()
    command_sequence._parser = client_replay._Parser(string_buffer)
    command = command_sequence._parser.GetNext()

    self.assertEqual(command.name, "GetTitle")
    self.assertEqual(command.GetPayloadPrimitive(), {"param1": 7})
    self.assertEqual(command.session_id, _SESSION_ID)
    def testParserGetNext(self):
        string_buffer = StringIO.StringIO(_WITH_PARAMS)
        command_sequence = client_replay.CommandSequence()
        command_sequence._parser = client_replay._Parser(string_buffer)
        command = command_sequence._parser.GetNext()

        self.assertEqual(command.name, "GetTitle")
        self.assertEqual(command.GetPayloadPrimitive(), {"param1": 7})
        self.assertEqual(command.session_id, _SESSION_ID)
    def testIngestLoggedResponse(self):
        string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
        command_sequence = client_replay.CommandSequence()
        command_sequence._parser = client_replay._Parser(string_buffer)
        response = command_sequence._parser.GetNext()

        self.assertEqual(response.name, "GetTitle")
        self.assertEqual(response.GetPayloadPrimitive(), {"param2": 42})
        self.assertEqual(response.session_id, _SESSION_ID)
Exemplo n.º 12
0
  def testIngestLoggedResponse(self):
    string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
    command_sequence = client_replay.CommandSequence()
    command_sequence._parser = client_replay._Parser(string_buffer)
    response = command_sequence._parser.GetNext()

    self.assertEqual(response.name, "GetTitle")
    self.assertEqual(response.GetPayloadPrimitive(), {"param2": 42})
    self.assertEqual(response.session_id, _SESSION_ID)
Exemplo n.º 13
0
  def testNextCommandEmptyParams(self):
    string_buffer = StringIO.StringIO(_NO_PARAMS)
    command_sequence = client_replay.CommandSequence()
    command_sequence._parser = client_replay._Parser(string_buffer)
    command = command_sequence.NextCommand(None)
    response = command_sequence._last_response

    self.assertEqual(command.name, "GetTitle")
    self.assertEqual(command.GetPayloadPrimitive(), {"sessionId": _SESSION_ID})
    self.assertEqual(command.session_id, _SESSION_ID)

    self.assertEqual(response.name, "GetTitle")
    self.assertEqual(response.GetPayloadPrimitive(), None)
    self.assertEqual(response.session_id, _SESSION_ID)
Exemplo n.º 14
0
  def testNextCommandEmptyParams(self):
    string_buffer = StringIO.StringIO(_NO_PARAMS)
    command_sequence = client_replay.CommandSequence()
    command_sequence._parser = client_replay._Parser(string_buffer)
    command = command_sequence.NextCommand(None)
    response = command_sequence._last_response

    self.assertEqual(command.name, "GetTitle")
    self.assertEqual(command.GetPayloadPrimitive(), {"sessionId": _SESSION_ID})
    self.assertEqual(command.session_id, _SESSION_ID)

    self.assertEqual(response.name, "GetTitle")
    self.assertEqual(response.GetPayloadPrimitive(), None)
    self.assertEqual(response.session_id, _SESSION_ID)
 def testParseResponse_false(self):
     string_buffer = StringIO.StringIO(_COMMAND_ONLY)
     command_sequence = client_replay.CommandSequence()
     command_sequence._parser = client_replay._Parser(string_buffer)
     self.assertFalse(command_sequence._parser.GetNext().IsResponse())
 def testParseResponse_true(self):
     string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
     command_sequence = client_replay.CommandSequence()
     command_sequence._parser = client_replay._Parser(string_buffer)
     self.assertTrue(command_sequence._parser.GetNext().IsResponse())
 def testParseCommand_true(self):
     string_buffer = StringIO.StringIO(_COMMAND_ONLY)
     command_sequence = client_replay.CommandSequence()
     command_sequence._parser = client_replay._Parser(string_buffer)
     self.assertTrue(command_sequence._parser.GetNext().IsCommand())
Exemplo n.º 18
0
 def testParseCommand_true(self):
   string_buffer = StringIO.StringIO(_COMMAND_ONLY)
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   self.assertTrue(command_sequence._parser.GetNext().IsCommand())
Exemplo n.º 19
0
 def testParseResponse_true(self):
   string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   self.assertTrue(command_sequence._parser.GetNext().IsResponse())
Exemplo n.º 20
0
 def testParseResponse_false(self):
   string_buffer = StringIO.StringIO(_COMMAND_ONLY)
   command_sequence = client_replay.CommandSequence()
   command_sequence._parser = client_replay._Parser(string_buffer)
   self.assertFalse(command_sequence._parser.GetNext().IsResponse())
Exemplo n.º 21
0
 def testParseCommand_false(self):
     string_buffer = io.StringIO(_RESPONSE_ONLY)
     command_sequence = client_replay.CommandSequence()
     command_sequence._parser = client_replay._Parser(string_buffer)
     self.assertFalse(command_sequence._parser.GetNext().IsCommand())