Exemplo n.º 1
0
 def test_re_enroll_mit_update(self):
     ms, action = enroll("0123456789", None, "godzilla", "192.168.1.1")
     ms2, action2 = enroll("0123456789", None, "godzilla", "192.168.1.1")
     ms3, action3 = enroll("0123456789", None, "godzilla", "192.168.1.167")
     self.assertEqual(ms3.machinesnapshotcommit_set.all()[0].parent.machine_snapshot, ms2)
     self.assertEqual(ms3.public_ip_address, "192.168.1.167")
     self.assertEqual(action3, "re-enrollment")
Exemplo n.º 2
0
 def test_re_enroll_mit_update(self):
     machine_serial_number = get_random_string(64)
     ms, action = enroll(self.enrollment, machine_serial_number, None, "godzilla", "192.168.1.1")
     ms2, action2 = enroll(self.enrollment, machine_serial_number, None, "godzilla", "192.168.1.1")
     ms3, action3 = enroll(self.enrollment, machine_serial_number, None, "godzilla", "192.168.1.167")
     self.assertEqual(ms3.machinesnapshotcommit_set.all()[0].parent.machine_snapshot, ms2)
     self.assertEqual(ms3.public_ip_address, "192.168.1.167")
     self.assertEqual(action3, "re-enrollment")
Exemplo n.º 3
0
 def test_re_enroll_mit_update(self):
     ms, action = enroll("0123456789", None, "godzilla", "192.168.1.1")
     ms2, action2 = enroll("0123456789", None, "godzilla", "192.168.1.1")
     ms3, action3 = enroll("0123456789", None, "godzilla", "192.168.1.167")
     self.assertEqual(
         ms3.machinesnapshotcommit_set.all()[0].parent.machine_snapshot,
         ms2)
     self.assertEqual(ms3.public_ip_address, "192.168.1.167")
     self.assertEqual(action3, "re-enrollment")
Exemplo n.º 4
0
 def test_re_enroll(self):
     bu, _ = BusinessUnit.objects.commit({"name": "yo",
                                          "reference": "yo",
                                          "source": {"module": "io.zentral.tests",
                                                     "name": "tests"}})
     ms, action = enroll("0123456789", bu, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     ms2, action2 = enroll("0123456789", bu, "godzilla", "192.168.1.1")
     self.assertEqual(ms, ms2)
     self.assertEqual(action2, "re-enrollment")
     self.assertEqual(ms.business_unit, bu)
Exemplo n.º 5
0
 def test_re_enroll(self):
     bu, _ = BusinessUnit.objects.commit({"name": "yo",
                                          "reference": "yo",
                                          "source": {"module": "io.zentral.tests",
                                                     "name": "tests"}})
     machine_serial_number = get_random_string(64)
     ms, action = enroll(self.enrollment, machine_serial_number, bu, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     ms2, action2 = enroll(self.enrollment, machine_serial_number, bu, "godzilla", "192.168.1.1")
     self.assertEqual(ms, ms2)
     self.assertEqual(action2, "re-enrollment")
     self.assertEqual(ms.business_unit, bu)
Exemplo n.º 6
0
 def test_re_enroll(self):
     bu, _ = BusinessUnit.objects.commit({
         "name": "yo",
         "reference": "yo",
         "source": {
             "module": "io.zentral.tests",
             "name": "tests"
         }
     })
     ms, action = enroll("0123456789", bu, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     ms2, action2 = enroll("0123456789", bu, "godzilla", "192.168.1.1")
     self.assertEqual(ms, ms2)
     self.assertEqual(action2, "re-enrollment")
     self.assertEqual(ms.business_unit, bu)
Exemplo n.º 7
0
 def do_post(self, data):
     ms, action = enroll(self.machine_serial_number,
                         self.business_unit,
                         data.get("host_identifier"))
     post_enrollment_event(ms.machine.serial_number,
                           self.user_agent, self.ip,
                           {'action': action})
     return {'node_key': ms.reference}
Exemplo n.º 8
0
 def do_post(self, data):
     ms, action = enroll(self.machine_serial_number, self.business_unit,
                         data.get("host_identifier"), self.ip)
     if ms and action:
         post_enrollment_event(ms.serial_number, self.user_agent, self.ip,
                               {'action': action})
         return {'node_key': ms.reference}
     else:
         raise RuntimeError("Could not enroll client")
Exemplo n.º 9
0
 def test_enroll(self):
     machine_serial_number = get_random_string(64)
     ms, action = enroll(self.enrollment, machine_serial_number, None, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     self.assertEqual(ms.serial_number, machine_serial_number)
     self.assertEqual(ms.public_ip_address, "192.168.1.1")
     self.assertEqual(ms.system_info.computer_name, "godzilla")
     self.assertEqual(set(mt.tag for mt in MachineTag.objects.filter(serial_number=machine_serial_number)),
                      set(self.tags))
Exemplo n.º 10
0
 def do_post(self, data):
     machine_snapshot, action = enroll(self.enrollment,
                                       self.machine_serial_number,
                                       self.business_unit,
                                       data.get("host_identifier"), self.ip)
     if machine_snapshot and action:
         post_enrollment_event(machine_snapshot.serial_number,
                               self.user_agent, self.ip, {'action': action})
         return {'node_key': machine_snapshot.reference}
     else:
         raise SuspiciousOperation("Could not enroll machine")
Exemplo n.º 11
0
 def test_enroll(self):
     ms, action = enroll("0123456789", None, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     self.assertEqual(ms.serial_number, "0123456789")
     self.assertEqual(ms.public_ip_address, "192.168.1.1")
     self.assertEqual(ms.system_info.computer_name, "godzilla")
Exemplo n.º 12
0
 def test_enroll(self):
     ms, action = enroll("0123456789", None, "godzilla", "192.168.1.1")
     self.assertEqual(action, "enrollment")
     self.assertEqual(ms.serial_number, "0123456789")
     self.assertEqual(ms.public_ip_address, "192.168.1.1")
     self.assertEqual(ms.system_info.computer_name, "godzilla")