Exemplo n.º 1
0
def test_get_eligible_certificates(app, certificate, notification):
    from lemur.notifications.messaging import get_eligible_certificates

    certificate.notifications.append(notification)
    certificate.notifications[0].options = [{'name': 'interval', 'value': 10}, {'name': 'unit', 'value': 'days'}]

    delta = certificate.not_after - timedelta(days=10)
    with freeze_time(delta.datetime):
        assert get_eligible_certificates() == {certificate.owner: {notification.label: [(notification, certificate)]}}
Exemplo n.º 2
0
def test_get_eligible_certificates(app, certificate, notification):
    from lemur.notifications.messaging import get_eligible_certificates

    certificate.notifications.append(notification)
    certificate.notifications[0].options = [
        {"name": "interval", "value": 10},
        {"name": "unit", "value": "days"},
    ]

    delta = certificate.not_after - timedelta(days=10)
    with freeze_time(delta.datetime):
        assert get_eligible_certificates() == {
            certificate.owner: {notification.label: [(notification, certificate)]}
        }
Exemplo n.º 3
0
def test_get_eligible_certificates(app, certificate, notification):
    from lemur.notifications.messaging import get_eligible_certificates

    certificate.notifications.append(notification)
    certificate.notifications[0].options = [{
        'name': 'interval',
        'value': 10
    }, {
        'name': 'unit',
        'value': 'days'
    }]

    delta = certificate.not_after - timedelta(days=10)
    with freeze_time(delta.datetime):
        assert get_eligible_certificates() == {
            certificate.owner: {
                notification.label: [(notification, certificate)]
            }
        }
Exemplo n.º 4
0
def test_get_eligible_certificates_multiple(app, notification):
    from lemur.notifications.messaging import get_eligible_certificates

    options = [
        {
            "name": "interval",
            "value": 10
        },
        {
            "name": "unit",
            "value": "days"
        },
    ]
    cert_1 = create_cert_that_expires_in_days(10)
    cert_1.notifications.append(notification)
    cert_1.notifications[0].options = options
    cert_2 = create_cert_that_expires_in_days(10)
    # cert 2 has a different owner
    cert_2.notifications.append(notification)
    cert_2.notifications[0].options = options
    cert_3 = create_cert_that_expires_in_days(10)
    cert_3.owner = cert_1.owner
    cert_3.notifications.append(notification)
    cert_3.notifications[0].options = options

    delta = cert_1.not_after - timedelta(days=10)
    with freeze_time(delta.datetime):
        assert get_eligible_certificates() == {
            cert_1.owner: {
                notification.label: [(notification, cert_1),
                                     (notification, cert_3)]
            },
            cert_2.owner: {
                notification.label: [(notification, cert_2)]
            }
        }