Exemplo n.º 1
0
def test_positive_update_rh_product(session):
    """Update Content View in an Activation key

    :id: 9b0ac209-45de-4cc4-97e8-e191f3f37239

    :Steps:

        1. Create an activation key
        2. Update the content view with another content view which has RH
            products

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env1_name = gen_string('alpha')
    env2_name = gen_string('alpha')
    cv1_name = gen_string('alpha')
    cv2_name = gen_string('alpha')
    rh_repo1 = {
        'name': REPOS['rhva6']['name'],
        'product': PRDS['rhel'],
        'reposet': REPOSET['rhva6'],
        'basearch': DEFAULT_ARCHITECTURE,
        'releasever': DEFAULT_RELEASE_VERSION,
    }
    rh_repo2 = {
        'name': ('Red Hat Enterprise Virtualization Agents for RHEL 6 '
                 'Server RPMs i386 6Server'),
        'product': PRDS['rhel'],
        'reposet': REPOSET['rhva6'],
        'basearch': 'i386',
        'releasever': DEFAULT_RELEASE_VERSION,
    }
    org = entities.Organization().create()
    with manifests.clone() as manifest:
        upload_manifest(org.id, manifest.content)
    repo1_id = enable_sync_redhat_repo(rh_repo1, org.id)
    cv_publish_promote(cv1_name, env1_name, repo1_id, org.id)
    repo2_id = enable_sync_redhat_repo(rh_repo2, org.id)
    cv_publish_promote(cv2_name, env2_name, repo2_id, org.id)
    with session:
        session.organization.select(org.name)
        session.activationkey.create({
            'name': name,
            'lce': {env1_name: True},
            'content_view': cv1_name,
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv1_name
        if bz_bug_is_open(1597639):
            assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.update(name, {'details': {
            'lce': {env2_name: True},
            'content_view': cv2_name,
        }})
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv2_name
Exemplo n.º 2
0
def test_positive_add_custom_product(session, module_org):
    """Test that custom product can be associated to Activation Keys

    :id: e66db2bf-517a-46ff-ba23-9f9744bef884

    :expectedresults: Custom products are successfully associated to Activation
        key

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    product_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(
        org_id=module_org.id, product_name=product_name)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name,
        })
        assert session.activationkey.search(name) == name
        session.activationkey.add_subscription(name, product_name)
        ak = session.activationkey.read(name)
        assigned_prod = ak[
            'subscriptions']['resources']['assigned'][0]['Repository Name']
        assert assigned_prod == product_name
Exemplo n.º 3
0
def test_positive_delete_with_system(session):
    """Delete an Activation key which has registered systems

    :id: 86cd070e-cf46-4bb1-b555-e7cb42e4dc9f

    :Steps:
        1. Create an Activation key
        2. Register systems to it
        3. Delete the Activation key

    :expectedresults: Activation key is deleted

    :CaseLevel: System
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    product_name = gen_string('alpha')
    org = entities.Organization().create()
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(product_name=product_name, org_id=org.id)
    cv_publish_promote(cv_name, env_name, repo_id, org.id)
    with session:
        session.organization.select(org_name=org.name)
        session.activationkey.create(
            {'name': name, 'lce': {env_name: True}, 'content_view': cv_name}
        )
        assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.add_subscription(name, product_name)
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, name)
            assert vm.subscribed
            session.activationkey.delete(name)
            assert session.activationkey.search(name)[0]['Name'] != name
Exemplo n.º 4
0
def test_positive_search_scoped(session, module_org):
    """Test scoped search for different activation key parameters

    :id: 2c2ee1d7-0997-4a89-8f0a-b04e4b6177c0

    :customerscenario: true

    :expectedresults: Search functionality returns correct activation key

    :BZ: 1259374

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    env_name = gen_string('alpha')
    cv_name = gen_string('alpha')
    description = gen_string('alpha')
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'description': description,
            'lce': {env_name: True},
            'content_view': cv_name,
        })
        for query_type, query_value in [
            ('content_view', cv_name),
            ('environment', env_name),
            ('description', description)
        ]:
            assert session.activationkey.search(
                '{} = {}'.format(query_type, query_value))[0]['Name'] == name
