Exemplo n.º 1
0
def test_no_retry_when_filenotfound(config, mocker):
    KrbCommand.kdestroy(config)

    raise_exception = [FileNotFoundError, None]
    patcher = mocker.patch('subprocess.check_output',
                           side_effect=raise_exception)
    try:
        KrbCommand.kinit(config)
        pytest.fail()
    except FileNotFoundError:
        assert patcher.call_count == 1
Exemplo n.º 2
0
def test_retry(config, mocker):
    KrbCommand.kdestroy(config)

    raise_exception_twice = [
        subprocess.CalledProcessError(1, ['kinit']),
        subprocess.CalledProcessError(1, ['kinit']), None
    ]
    patcher = mocker.patch('subprocess.check_output',
                           side_effect=raise_exception_twice)
    KrbCommand.kinit(config)
    assert patcher.call_count == 3
Exemplo n.º 3
0
def _test_commands(config):
    KrbCommand.kdestroy(config)
    KrbCommand.kinit(config)
    KrbCommand.renewal(config)
    KrbCommand.klist(config)
    KrbCommand.kdestroy(config)
Exemplo n.º 4
0
def test_kinit_command(config, expected, mocker):
    mocker.patch.object(KrbCommand, '_call')
    KrbCommand.kinit(config)
    KrbCommand._call.assert_called_with(config, expected)