Example #1
0
def test_sync_certificates_same_cert_same_name(user, source,
                                               sync_source_plugin):
    from lemur.sources.service import sync_certificates, certificate_create
    from lemur.certificates import service as cert_service
    from lemur.plugins.base import plugins

    # create an existing cert with same body
    data = {
        "name": "WildcardCert2",
        "body": WILDCARD_CERT_STR,
        "private_key": WILDCARD_CERT_KEY,
        "owner": "*****@*****.**",
        "creator": user["user"],
    }
    certificate_create(data, source)

    # sync a certificate with same body
    s = plugins.get(source.plugin_name)
    s.certificates = [
        {
            "name": "WildcardCert2",
            "body": WILDCARD_CERT_STR,
        },
    ]

    res = sync_certificates(source, user["user"])

    assert res == (0, 1, 1)
    assert cert_service.get_by_name("WildcardCert2") is not None
Example #2
0
def test_sync_certificates_different_cert_existing_name(
        user, source, sync_source_plugin):
    from lemur.sources.service import sync_certificates, certificate_create
    from lemur.certificates import service as cert_service
    from lemur.plugins.base import plugins

    # create an existing cert with same body
    data = {
        "name": "MyCert1",
        "body": WILDCARD_CERT_STR,
        "private_key": WILDCARD_CERT_KEY,
        "owner": "*****@*****.**",
        "creator": user["user"],
    }
    certificate_create(data, source)

    # sync a certificate with same body
    s = plugins.get(source.plugin_name)
    s.certificates = [
        {
            "name": "MyCert1",
            "body": SAN_CERT_STR,
        },
    ]

    with pytest.raises(Exception):
        sync_certificates(source, user["user"])
Example #3
0
def test_create_certificate(source):
    from lemur.sources.service import certificate_create

    with pytest.raises(Exception):
        certificate_create({}, source)

    data = {
        'body': INTERNAL_VALID_WILDCARD_STR,
        'private_key': INTERNAL_PRIVATE_KEY_A_STR,
        'owner': '*****@*****.**'
    }

    cert = certificate_create(data, source)
    assert cert.notifications
Example #4
0
def test_create_certificate(user, source):
    from lemur.sources.service import certificate_create

    with pytest.raises(Exception):
        certificate_create({}, source)

    data = {
        'body': INTERNAL_VALID_WILDCARD_STR,
        'private_key': INTERNAL_PRIVATE_KEY_A_STR,
        'owner': '*****@*****.**',
        'creator': user['user']
    }

    cert = certificate_create(data, source)
    assert cert.notifications
Example #5
0
def test_create_certificate(user, source):
    from lemur.sources.service import certificate_create

    with pytest.raises(Exception):
        certificate_create({}, source)

    data = {
        "body": WILDCARD_CERT_STR,
        "private_key": WILDCARD_CERT_KEY,
        "owner": "*****@*****.**",
        "creator": user["user"],
    }

    cert = certificate_create(data, source)
    assert cert.notifications
Example #6
0
def test_create_certificate(user, source):
    from lemur.sources.service import certificate_create

    with pytest.raises(Exception):
        certificate_create({}, source)

    data = {
        'body': WILDCARD_CERT_STR,
        'private_key': WILDCARD_CERT_KEY,
        'owner': '*****@*****.**',
        'creator': user['user']
    }

    cert = certificate_create(data, source)
    assert cert.notifications