Exemplo n.º 5
0
def test_positive_delete_with_cv(session, module_org):
    """Create Activation key with content view and delete it

    :id: 7e40e1ed-8314-406b-9451-05f64806a6e6

    :expectedresults: Activation key is deleted

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
            'content_view': cv_name,
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.delete(name)
        assert not session.activationkey.search(name)
Exemplo n.º 6
0
def test_positive_add_custom_product(session, module_org):
    """Test that custom product can be associated to Activation Keys

    :id: e66db2bf-517a-46ff-ba23-9f9744bef884

    :expectedresults: Custom products are successfully associated to Activation
        key

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    product_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(org_id=module_org.id,
                                      product_name=product_name)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
            'content_view': cv_name,
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.add_subscription(name, product_name)
        ak = session.activationkey.read(name)
        assigned_prod = ak['subscriptions']['resources']['assigned'][0][
            'Repository Name']
        assert assigned_prod == product_name
Exemplo n.º 7
0
def test_positive_update_env(session, module_org, env_name):
    """Update Environment in an Activation key

    :id: 895cda6a-bb1e-4b94-a858-95f0be78a17b

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {ENVIRONMENT: True},
        })
        assert session.activationkey.search(name) == name
        ak = session.activationkey.read(name)
        assert ak['details']['lce'][env_name][ENVIRONMENT]
        assert not ak['details']['lce'][env_name][env_name]
        session.activationkey.update(name, {'details.lce': {env_name: True}})
        ak = session.activationkey.read(name)
        assert not ak['details']['lce'][env_name][ENVIRONMENT]
        assert ak['details']['lce'][env_name][env_name]
Exemplo n.º 8
0
def test_positive_create_with_envs(session, module_org, env_name):
    """Create Activation key for all variations of Environments

    :id: f75e994a-6da1-40a3-9685-f8387388b3f0

    :expectedresults: Activation key is created

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    # Helper function to create and sync custom repository
    repo_id = create_sync_custom_repo(module_org.id)
    # Helper function to create and promote CV to next env
    cv_publish_promote(
        cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name
        })
        assert session.activationkey.search(name) == name
        ak = session.activationkey.read(name)
        assert ak['details']['lce'][env_name][env_name]
Exemplo n.º 9
0
def test_positive_create_with_cv(session, module_org, cv_name):
    """Create Activation key for all variations of Content Views

    :id: 2ad000f1-6c80-46aa-a61b-9ea62cefe91b

    :parametrized: yes

    :expectedresults: Activation key is created

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env_name = gen_string('alpha')
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
            'content_view': cv_name
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name, widget_names='details')
        assert ak['details']['content_view'] == cv_name
Exemplo n.º 10
0
def test_positive_search_scoped(session, module_org):
    """Test scoped search for different activation key parameters

    :id: 2c2ee1d7-0997-4a89-8f0a-b04e4b6177c0

    :customerscenario: true

    :expectedresults: Search functionality returns correct activation key

    :BZ: 1259374

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    env_name = gen_string('alpha')
    cv_name = gen_string('alpha')
    description = gen_string('alpha')
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'description': description,
            'lce': {
                env_name: True
            },
            'content_view': cv_name,
        })
        for query_type, query_value in [('content_view', cv_name),
                                        ('environment', env_name),
                                        ('description', description)]:
            assert session.activationkey.search('{} = {}'.format(
                query_type, query_value))[0]['Name'] == name
