Esempio n. 1
0
def test_positive_update_key(name, module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then update its gpg key file

    :id: d3a72892-3414-4178-98b7-e0780d9b6587

    :parametrized: yes

    :expectedresults: gpg key is updated

    :CaseImportance: Critical
    """
    gpg_key = make_content_credential({'organization-id': module_org.id})
    content = gen_alphanumeric(gen_integer(20, 50))
    assert gpg_key['content'] != content
    local_key = create_gpg_key_file(content)
    assert gpg_key, 'GPG Key file must be created'
    key = '/tmp/%s' % gen_alphanumeric()
    ssh.upload_file(local_file=local_key, remote_file=key)
    ContentCredential.update({
        'key': key,
        'name': gpg_key['name'],
        'organization-id': module_org.id
    })
    gpg_key = ContentCredential.info({
        'name': gpg_key['name'],
        'organization-id': module_org.id
    })
    assert gpg_key['content'] == content
Esempio n. 2
0
def test_positive_update_key_for_product_with_repos(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it with custom product that has more than one
    repository then update the key

    :id: 8aa3dc75-6257-48ae-b3f9-c617e323b47a

    :expectedresults: gpg key is associated with product before/after
        update as well as with the repositories

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Create repositories and assign them to the product
    repos = [
        make_repository({'product-id': product['id']})
        for _ in range(gen_integer(2, 5))
    ]
    # Associate gpg key with a product
    Product.update({
        'gpg-key': gpg_key['name'],
        'id': product['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] == gpg_key['name']
    for repo in repos:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('name') == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] == new_name
    # Verify changes are reflected in the repositories
    for repo in repos:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('name') == new_name
Esempio n. 3
0
def test_positive_update_key_for_repo_from_product_with_repos(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    more than one repository then update the key

    :id: c548ed4f-7f2d-456f-a644-7597644f6457

    :expectedresults: gpg key is associated with a single repository
        before/after update and not associated with product or other
        repositories

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Create repositories and assign them to the product
    repos = [
        make_repository({'product-id': product['id']})
        for _ in range(gen_integer(2, 5))
    ]
    # Associate gpg key with a single repository
    Repository.update({
        'gpg-key': gpg_key['name'],
        'id': repos[0]['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated
    repos[0] = Repository.info({'id': repos[0]['id']})
    assert repos[0]['gpg-key']['name'] == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the associated repository
    repos[0] = Repository.info({'id': repos[0]['id']})
    assert repos[0]['gpg-key'].get('name') == new_name
    # Verify changes are not reflected in the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] != new_name
    # Verify changes are not reflected in the rest of repositories
    for repo in repos[1:]:
        repo = Repository.info({'id': repo['id']})
        assert repo['gpg-key'].get('name') != new_name
Esempio n. 4
0
def test_positive_update_key_for_product_with_repo(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it with custom product that has one repository
    then update the key

    :id: 1f8f943c-a611-4ed2-9d8a-770f60a549a7

    :expectedresults: gpg key is associated with product before/after
        update as well as with the repository

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Create a repository and assign it to the product
    repo = make_repository({'product-id': product['id']})
    # Associate gpg key with a product
    Product.update({
        'gpg-key': gpg_key['name'],
        'id': product['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    repo = Repository.info({'id': repo['id']})
    assert product['gpg']['gpg-key'] == gpg_key['name']
    assert repo['gpg-key'].get('name') == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] == new_name
    # Verify changes are reflected in the repository
    repo = Repository.info({'id': repo['id']})
    assert repo['gpg-key'].get('id') == gpg_key['id']
Esempio n. 5
0
def test_positive_update_key_for_empty_product(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it with empty (no repos) custom product then
    update the key

    :id: 13aa6e0c-4255-483a-af33-ea7e82ee7766

    :expectedresults: gpg key is associated with product before/after
        update

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Associate gpg key with a product
    Product.update({
        'gpg-key': gpg_key['name'],
        'id': product['id'],
        'organization-id': module_org.id
    })
    # Verify gpg key was associated
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] == new_name
def test_negative_update_name(new_name, module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then fail to update its name

    :id: 98cda40a-49d0-42ce-91a6-31fa7b7f330b

    :expectedresults: gpg key is not updated

    :CaseImportance: Critical
    """
    gpg_key = make_content_credential({'organization-id': module_org.id})
    with pytest.raises(CLIReturnCodeError):
        ContentCredential.update({
            'name': gpg_key['name'],
            'new-name': new_name,
            'organization-id': module_org.id,
        })
Esempio n. 7
0
def test_positive_update_key_for_repo_from_product_with_repo(module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then associate it to repository from custom product that has
    one repository then update the key

    :id: 2fee5f35-6e0e-4b7c-8a8a-46ee1e77919d

    :expectedresults: gpg key is associated with the repository
        before/after update, but not with the product

    :CaseLevel: Integration
    """
    # Create a product and a gpg key
    product = make_product({'organization-id': module_org.id})
    gpg_key = make_content_credential({'organization-id': module_org.id})
    # Create repository, assign product and gpg-key
    repo = make_repository({
        'gpg-key-id': gpg_key['id'],
        'product-id': product['id']
    })
    # Verify gpg key was associated
    assert repo['gpg-key'].get('name') == gpg_key['name']
    # Update the gpg key
    new_name = gen_choice(list(valid_data_list().values()))
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id
    })
    # Verify changes are reflected in the gpg key
    gpg_key = ContentCredential.info({
        'id': gpg_key['id'],
        'organization-id': module_org.id
    })
    assert gpg_key['name'] == new_name
    # Verify changes are reflected in the repositories
    repo = Repository.info({'id': repo['id']})
    assert repo['gpg-key'].get('name') == new_name
    # Verify gpg key wasn't added to the product
    product = Product.info({
        'id': product['id'],
        'organization-id': module_org.id
    })
    assert product['gpg']['gpg-key'] != new_name
def test_positive_update_name(new_name, module_org):
    """Create gpg key with valid name and valid gpg key via file
    import then update its name

    :id: f3bb254d-f831-4f86-944a-26d9a36bd906

    :expectedresults: gpg key is updated

    :CaseImportance: Critical
    """
    gpg_key = make_content_credential({'organization-id': module_org.id})
    ContentCredential.update({
        'name': gpg_key['name'],
        'new-name': new_name,
        'organization-id': module_org.id,
    })
    gpg_key = ContentCredential.info({
        'name': new_name,
        'organization-id': module_org.id
    })