Exemple #1
0
def main():
    try:
        logging.info("Leosac path is [{0}]".format(get_leosac_path()))
        leosac_1 = LeosacRunner("this_test/rpi1-cfg.xml")
        out = insert_card_and_get_output(leosac_1)
        logging.info("Leosac 1 output: {0}".format(out))
        check_access_granted(out)

        leosac_2 = LeosacRunner("this_test/rpi2-cfg.xml")
        out = insert_card_and_get_output(leosac_2)
        logging.info("Leosac 2 output: {0}".format(out))
        check_access_denied(out)

    except KeyboardInterrupt:
        logging.error("Interrupted.")
        if leosac_1.returncode is None:
            leosac_1.kill()
        if leosac_2.returncode is None:
            leosac_2.kill()
    except Exception as e:
        logging.exception("Exception occurred: " + str(e))
        if leosac_1.returncode is None:
            leosac_1.kill()
        if leosac_2.returncode is None:
            leosac_2.kill()
    return 0
Exemple #2
0
def test_8bits():
    leosac = LeosacRunner("this_test/config-8bits.xml")
    wiegand = WiegandClient("/tmp/leosac-ipc", "wiegand_data_high", "wiegand_data_low")
    time.sleep(3)

    wiegand.send_8bits_pin("31337")
    leosac.run_at_most(7)
    test_assert(leosac.returncode == 0,
                "Process returned with non-zero exit code ({0})".format(leosac.returncode))
    ret = re.search("^.* 31337$", leosac.out, re.MULTILINE)
    test_assert(ret, "8bits Pin code wasn't read")
Exemple #3
0
def main():
    leosac = LeosacRunner("this_test/test-module-list.xml")

    rc = RemoteController("127.0.0.1:12345", "TJz$:^DbZvFN@wv/ct&[Su6Nnu6w!fMGHEcIttyT")
    cmd = ModuleListCommand()

    rc.execute_command(cmd)
    test_assert(cmd.status is True
                and ("MONITOR" in cmd.modules)
                and ("WIEGAND_READER" in cmd.modules)
                and ("NOT_A_MODULE" not in cmd.modules),
                "Failed to retrieve config from valid module.")

    leosac.run_at_most(10)
Exemple #4
0
def main():
    leosac = LeosacRunner("this_test/test-module-list.xml")

    rc = RemoteController("127.0.0.1:12345",
                          "TJz$:^DbZvFN@wv/ct&[Su6Nnu6w!fMGHEcIttyT")
    cmd = ModuleListCommand()

    rc.execute_command(cmd)
    test_assert(
        cmd.status is True and ("MONITOR" in cmd.modules)
        and ("WIEGAND_READER" in cmd.modules)
        and ("NOT_A_MODULE" not in cmd.modules),
        "Failed to retrieve config from valid module.")

    leosac.run_at_most(10)
Exemple #5
0
def receive_card_number():
    tcp_server = subprocess.Popen(["this_test/tcp_server.py"])
    leosac = LeosacRunner("this_test/config.xml")

    time.sleep(3)
    wiegand = WiegandClient("/tmp/leosac-ipc", "wiegand_data_high", "wiegand_data_low")

    wiegand.send_card("ff:ff:ff:ff")
    wiegand.send_card("00:00:00:10")

    tcp_server.wait()
    leosac.run_at_most(5)
    test_assert(tcp_server.returncode == 0,
                "TCPServer returned with non zero code")
    test_assert(leosac.returncode == 0,
                "Process returned with non-zero exit code ({0})".format(leosac.returncode))
Exemple #6
0
def receive_card_number():
    tcp_server = subprocess.Popen(["this_test/tcp_server.py"])
    leosac = LeosacRunner("this_test/config.xml")

    time.sleep(3)
    wiegand = WiegandClient("/tmp/leosac-ipc", "wiegand_data_high",
                            "wiegand_data_low")

    wiegand.send_card("ff:ff:ff:ff")
    wiegand.send_card("00:00:00:10")

    tcp_server.wait()
    leosac.run_at_most(5)
    test_assert(tcp_server.returncode == 0,
                "TCPServer returned with non zero code")
    test_assert(
        leosac.returncode == 0,
        "Process returned with non-zero exit code ({0})".format(
            leosac.returncode))
Exemple #7
0
def main():
    leosac = LeosacRunner("this_test/test-module-config.xml")

    rc = RemoteController("127.0.0.1:12345", "TJz$:^DbZvFN@wv/ct&[Su6Nnu6w!fMGHEcIttyT")
    cmd_existing_module = ModuleConfigCommand("MONITOR")  # xml format

    rc.execute_command(cmd_existing_module)
    test_assert(cmd_existing_module.status is True
                and cmd_existing_module.module == "MONITOR",
                "Failed to retrieve config from valid module.")

    cmd_invalid_module = ModuleConfigCommand("INVALID_MODULE_BLA")
    rc.execute_command(cmd_invalid_module)
    test_assert(cmd_invalid_module.status is False,
                "Managed to retrieve config from invalid module.")

    leosac.interrupt()
    leosac.wait_abort(30)
Exemple #8
0
def main():
    try:
        logging.info("Leosac path is [{0}]".format(get_leosac_path()))
        leosac_1 = LeosacRunner("this_test/rpi1-cfg.xml")
        out = insert_card_and_get_output(leosac_1)
        logging.info("Leosac 1 output: {0}".format(out))
        check_access_granted(out)

        leosac_2 = LeosacRunner("this_test/rpi2-cfg.xml")
        out = insert_card_and_get_output(leosac_2)
        logging.info("Leosac 2 output: {0}".format(out))
        check_access_denied(out)

    except KeyboardInterrupt:
        logging.error("Interrupted.")
        if leosac_1.returncode is None:
            leosac_1.kill()
        if leosac_2.returncode is None:
            leosac_2.kill()
    except Exception as e:
        logging.exception("Exception occurred: " + str(e))
        if leosac_1.returncode is None:
            leosac_1.kill()
        if leosac_2.returncode is None:
            leosac_2.kill()
    return 0