Ejemplo n.º 1
0
def gen_valid_source(cleanup,
                     src_type,
                     hosts,
                     create=True,
                     exclude_hosts=None):
    """Create valid source."""
    cred = Credential(cred_type=src_type, password=uuid4())
    cred.create()
    cleanup.append(cred)
    source = Source(source_type=src_type,
                    hosts=[hosts],
                    credential_ids=[cred._id])
    # QPC does not accept blank exclude_host values, only add it if not empty.
    if exclude_hosts is not None:
        source.exclude_hosts = [exclude_hosts]
    if create:
        source.create()
        cleanup.append(source)
        assert_matches_server(source)
    return source
Ejemplo n.º 2
0
def test_create_exclude_hosts_negative(shared_client, cleanup, scan_host, src_type):
    """Attempt to create a source with excluded hosts with an invalid source type.

    :id: 52ba8847-81d7-4c8a-a5bd-1f946f5f39b5
    :description: Attempt to create a source with exclude_hosts with an invalid
        source type, like vcenter or satellite.
    :steps:
        1) Create host credential
        2) Send POST with data to create the source using the credential to
           the endpoint, with the exclude_host option and invalid source type.
    :expectedresults: Creation of the source fails with a message about an
        invalid source type.
    """
    cred = Credential(cred_type=src_type, client=shared_client, password=uuid4())
    cred.create()
    cleanup.append(cred)
    src = Source(
        source_type=src_type,
        client=shared_client,
        hosts=[scan_host],
        credential_ids=[cred._id],
    )
    src.exclude_hosts = ["10.10.10.10"]
    assert_source_create_fails(src, src_type)