Exemplo n.º 11
0
def test_positive_update_rh_product(session):
    """Update Content View in an Activation key

    :id: 9b0ac209-45de-4cc4-97e8-e191f3f37239

    :Steps:

        1. Create an activation key
        2. Update the content view with another content view which has RH
            products

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env1_name = gen_string('alpha')
    env2_name = gen_string('alpha')
    cv1_name = gen_string('alpha')
    cv2_name = gen_string('alpha')
    rh_repo1 = {
        'name': REPOS['rhva6']['name'],
        'product': PRDS['rhel'],
        'reposet': REPOSET['rhva6'],
        'basearch': DEFAULT_ARCHITECTURE,
        'releasever': DEFAULT_RELEASE_VERSION,
    }
    rh_repo2 = {
        'name': ('Red Hat Enterprise Virtualization Agents for RHEL 6 '
                 'Server RPMs i386 6Server'),
        'product': PRDS['rhel'],
        'reposet': REPOSET['rhva6'],
        'basearch': 'i386',
        'releasever': DEFAULT_RELEASE_VERSION,
    }
    org = entities.Organization().create()
    with manifests.clone() as manifest:
        upload_manifest(org.id, manifest.content)
    repo1_id = enable_sync_redhat_repo(rh_repo1, org.id)
    cv_publish_promote(cv1_name, env1_name, repo1_id, org.id)
    repo2_id = enable_sync_redhat_repo(rh_repo2, org.id)
    cv_publish_promote(cv2_name, env2_name, repo2_id, org.id)
    with session:
        session.organization.select(org.name)
        session.activationkey.create({
            'name': name,
            'lce': {env1_name: True},
            'content_view': cv1_name,
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv1_name
        if bz_bug_is_open(1597639):
            assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.update(name, {'details': {
            'lce': {env2_name: True},
            'content_view': cv2_name,
        }})
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv2_name
Exemplo n.º 12
0
def test_positive_create_with_envs(session, module_org):
    """Create Activation key with lifecycle environment

    :id: f75e994a-6da1-40a3-9685-f8387388b3f0

    :expectedresults: Activation key is created

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alphanumeric')
    # Helper function to create and sync custom repository
    repo_id = create_sync_custom_repo(module_org.id)
    # Helper function to create and promote CV to next env
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
            'content_view': cv_name
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name)
        assert ak['details']['lce'][env_name][env_name]
Exemplo n.º 13
0
def test_positive_update_env(session, module_org):
    """Update Environment in an Activation key

    :id: 895cda6a-bb1e-4b94-a858-95f0be78a17b

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alphanumeric')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                ENVIRONMENT: True
            },
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name)
        assert ak['details']['lce'][env_name][ENVIRONMENT]
        assert not ak['details']['lce'][env_name][env_name]
        session.activationkey.update(name, {'details.lce': {env_name: True}})
        ak = session.activationkey.read(name)
        assert not ak['details']['lce'][env_name][ENVIRONMENT]
        assert ak['details']['lce'][env_name][env_name]
Exemplo n.º 14
0
def test_positive_delete_with_env(session, module_org):
    """Create Activation key with environment and delete it

    :id: b6019881-3d6e-4b75-89f5-1b62aff3b1ca

    :expectedresults: Activation key is deleted

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.delete(name)
        assert not session.activationkey.search(name)
