Beispiel #1
0
def test_tls_not_running_due_to_pid_clean_up(mocker, tmpdir):
    state = dict(STATE)
    state.pop("pid")

    state_file_dir, state_file = create_state_file(tmpdir,
                                                   content=json.dumps(state))

    clean_up_mock, restart_tls_mock, _, _, _ = setup_mocks(
        mocker,
        mounts={
            "mnt": watchdog.Mount("127.0.0.1", "/mnt", "nfs4", "", "0", "0")
        },
        state_files={"mnt": state_file},
        is_pid_running=True,
    )

    watchdog.check_efs_mounts(
        _get_config(),
        [],
        GRACE_PERIOD,
        UNMOUNT_COUNT,
        state_file_dir=state_file_dir,
    )

    utils.assert_not_called(clean_up_mock)
    utils.assert_called_once(restart_tls_mock)
def test_extra_mount(mocker, tmpdir):
    state_file_dir, state_file = create_state_file(tmpdir)

    clean_up_mock, restart_tls_mock = setup_mocks(
        mocker,
        mounts={
            'mnt': watchdog.Mount('127.0.0.1', '/mnt', 'nfs4', '', '0', '0'),
            'mnt2': watchdog.Mount('192.168.1.1', '/mnt2', 'nfs4', '', '0',
                                   '0'),
        },
        state_files={'mnt': state_file})

    watchdog.check_efs_mounts([], GRACE_PERIOD, state_file_dir)

    clean_up_mock.assert_not_called()
    restart_tls_mock.assert_not_called()
Beispiel #3
0
def test_ap_mount_with_extra_mount(mocker, tmpdir):
    state_file_dir, state_file = create_state_file(tmpdir)

    clean_up_mock, restart_tls_mock, check_certificate_call = setup_mocks(
        mocker,
        mounts={
            'mnt': watchdog.Mount('127.0.0.1', '/mnt', 'nfs4', '', '0', '0'),
            'mnt2': watchdog.Mount('192.168.1.1', '/mnt2', 'nfs4', '', '0',
                                   '0'),
        },
        state_files={'mnt': state_file})

    watchdog.check_efs_mounts(_get_config(), [], GRACE_PERIOD, state_file_dir)

    utils.assert_not_called(clean_up_mock)
    utils.assert_not_called(restart_tls_mock)
    utils.assert_called_once(check_certificate_call)
Beispiel #4
0
def test_no_state_files(mocker):
    clean_up_mock, restart_tls_mock, _ = setup_mocks(
        mocker,
        mounts={
            'mnt': watchdog.Mount('127.0.0.1', '/mnt', 'nfs4', '', '0', '0')
        },
        state_files={})

    watchdog.check_efs_mounts(_get_config(), [], GRACE_PERIOD)

    utils.assert_not_called(clean_up_mock)
    utils.assert_not_called(restart_tls_mock)
Beispiel #5
0
def test_no_state_files(mocker):
    clean_up_mock, restart_tls_mock, _, _, _ = setup_mocks(
        mocker,
        mounts={
            "mnt": watchdog.Mount("127.0.0.1", "/mnt", "nfs4", "", "0", "0")
        },
        state_files={},
    )

    watchdog.check_efs_mounts(_get_config(), [], GRACE_PERIOD, UNMOUNT_COUNT)

    utils.assert_not_called(clean_up_mock)
    utils.assert_not_called(restart_tls_mock)
def test_no_state_files(mocker):
    clean_up_mock, restart_tls_mock = setup_mocks(mocker,
                                                  mounts={
                                                      'mnt':
                                                      watchdog.Mount(
                                                          '127.0.0.1', '/mnt',
                                                          'nfs4', '', '0', '0')
                                                  },
                                                  state_files={})

    watchdog.check_efs_mounts([], GRACE_PERIOD)

    clean_up_mock.assert_not_called()
    restart_tls_mock.assert_not_called()
Beispiel #7
0
def test_tls_not_running(mocker, tmpdir):
    state_file_dir, state_file = create_state_file(tmpdir)

    clean_up_mock, restart_tls_mock, _ = setup_mocks(
        mocker,
        mounts={
            'mnt': watchdog.Mount('127.0.0.1', '/mnt', 'nfs4', '', '0', '0')
        },
        state_files={'mnt': state_file},
        is_pid_running=False)

    watchdog.check_efs_mounts(_get_config(), [], GRACE_PERIOD, state_file_dir)

    utils.assert_not_called(clean_up_mock)
    utils.assert_called_once(restart_tls_mock)
Beispiel #8
0
def test_ap_mount_with_extra_mount(mocker, tmpdir):
    state_file_dir, state_file = create_state_file(tmpdir)

    clean_up_mock, restart_tls_mock, check_certificate_call, _, _ = setup_mocks(
        mocker,
        mounts={
            "mnt": watchdog.Mount("127.0.0.1", "/mnt", "nfs4", "", "0", "0"),
            "mnt2": watchdog.Mount("192.168.1.1", "/mnt2", "nfs4", "", "0",
                                   "0"),
        },
        state_files={"mnt": state_file},
    )

    watchdog.check_efs_mounts(
        _get_config(),
        [],
        GRACE_PERIOD,
        UNMOUNT_COUNT,
        state_file_dir=state_file_dir,
    )

    utils.assert_not_called(clean_up_mock)
    utils.assert_not_called(restart_tls_mock)
    utils.assert_called_once(check_certificate_call)
Beispiel #9
0
def test_tls_not_running_due_to_pid_clean_up(mocker, tmpdir):
    state = dict(STATE)
    state.pop('pid')

    state_file_dir, state_file = create_state_file(tmpdir,
                                                   content=json.dumps(state))

    clean_up_mock, restart_tls_mock, _ = setup_mocks(
        mocker,
        mounts={
            'mnt': watchdog.Mount('127.0.0.1', '/mnt', 'nfs4', '', '0', '0')
        },
        state_files={'mnt': state_file},
        is_pid_running=True)

    watchdog.check_efs_mounts(_get_config(), [], GRACE_PERIOD, state_file_dir)

    utils.assert_not_called(clean_up_mock)
    utils.assert_called_once(restart_tls_mock)
Beispiel #10
0
def test_tls_not_running(mocker, tmpdir):
    state_file_dir, state_file = create_state_file(tmpdir)

    clean_up_mock, restart_tls_mock, _, _, _ = setup_mocks(
        mocker,
        mounts={
            "mnt": watchdog.Mount("127.0.0.1", "/mnt", "nfs4", "", "0", "0")
        },
        state_files={"mnt": state_file},
        is_pid_running=False,
    )

    watchdog.check_efs_mounts(
        _get_config(),
        [],
        GRACE_PERIOD,
        UNMOUNT_COUNT,
        state_file_dir=state_file_dir,
    )

    utils.assert_not_called(clean_up_mock)
    utils.assert_called_once(restart_tls_mock)