コード例 #1
0
def test_multiple_secrets(mock_get_ocp_secrets, generate_cert):
    cert_30_days = generate_cert('30days', 30 * NOT_AFTER_DAYS)
    cert_35_days = generate_cert('35days', 35 * NOT_AFTER_DAYS)
    mock_get_ocp_secrets.return_value = [
        {
            'type': 'Opaque',
            'metadata': {
                'name': 'mysecret'
            },
            'data': {
                'mycert': b64encode(cert_30_days),
            }
        },
        {
            'type': 'Opaque',
            'metadata': {
                'name': 'myothersecret'
            },
            'data': {
                'myothercert': b64encode(cert_35_days),
            }
        }
    ]

    certs = verify('myproject', 29)
    assert len(certs) == 2
    assert certs[0].expires_soon is False
    assert certs[0].name == 'myproject:mysecret:mycert'
    assert certs[1].expires_soon is False
    assert certs[1].name == 'myproject:myothersecret:myothercert'

    certs = verify('myproject', 31)
    assert len(certs) == 2
    assert certs[0].expires_soon is True
    assert certs[0].name == 'myproject:mysecret:mycert'
    assert certs[1].expires_soon is False
    assert certs[1].name == 'myproject:myothersecret:myothercert'

    certs = verify('myproject', 36)
    assert len(certs) == 2
    assert certs[0].expires_soon is True
    assert certs[0].name == 'myproject:mysecret:mycert'
    assert certs[1].expires_soon is True
    assert certs[1].name == 'myproject:myothersecret:myothercert'
コード例 #2
0
def test_no_secrets(mock_get_ocp_secrets):
    mock_get_ocp_secrets.return_value = []
    assert verify('myproject', 30) == []