Exemplo n.º 15
0
def test_positive_add_multiple_aks_to_system(session, module_org):
    """Check if multiple Activation keys can be attached to a system

    :id: 4d6b6b69-9d63-4180-af2e-a5d908f8adb7

    :expectedresults: Multiple Activation keys are attached to a system

    :CaseLevel: System
    """
    key_1_name = gen_string('alpha')
    key_2_name = gen_string('alpha')
    cv_1_name = gen_string('alpha')
    cv_2_name = gen_string('alpha')
    env_1_name = gen_string('alpha')
    env_2_name = gen_string('alpha')
    product_1_name = gen_string('alpha')
    product_2_name = gen_string('alpha')
    repo_1_id = create_sync_custom_repo(
        org_id=module_org.id, product_name=product_1_name)
    cv_publish_promote(cv_1_name, env_1_name, repo_1_id, module_org.id)
    repo_2_id = create_sync_custom_repo(
        org_id=module_org.id,
        product_name=product_2_name,
        repo_url=FAKE_2_YUM_REPO,
    )
    cv_publish_promote(cv_2_name, env_2_name, repo_2_id, module_org.id)
    with session:
        # Create 2 activation keys
        for key_name, env_name, cv_name, product_name in (
                (key_1_name, env_1_name, cv_1_name, product_1_name),
                (key_2_name, env_2_name, cv_2_name, product_2_name)):
            session.activationkey.create({
                'name': key_name,
                'lce': {env_name: True},
                'content_view': cv_name
            })
            assert (
                session.activationkey.search(key_name)[0]['Name'] == key_name)
            session.activationkey.add_subscription(key_name, product_name)
            ak = session.activationkey.read(key_name)
            subscriptions = [
                subscription['Repository Name']
                for subscription
                in ak['subscriptions']['resources']['assigned']
            ]
            assert product_name in subscriptions
        # Create VM
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(
                module_org.label,
                '{0},{1}'.format(key_1_name, key_2_name),
            )
            assert vm.subscribed
            # Assert the content-host association with activation keys
            for key_name in [key_1_name, key_2_name]:
                ak = session.activationkey.read(key_name)
                assert len(ak['content_hosts']['table']) == 1
                assert ak['content_hosts']['table'][0]['Name'] == vm.hostname
Exemplo n.º 16
0
def test_positive_add_multiple_aks_to_system(session, module_org):
    """Check if multiple Activation keys can be attached to a system

    :id: 4d6b6b69-9d63-4180-af2e-a5d908f8adb7

    :expectedresults: Multiple Activation keys are attached to a system

    :CaseLevel: System
    """
    key_1_name = gen_string('alpha')
    key_2_name = gen_string('alpha')
    cv_1_name = gen_string('alpha')
    cv_2_name = gen_string('alpha')
    env_1_name = gen_string('alpha')
    env_2_name = gen_string('alpha')
    product_1_name = gen_string('alpha')
    product_2_name = gen_string('alpha')
    repo_1_id = create_sync_custom_repo(
        org_id=module_org.id, product_name=product_1_name)
    cv_publish_promote(cv_1_name, env_1_name, repo_1_id, module_org.id)
    repo_2_id = create_sync_custom_repo(
        org_id=module_org.id,
        product_name=product_2_name,
        repo_url=FAKE_2_YUM_REPO,
    )
    cv_publish_promote(cv_2_name, env_2_name, repo_2_id, module_org.id)
    with session:
        # Create 2 activation keys
        for key_name, env_name, cv_name, product_name in (
                (key_1_name, env_1_name, cv_1_name, product_1_name),
                (key_2_name, env_2_name, cv_2_name, product_2_name)):
            session.activationkey.create({
                'name': key_name,
                'lce': {env_name: True},
                'content_view': cv_name
            })
            assert (
                session.activationkey.search(key_name)[0]['Name'] == key_name)
            session.activationkey.add_subscription(key_name, product_name)
            ak = session.activationkey.read(key_name)
            subscriptions = [
                subscription['Repository Name']
                for subscription
                in ak['subscriptions']['resources']['assigned']
            ]
            assert product_name in subscriptions
        # Create VM
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(
                module_org.label,
                '{0},{1}'.format(key_1_name, key_2_name),
            )
            assert vm.subscribed
            # Assert the content-host association with activation keys
            for key_name in [key_1_name, key_2_name]:
                ak = session.activationkey.read(key_name)
                assert len(ak['content_hosts']['table']) == 1
                assert ak['content_hosts']['table'][0]['Name'] == vm.hostname
