Beispiel #1
0
def test_list_certificates_calls_list_all_resources_with_correct_parameters(
    waas_client, list_all_resources_patch
):
    id = [
        "ocid1.waascertificate.oc1..xxxxxEXAMPLExxxxx1",
        "ocid1.waascertificate.oc1..xxxxxEXAMPLExxxxx2",
    ]
    display_name = "testname1"
    lifecycle_state = ["ACTIVE", "CREATING"]
    module = get_module(
        compartment_id="ocid1.compartment.oc1..xxxxxEXAMPLExxxxx",
        sort_by="timeCreated",
        sort_order="DESC",
        id=id,
        display_name=display_name,
        lifecycle_state=lifecycle_state,
        time_created_greater_than_or_equal_to="2019-04-02T17:12:42.454000+00:00",
        time_created_less_than="2019-04-02T17:12:42.454000+00:00",
    )
    list_all_resources_patch.return_value = []
    oci_waas_certificate_facts.list_certificates(waas_client, module)
    list_all_resources_patch.assert_called_once()
    list_all_resources_patch.assert_called_with(
        waas_client.list_certificates,
        compartment_id="ocid1.compartment.oc1..xxxxxEXAMPLExxxxx",
        sort_by="timeCreated",
        sort_order="DESC",
        id=id,
        display_name=display_name,
        lifecycle_state=lifecycle_state,
        time_created_greater_than_or_equal_to="2019-04-02T17:12:42.454000+00:00",
        time_created_less_than="2019-04-02T17:12:42.454000+00:00",
    )
Beispiel #2
0
def test_list_certificates_raises_service_error(waas_client, list_all_resources_patch):
    list_all_resources_patch.side_effect = ServiceError(
        500, "InternalServerError", dict(), "Internal Server Error"
    )
    with pytest.raises(ServiceError) as exc_info:
        oci_waas_certificate_facts.list_certificates(
            waas_client,
            get_module(compartment_id="ocid1.compartment.oc1..xxxxxEXAMPLExxxxx"),
        )
    se = exc_info.value
    assert se.status == 500
    assert se.code == "InternalServerError"
    assert se.message == "Internal Server Error"
Beispiel #3
0
def test_list_certificates_calls_get_certificate(
    waas_client, list_all_resources_patch, call_with_backoff_patch
):
    module = get_module(compartment_id="ocid1.compartment.oc1..xxxxxEXAMPLExxxxx")
    certificates = get_certificates()
    list_all_resources_patch.return_value = certificates
    oci_waas_certificate_facts.list_certificates(waas_client, module)
    list_all_resources_patch.assert_called_once()
    assert call_with_backoff_patch.call_count == 2
    call_with_backoff_patch.assert_any_call(
        waas_client.get_certificate, certificate_id=certificates[0].id
    )
    call_with_backoff_patch.assert_any_call(
        waas_client.get_certificate, certificate_id=certificates[1].id
    )