Пример #1
0
def test_wrong_credentials_with_ntlm(opt_adcs, opt_username, opt_password):
    with pytest.raises(RequestException) as excinfo:
        certsrv.get_existing_cert(opt_adcs,
                                  -1,
                                  'wronguser',
                                  'wrongpassword',
                                  auth_method='ntlm')
    assert excinfo.value.response.reason == 'Unauthorized'
Пример #2
0
def test_get_existing_cert_with_wrong_cafile(opt_adcs):
    dir_path = os.path.dirname(os.path.realpath(__file__))
    ca_bundle = '%s/test_dummy-ca-cert.pem' % dir_path
    with pytest.raises(SSLError) as excinfo:
        certsrv.get_existing_cert(opt_adcs,
                                  1,
                                  'username',
                                  'password',
                                  cafile=ca_bundle)
Пример #3
0
def test_get_existing_cert_der(opt_adcs, opt_username, opt_password):
    # Request number 1 should always exist, right?
    der_cert = certsrv.get_existing_cert(opt_adcs, 1, opt_username, opt_password, 'bin')
    cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, der_cert)
Пример #4
0
def test_get_existing_cert_pem(opt_adcs, opt_username, opt_password):
    # Request number 1 should always exist, right?
    pem_cert = certsrv.get_existing_cert(opt_adcs, 1, opt_username, opt_password)
    cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, pem_cert)
Пример #5
0
def test_get_non_existing_cert(opt_adcs, opt_username, opt_password):
    with pytest.raises(certsrv.CouldNotRetrieveCertificateException) as excinfo:
        certsrv.get_existing_cert(opt_adcs, -1, opt_username, opt_password)
Пример #6
0
def test_get_existing_cert_with_wrong_cafile(opt_adcs):
    dir_path = os.path.dirname(os.path.realpath(__file__))
    ca_bundle = '%s/test_dummy-ca-cert.pem' % dir_path
    with pytest.raises(URLError) as excinfo:
        certsrv.get_existing_cert(opt_adcs, 1, 'username', 'password', cafile=ca_bundle)
    assert excinfo.value.reason.reason == 'CERTIFICATE_VERIFY_FAILED'
Пример #7
0
def test_wrong_credentials_with_ntlm(opt_adcs, opt_username, opt_password):
    # We should throw a HTTPError even when ntlm auth
    with pytest.raises(HTTPError) as excinfo:
        certsrv.get_existing_cert(opt_adcs, -1, 'wronguser', 'wrongpassword', auth_method='ntlm')
    assert excinfo.value.msg == 'Unauthorized'
Пример #8
0
def test_wrong_credentials(opt_adcs, opt_username, opt_password):
    with pytest.raises(HTTPError) as excinfo:
        certsrv.get_existing_cert(opt_adcs, -1, 'wronguser', 'wrongpassword')
    assert excinfo.value.msg == 'Unauthorized'