Exemplo n.º 17
0
def test_positive_update_cv(session, module_org, cv2_name):
    """Update Content View in an Activation key

    :id: 68880ca6-acb9-4a16-aaa0-ced680126732

    :parametrized: yes

    :Steps:
        1. Create Activation key
        2. Update the Content view with another Content view which has custom
            products

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env1_name = gen_string('alpha')
    env2_name = gen_string('alpha')
    cv1_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo1_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv1_name, env1_name, repo1_id, module_org.id)
    repo2_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv2_name, env2_name, repo2_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {
                env1_name: True
            },
            'content_view': cv1_name
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name, widget_names='details')
        assert ak['details']['content_view'] == cv1_name
        session.activationkey.update(
            name,
            {'details': {
                'lce': {
                    env2_name: True
                },
                'content_view': cv2_name
            }})
        ak = session.activationkey.read(name, widget_names='details')
        assert ak['details']['content_view'] == cv2_name
Exemplo n.º 18
0
def test_positive_add_rh_product(session):
    """Test that RH product can be associated to Activation Keys

    :id: d805341b-6d2f-4e16-8cb4-902de00b9a6c

    :expectedresults: RH products are successfully associated to Activation key

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    rh_repo = {
        'name': constants.REPOS['rhva6']['name'],
        'product': constants.PRDS['rhel'],
        'reposet': constants.REPOSET['rhva6'],
        'basearch': constants.DEFAULT_ARCHITECTURE,
        'releasever': constants.DEFAULT_RELEASE_VERSION,
    }
    # Create new org to import manifest
    org = entities.Organization().create()
    # Upload manifest
    with manifests.clone() as manifest:
        upload_manifest(org.id, manifest.content)
    # Helper function to create and promote CV to next environment
    repo_id = enable_sync_redhat_repo(rh_repo, org.id)
    cv_publish_promote(cv_name, env_name, repo_id, org.id)
    with session:
        session.organization.select(org.name)
        session.activationkey.create({
            'name': name,
            'lce': {
                env_name: True
            },
            'content_view': cv_name
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.add_subscription(
            name, constants.DEFAULT_SUBSCRIPTION_NAME)
        ak = session.activationkey.read(name, widget_names='subscriptions')
        subs_name = ak['subscriptions']['resources']['assigned'][0][
            'Repository Name']
        assert subs_name == constants.DEFAULT_SUBSCRIPTION_NAME
Exemplo n.º 19
0
def test_positive_add_rh_product(session):
    """Test that RH product can be associated to Activation Keys

    :id: d805341b-6d2f-4e16-8cb4-902de00b9a6c

    :expectedresults: RH products are successfully associated to Activation key

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    rh_repo = {
        'name': REPOS['rhva6']['name'],
        'product': PRDS['rhel'],
        'reposet': REPOSET['rhva6'],
        'basearch': DEFAULT_ARCHITECTURE,
        'releasever': DEFAULT_RELEASE_VERSION,
    }
    # Create new org to import manifest
    org = entities.Organization().create()
    # Upload manifest
    with manifests.clone() as manifest:
        upload_manifest(org.id, manifest.content)
    # Helper function to create and promote CV to next environment
    repo_id = enable_sync_redhat_repo(rh_repo, org.id)
    cv_publish_promote(cv_name, env_name, repo_id, org.id)
    with session:
        session.organization.select(org.name)
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name,
        })
        assert session.activationkey.search(name) == name
        session.activationkey.add_subscription(name, DEFAULT_SUBSCRIPTION_NAME)
        ak = session.activationkey.read(name)
        subs_name = ak[
            'subscriptions']['resources']['assigned'][0]['Repository Name']
        assert subs_name == DEFAULT_SUBSCRIPTION_NAME
Exemplo n.º 20
0
def test_positive_update_cv(session, module_org, cv2_name):
    """Update Content View in an Activation key

    :id: 68880ca6-acb9-4a16-aaa0-ced680126732

    :Steps:
        1. Create Activation key
        2. Update the Content view with another Content view which has custom
            products

    :expectedresults: Activation key is updated

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env1_name = gen_string('alpha')
    env2_name = gen_string('alpha')
    cv1_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo1_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv1_name, env1_name, repo1_id, module_org.id)
    repo2_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv2_name, env2_name, repo2_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env1_name: True},
            'content_view': cv1_name,
        })
        assert session.activationkey.search(name)[0]['Name'] == name
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv1_name
        if bz_bug_is_open(1597639):
            assert session.activationkey.search(name)[0]['Name'] == name
        session.activationkey.update(name, {'details': {
            'lce': {env2_name: True},
            'content_view': cv2_name,
        }})
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv2_name
Exemplo n.º 21
0
def test_positive_create_with_cv(session, module_org, cv_name):
    """Create Activation key for all variations of Content Views

    :id: 2ad000f1-6c80-46aa-a61b-9ea62cefe91b

    :expectedresults: Activation key is created

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    env_name = gen_string('alpha')
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(
        cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name,
        })
        assert session.activationkey.search(name) == name
        ak = session.activationkey.read(name)
        assert ak['details']['content_view'] == cv_name
Exemplo n.º 22
0
def test_positive_delete_with_env(session, module_org):
    """Create Activation key with environment and delete it

    :id: b6019881-3d6e-4b75-89f5-1b62aff3b1ca

    :expectedresults: Activation key is deleted

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
        })
        assert session.activationkey.search(name) == name
        session.activationkey.delete(name)
        assert session.activationkey.search(name) is None
