コード例 #1
0
def test_crt_missmatch():
    '''
    Forged certificate should raise napalm_logs.exceptions.SSLMismatchException.
    '''
    nlap = NapalmLogsAuthProc('tests/auth/forged.crt', 'tests/auth/forged.key',
                              'fake_pk', 'fake_hex')
    with pytest.raises(napalm_logs.exceptions.SSLMismatchException):
        nlap.start()
コード例 #2
0
def test_invalid_cert():
    '''
    Testing if the auth process dies when
    unable to open the SSL certificate or keyfile.
    '''
    nlap = NapalmLogsAuthProc('fake_cert', 'fake_keyfile', 'fake_pk',
                              'fake_hex')
    with pytest.raises(IOError):
        nlap.start()
コード例 #3
0
def test_twice_bind():
    '''
    Test that binding twice on the same host/port fails,
    and raises napalm_logs.exceptions.BindException.
    '''
    pk, sgn_key = _generate_test_keys()
    nlap = NapalmLogsAuthProc('tests/auth/server.crt', 'tests/auth/server.key',
                              pk, sgn_key)
    assert AUTH_PROC.is_alive()
    time.sleep(.1)  # waiting for the auth socket
    with pytest.raises(napalm_logs.exceptions.BindException):
        nlap.start()
    nlap.stop()