예제 #1
0
파일: client_test.py 프로젝트: mmaj5524/grr
 def testGetAddrFromFleetspeakMissing(self):
   client_id = client_plugin.ApiClientId("C." + "1" * 16)
   conn = mock.MagicMock()
   conn.outgoing.ListClients.return_value = admin_pb2.ListClientsResponse(
       clients=[
           admin_pb2.Client(
               client_id=fleetspeak_utils.GRRIDToFleetspeakID(client_id),
               last_contact_time=TSProtoFromString("2018-01-01T00:00:01Z"),
               last_clock=TSProtoFromString("2018-01-01T00:00:02Z"))
       ])
   with mock.patch.object(fleetspeak_connector, "CONN", conn):
     ip_str, ipaddr_obj = client_plugin._GetAddrFromFleetspeak(client_id)
     self.assertEqual(ip_str, "")
     self.assertIsNone(ipaddr_obj)
예제 #2
0
파일: client_test.py 프로젝트: google/grr
 def testGetAddrFromFleetspeakMissing(self):
   client_id = client_plugin.ApiClientId("C." + "1" * 16)
   conn = mock.MagicMock()
   conn.outgoing.ListClients.return_value = admin_pb2.ListClientsResponse(
       clients=[
           admin_pb2.Client(
               client_id=fleetspeak_utils.GRRIDToFleetspeakID(client_id),
               last_contact_time=TSProtoFromString("2018-01-01T00:00:01Z"),
               last_clock=TSProtoFromString("2018-01-01T00:00:02Z"))
       ])
   with mock.patch.object(fleetspeak_connector, "CONN", conn):
     ip_str, ipaddr_obj = client_plugin._GetAddrFromFleetspeak(client_id)
     self.assertEqual(ip_str, "")
     self.assertIsNone(ipaddr_obj)
예제 #3
0
파일: client_test.py 프로젝트: mmaj5524/grr
 def testGetAddrFromFleetspeakIpV6(self):
   client_id = client_plugin.ApiClientId("C." + "1" * 16)
   conn = mock.MagicMock()
   conn.outgoing.ListClients.return_value = admin_pb2.ListClientsResponse(
       clients=[
           admin_pb2.Client(
               client_id=fleetspeak_utils.GRRIDToFleetspeakID(client_id),
               last_contact_address="[2001:0db8:85a3::8a2e:0370:7334]:50000",
               last_contact_time=TSProtoFromString("2018-01-01T00:00:01Z"),
               last_clock=TSProtoFromString("2018-01-01T00:00:02Z"))
       ])
   with mock.patch.object(fleetspeak_connector, "CONN", conn):
     ip_str, ipaddr_obj = client_plugin._GetAddrFromFleetspeak(client_id)
     self.assertEqual(ip_str, "2001:0db8:85a3::8a2e:0370:7334")
     self.assertEqual(
         ipaddr_obj,
         ipaddress.ip_address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))
예제 #4
0
파일: client_test.py 프로젝트: google/grr
 def testGetAddrFromFleetspeakIpV6(self):
   client_id = client_plugin.ApiClientId("C." + "1" * 16)
   conn = mock.MagicMock()
   conn.outgoing.ListClients.return_value = admin_pb2.ListClientsResponse(
       clients=[
           admin_pb2.Client(
               client_id=fleetspeak_utils.GRRIDToFleetspeakID(client_id),
               last_contact_address="[2001:0db8:85a3::8a2e:0370:7334]:50000",
               last_contact_time=TSProtoFromString("2018-01-01T00:00:01Z"),
               last_clock=TSProtoFromString("2018-01-01T00:00:02Z"))
       ])
   with mock.patch.object(fleetspeak_connector, "CONN", conn):
     ip_str, ipaddr_obj = client_plugin._GetAddrFromFleetspeak(client_id)
     self.assertEqual(ip_str, "2001:0db8:85a3::8a2e:0370:7334")
     self.assertEqual(
         ipaddr_obj,
         ipaddress.ip_address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))