Exemplo n.º 23
0
def test_positive_delete_with_system(session):
    """Delete an Activation key which has registered systems

    :id: 86cd070e-cf46-4bb1-b555-e7cb42e4dc9f

    :Steps:
        1. Create an Activation key
        2. Register systems to it
        3. Delete the Activation key

    :expectedresults: Activation key is deleted

    :CaseLevel: System
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    product_name = gen_string('alpha')
    org = entities.Organization().create()
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(product_name=product_name, org_id=org.id)
    cv_publish_promote(cv_name, env_name, repo_id, org.id)
    with session:
        session.organization.select(org_name=org.name)
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name
        })
        assert session.activationkey.search(name) == name
        session.activationkey.add_subscription(name, product_name)
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(org.label, name)
            assert vm.subscribed
            session.activationkey.delete(name)
            assert session.activationkey.search(name) is None
Exemplo n.º 24
0
def test_positive_delete_with_cv(session, module_org):
    """Create Activation key with content view and delete it

    :id: 7e40e1ed-8314-406b-9451-05f64806a6e6

    :expectedresults: Activation key is deleted

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    cv_name = gen_string('alpha')
    env_name = gen_string('alpha')
    # Helper function to create and promote CV to next environment
    repo_id = create_sync_custom_repo(module_org.id)
    cv_publish_promote(cv_name, env_name, repo_id, module_org.id)
    with session:
        session.activationkey.create({
            'name': name,
            'lce': {env_name: True},
            'content_view': cv_name,
        })
        assert session.activationkey.search(name) == name
        session.activationkey.delete(name)
        assert session.activationkey.search(name) is None
Exemplo n.º 25
0
    def test_positive_add_multiple_aks_to_system(self):
        """Check if multiple Activation keys can be attached to a system

        :id: 4d6b6b69-9d63-4180-af2e-a5d908f8adb7

        :expectedresults: Multiple Activation keys are attached to a system

        :CaseLevel: System
        """
        key_1_name = gen_string('alpha')
        key_2_name = gen_string('alpha')
        cv_1_name = gen_string('alpha')
        cv_2_name = gen_string('alpha')
        env_1_name = gen_string('alpha')
        env_2_name = gen_string('alpha')
        product_1_name = gen_string('alpha')
        product_2_name = gen_string('alpha')
        # Helper function to create and promote CV to next environment
        repo_1_id = create_sync_custom_repo(
            org_id=self.organization.id, product_name=product_1_name)
        cv_publish_promote(
            cv_1_name, env_1_name, repo_1_id, self.organization.id)
        repo_2_id = create_sync_custom_repo(
            org_id=self.organization.id,
            product_name=product_2_name,
            repo_url=FAKE_2_YUM_REPO,
        )
        cv_publish_promote(
            cv_2_name, env_2_name, repo_2_id, self.organization.id)
        with Session(self) as session:
            # Create activation_key_1
            make_activationkey(
                session,
                org=self.organization.name,
                name=key_1_name,
                env=env_1_name,
                content_view=cv_1_name,
            )
            self.assertIsNotNone(self.activationkey.search(key_1_name))
            self.activationkey.associate_product(key_1_name, [product_1_name])
            self.assertIsNotNone(self.activationkey.wait_until_element(
                common_locators['alert.success_sub_form']))
            # Create activation_key_2
            make_activationkey(
                session,
                org=self.organization.name,
                name=key_2_name,
                env=env_2_name,
                content_view=cv_2_name,
            )
            self.assertIsNotNone(self.activationkey.search(key_2_name))
            self.activationkey.associate_product(key_2_name, [product_2_name])
            self.assertIsNotNone(self.activationkey.wait_until_element(
                common_locators['alert.success_sub_form']))
            # Create VM
            with VirtualMachine(distro=self.vm_distro) as vm:
                vm.install_katello_ca()
                vm.register_contenthost(
                    self.organization.label,
                    '{0},{1}'.format(key_1_name, key_2_name),
                )
                self.assertTrue(vm.subscribed)
                # Assert the content-host association with activation-key
                for key_name in [key_1_name, key_2_name]:
                    names = self.activationkey.fetch_associated_content_hosts(
                        key_name)
                    self.assertEqual(len(names), 1)
                    self.assertEqual(vm.hostname, names[0])
Exemplo n.º 26
0
def test_positive_add_multiple_aks_to_system(session, module_org,
                                             rhel6_contenthost, default_sat):
    """Check if multiple Activation keys can be attached to a system

    :id: 4d6b6b69-9d63-4180-af2e-a5d908f8adb7

    :expectedresults: Multiple Activation keys are attached to a system

    :parametrized: yes

    :CaseLevel: System
    """
    key_1_name = gen_string('alpha')
    key_2_name = gen_string('alpha')
    cv_1_name = gen_string('alpha')
    cv_2_name = gen_string('alpha')
    env_1_name = gen_string('alpha')
    env_2_name = gen_string('alpha')
    product_1_name = gen_string('alpha')
    product_2_name = gen_string('alpha')
    repo_1_id = create_sync_custom_repo(org_id=module_org.id,
                                        product_name=product_1_name)
    cv_publish_promote(cv_1_name, env_1_name, repo_1_id, module_org.id)
    repo_2_id = create_sync_custom_repo(org_id=module_org.id,
                                        product_name=product_2_name,
                                        repo_url=settings.repos.yum_2.url)
    cv_publish_promote(cv_2_name, env_2_name, repo_2_id, module_org.id)
    with session:
        # Create 2 activation keys
        session.location.select(constants.DEFAULT_LOC)
        for key_name, env_name, cv_name, product_name in (
            (key_1_name, env_1_name, cv_1_name, product_1_name),
            (key_2_name, env_2_name, cv_2_name, product_2_name),
        ):
            session.activationkey.create({
                'name': key_name,
                'lce': {
                    env_name: True
                },
                'content_view': cv_name
            })
            assert session.activationkey.search(
                key_name)[0]['Name'] == key_name
            session.activationkey.add_subscription(key_name, product_name)
            ak = session.activationkey.read(key_name,
                                            widget_names='subscriptions')
            subscriptions = [
                subscription['Repository Name'] for subscription in
                ak['subscriptions']['resources']['assigned']
            ]
            assert product_name in subscriptions
        # Create VM
        rhel6_contenthost.install_katello_ca(default_sat)
        rhel6_contenthost.register_contenthost(
            module_org.label, ','.join([key_1_name, key_2_name]))
        assert rhel6_contenthost.subscribed
        # Assert the content-host association with activation keys
        for key_name in [key_1_name, key_2_name]:
            ak = session.activationkey.read(key_name,
                                            widget_names='content_hosts')
            assert len(ak['content_hosts']['table']) == 1
            assert ak['content_hosts']['table'][0][
                'Name'] == rhel6_contenthost.hostname