Esempio n. 1
0
    def test_positive_create_update_delete(self):
        """Create new http-proxy with attributes, update and delete it.

        :id: 6045010f-b43b-46f0-b80f-21505fa021c8

        :BZ: 1774325

        :steps:

            1. Create http-proxy.
            2. Update http-proxy.
            3. delete http-proxy.

        :expectedresults: CRUD operations related to http-proxy hammer command are successful.

        :CaseImportance: Critical
        """
        loc = make_location()
        org = make_org()
        self.addCleanup(location_cleanup, loc['id'])
        self.addCleanup(org_cleanup, org['id'])
        # Create http proxy
        name = gen_string('alpha', 15)
        url = '{}:{}'.format(gen_url(scheme='https'),
                             gen_integer(min_value=10, max_value=9999))
        password = gen_string('alpha', 15)
        username = gen_string('alpha', 15)
        updated_name = gen_string('alpha', 15)
        updated_url = '{}:{}'.format(gen_url(scheme='https'),
                                     gen_integer(min_value=10, max_value=9999))
        updated_password = gen_string('alpha', 15)
        updated_username = gen_string('alpha', 15)
        http_proxy = HttpProxy.create({
            'name': name,
            'url': url,
            'username': username,
            'password': password,
            'organization-id': org['id'],
            'location-id': loc['id'],
        })
        assert http_proxy['name'] == name
        assert http_proxy['url'] == url
        assert http_proxy['username'] == username
        # Update http-proxy
        HttpProxy.update({
            'name': name,
            'new-name': updated_name,
            'url': updated_url,
            'username': updated_username,
            'password': updated_password,
        })
        updated_http_proxy = HttpProxy.info({'id': http_proxy['id']})
        assert updated_http_proxy['name'] == updated_name
        assert updated_http_proxy['url'] == updated_url
        assert updated_http_proxy['username'] == updated_username
        # Delete http-proxy
        HttpProxy.delete({'id': updated_http_proxy['id']})
        with self.assertRaises(CLIReturnCodeError):
            HttpProxy.info({'id': updated_http_proxy['id']})
Esempio n. 2
0
def test_positive_create_update_delete(module_org, module_location):
    """Create new http-proxy with attributes, update and delete it.

    :id: 6045010f-b43b-46f0-b80f-21505fa021c8

    :BZ: 1774325

    :steps:

        1. hammer http-proxy create <args>
        2. hammer http-proxy update <args>
        3. hammer http-proxy delete <args>

    :expectedresults: CRUD operations related to http-proxy hammer command are successful.

    :CaseImportance: Critical
    """
    name = gen_string('alpha', 15)
    url = f'{gen_url(scheme="https")}:{gen_integer(min_value=10, max_value=9999)}'
    password = gen_string('alpha', 15)
    username = gen_string('alpha', 15)

    updated_name = gen_string('alpha', 15)
    updated_url = f'{gen_url(scheme="https")}:{gen_integer(min_value=10, max_value=9999)}'
    updated_password = gen_string('alpha', 15)
    updated_username = gen_string('alpha', 15)

    # Create
    http_proxy = HttpProxy.create({
        'name': name,
        'url': url,
        'username': username,
        'password': password,
        'organization-id': module_org.id,
        'location-id': module_location.id,
    })
    assert http_proxy['name'] == name
    assert http_proxy['url'] == url
    assert http_proxy['username'] == username

    # Update
    HttpProxy.update({
        'name': name,
        'new-name': updated_name,
        'url': updated_url,
        'username': updated_username,
        'password': updated_password,
    })
    updated_http_proxy = HttpProxy.info({'id': http_proxy['id']})
    assert updated_http_proxy['name'] == updated_name
    assert updated_http_proxy['url'] == updated_url
    assert updated_http_proxy['username'] == updated_username

    # Delete
    HttpProxy.delete({'id': updated_http_proxy['id']})
    with pytest.raises(CLIReturnCodeError):
        HttpProxy.info({'id': updated_http_proxy['id']})
Esempio n. 3
0
def test_positive_set_content_default_http_proxy(block_fake_repo_access):
    """An http proxy can be set to be the global default for repositories.

    :id: c12868eb-98f1-4763-a168-281ac44d9ff5

    :Steps:
            1. Create a product with repo.
            2. Create an un-authenticated proxy.
            3. Set the proxy to be the global default proxy.
            4. Sync a repo.

    :expectedresults:  Repo is synced

    :CaseImportance: High

    """
    org = entities.Organization().create()
    proxy_name = gen_string('alpha', 15)
    proxy_url = settings.http_proxy.un_auth_proxy_url
    product = entities.Product(organization=org).create()
    rpm_repo = entities.Repository(product=product,
                                   content_type='yum',
                                   url=settings.repos.yum_1.url).create()

    # Create un-auth HTTP proxy
    http_proxy = HttpProxy.create({
        'name': proxy_name,
        'url': proxy_url,
        'organization-id': org.id,
    })
    assert http_proxy['name'] == proxy_name
    assert http_proxy['url'] == proxy_url
    # Set the proxy to be the global default
    proxy_settings = Settings.set({
        'name': 'content_default_http_proxy',
        'value': proxy_name,
    })
    assert proxy_settings
    # Sync to check proxy works
    assert rpm_repo.read().content_counts['rpm'] == 0
    product.sync()
    assert rpm_repo.read().content_counts['rpm'] >= 1
Esempio n. 4
0
    def test_positive_assign_http_proxy_to_products(self):
        """Assign http_proxy to Products and perform product sync.

        :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f

        :expectedresults: HTTP Proxy is assigned to all repos present
            in Products and sync operation performed successfully.

        :CaseImportance: Critical
        """
        # create HTTP proxies
        http_proxy_a = HttpProxy.create({
            'name': gen_string('alpha', 15),
            'url': settings.http_proxy.un_auth_proxy_url,
            'organization-id': self.org['id'],
        })
        http_proxy_b = HttpProxy.create({
            'name': gen_string('alpha', 15),
            'url': settings.http_proxy.auth_proxy_url,
            'username': settings.http_proxy.username,
            'password': settings.http_proxy.password,
            'organization-id': self.org['id'],
        })
        # Create products and repositories
        product_a = make_product({'organization-id': self.org['id']})
        product_b = make_product({'organization-id': self.org['id']})
        repo_a1 = make_repository({
            'product-id': product_a['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'none'
        })
        repo_a2 = make_repository({
            'product-id': product_a['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'use_selected_http_proxy',
            'http-proxy-id': http_proxy_a['id'],
        })
        repo_b1 = make_repository({
            'product-id': product_b['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'none'
        })
        repo_b2 = make_repository({
            'product-id': product_b['id'],
            'url': FAKE_0_YUM_REPO
        })
        # Add http_proxy to products
        Product.update_proxy({
            'ids':
            '{},{}'.format(product_a['id'], product_b['id']),
            'http-proxy-policy':
            'use_selected_http_proxy',
            'http-proxy-id':
            http_proxy_b['id'],
        })
        # Perform sync and verify packages count
        Product.synchronize({
            'id': product_a['id'],
            'organization-id': self.org['id']
        })
        Product.synchronize({
            'id': product_b['id'],
            'organization-id': self.org['id']
        })
        repo_a1 = Repository.info({'id': repo_a1['id']})
        repo_a2 = Repository.info({'id': repo_a2['id']})
        repo_b1 = Repository.info({'id': repo_b1['id']})
        repo_b2 = Repository.info({'id': repo_b2['id']})
        assert repo_a1['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_a2['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_b1['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_b2['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_a1['http-proxy']['id'] == http_proxy_b['id']
        assert repo_a2['http-proxy']['id'] == http_proxy_b['id']
        assert repo_b1['http-proxy']['id'] == http_proxy_b['id']
        assert repo_b2['http-proxy']['id'] == http_proxy_b['id']
        assert int(repo_a1['content-counts']
                   ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
        assert int(repo_a2['content-counts']
                   ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
        assert int(repo_b1['content-counts']
                   ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
        assert int(repo_b2['content-counts']
                   ['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
        Product.update_proxy({
            'ids':
            '{},{}'.format(product_a['id'], product_b['id']),
            'http-proxy-policy':
            'none'
        })
        repo_a1 = Repository.info({'id': repo_a1['id']})
        repo_a2 = Repository.info({'id': repo_a2['id']})
        repo_b1 = Repository.info({'id': repo_b1['id']})
        repo_b2 = Repository.info({'id': repo_b2['id']})
        assert repo_a1['http-proxy']['http-proxy-policy'] == "none"
        assert repo_a2['http-proxy']['http-proxy-policy'] == "none"
        assert repo_b1['http-proxy']['http-proxy-policy'] == "none"
        assert repo_b2['http-proxy']['http-proxy-policy'] == "none"
Esempio n. 5
0
def test_positive_assign_http_proxy_to_products(module_org):
    """Assign http_proxy to Products and perform product sync.

    :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f

    :expectedresults: HTTP Proxy is assigned to all repos present
        in Products and sync operation performed successfully.

    :Assignee: jpathan

    :CaseImportance: High
    """
    # create HTTP proxies
    http_proxy_a = HttpProxy.create(
        {
            'name': gen_string('alpha', 15),
            'url': settings.http_proxy.un_auth_proxy_url,
            'organization-id': module_org.id,
        },
    )
    http_proxy_b = HttpProxy.create(
        {
            'name': gen_string('alpha', 15),
            'url': settings.http_proxy.auth_proxy_url,
            'username': settings.http_proxy.username,
            'password': settings.http_proxy.password,
            'organization-id': module_org.id,
        },
    )
    # Create products and repositories
    product_a = make_product({'organization-id': module_org.id})
    product_b = make_product({'organization-id': module_org.id})
    repo_a1 = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product_a['id'],
            'url': settings.repos.yum_0.url,
            'http-proxy-policy': 'none',
        },
    )
    repo_a2 = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product_a['id'],
            'url': settings.repos.yum_0.url,
            'http-proxy-policy': 'use_selected_http_proxy',
            'http-proxy-id': http_proxy_a['id'],
        },
    )
    repo_b1 = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product_b['id'],
            'url': settings.repos.yum_0.url,
            'http-proxy-policy': 'none',
        },
    )
    repo_b2 = make_repository(
        {
            'organization-id': module_org.id,
            'product-id': product_b['id'],
            'url': settings.repos.yum_0.url,
        },
    )
    # Add http_proxy to products
    Product.update_proxy(
        {
            'ids': f"{product_a['id']},{product_b['id']}",
            'http-proxy-policy': 'use_selected_http_proxy',
            'http-proxy-id': http_proxy_b['id'],
        }
    )
    for repo in repo_a1, repo_a2, repo_b1, repo_b2:
        result = Repository.info({'id': repo['id']})
        assert result['http-proxy']['http-proxy-policy'] == 'use_selected_http_proxy'
        assert result['http-proxy']['id'] == http_proxy_b['id']
    # Perform sync and verify packages count
    Product.synchronize({'id': product_a['id'], 'organization-id': module_org.id})
    Product.synchronize({'id': product_b['id'], 'organization-id': module_org.id})

    Product.update_proxy(
        {'ids': f"{product_a['id']},{product_b['id']}", 'http-proxy-policy': 'none'}
    )

    for repo in repo_a1, repo_a2, repo_b1, repo_b2:
        result = Repository.info({'id': repo['id']})
        assert result['http-proxy']['http-proxy-policy'] == 'none'
        assert int(result['content-counts']['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
Esempio n. 6
0
    def test_positive_assign_http_proxy_to_products(self):
        """Assign http_proxy to Products and check whether http-proxy is
         used during sync.

        :id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f

        :expectedresults: HTTP Proxy is assigned to all repos present
            in Products and sync operation uses assigned http-proxy.

        :CaseImportance: Critical
        """
        # create HTTP proxies
        http_proxy_url_a = '{}:{}'.format(
            gen_url(scheme='https'), gen_integer(min_value=10, max_value=9999))
        http_proxy_url_b = '{}:{}'.format(
            gen_url(scheme='http'), gen_integer(min_value=10, max_value=9999))
        http_proxy_a = HttpProxy.create({
            'name': gen_string('alpha', 15),
            'url': http_proxy_url_a,
            'organization-id': self.org['id'],
        })
        http_proxy_b = HttpProxy.create({
            'name': gen_string('alpha', 15),
            'url': http_proxy_url_b,
            'organization-id': self.org['id'],
        })
        proxy_fqdn = http_proxy_b['url'].split(":")[1].strip("//")
        repo_fqdn = FAKE_0_YUM_REPO.split("/")[2]
        # Create products and repositories
        product_a = make_product({'organization-id': self.org['id']})
        product_b = make_product({'organization-id': self.org['id']})
        repo_a1 = make_repository({
            'product-id': product_a['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'none'
        })
        repo_a2 = make_repository({
            'product-id': product_a['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'use_selected_http_proxy',
            'http-proxy-id': http_proxy_a['id'],
        })
        repo_b1 = make_repository({
            'product-id': product_b['id'],
            'url': FAKE_0_YUM_REPO,
            'http-proxy-policy': 'none'
        })
        repo_b2 = make_repository({
            'product-id': product_b['id'],
            'url': FAKE_0_YUM_REPO
        })
        # Add http_proxy to products
        Product.update_proxy({
            'ids':
            '{},{}'.format(product_a['id'], product_b['id']),
            'http-proxy-policy':
            'use_selected_http_proxy',
            'http-proxy-id':
            http_proxy_b['id'],
        })
        repo_a1 = Repository.info({'id': repo_a1['id']})
        repo_a2 = Repository.info({'id': repo_a2['id']})
        repo_b1 = Repository.info({'id': repo_b1['id']})
        repo_b2 = Repository.info({'id': repo_b2['id']})
        assert repo_a1['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_a2['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_b1['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_b2['http-proxy'][
            'http-proxy-policy'] == "use_selected_http_proxy"
        assert repo_a1['http-proxy']['id'] == http_proxy_b['id']
        assert repo_a2['http-proxy']['id'] == http_proxy_b['id']
        assert repo_b1['http-proxy']['id'] == http_proxy_b['id']
        assert repo_b2['http-proxy']['id'] == http_proxy_b['id']
        # check if proxy fqdn is present in log during sync
        with self.assertRaises(CLIReturnCodeError):
            Product.synchronize({
                'id': product_a['id'],
                'organization-id': self.org['id']
            })
        result = ssh.command(
            'grep -F "HTTP connection (1): {}" /var/log/messages'.format(
                proxy_fqdn))
        assert result.return_code == 0
        # Add http_proxy to products
        Product.update_proxy({
            'ids':
            '{},{}'.format(product_a['id'], product_b['id']),
            'http-proxy-policy':
            'none'
        })
        repo_a1 = Repository.info({'id': repo_a1['id']})
        repo_a2 = Repository.info({'id': repo_a2['id']})
        repo_b1 = Repository.info({'id': repo_b1['id']})
        repo_b2 = Repository.info({'id': repo_b2['id']})
        assert repo_a1['http-proxy']['http-proxy-policy'] == "none"
        assert repo_a2['http-proxy']['http-proxy-policy'] == "none"
        assert repo_b1['http-proxy']['http-proxy-policy'] == "none"
        assert repo_b2['http-proxy']['http-proxy-policy'] == "none"
        # verify that proxy fqdn is not present in log during sync.
        Product.synchronize({
            'id': product_a['id'],
            'organization-id': self.org['id']
        })
        result = ssh.command(
            'tail -n 50 /var/log/messages | grep -F "HTTP connection (1): {}"'.
            format(repo_fqdn))
        assert result.return_code == 0
        result = ssh.command(
            'tail -n 50 /var/log/messages | grep -F "{}"'.format(proxy_fqdn))
        assert result.return_code == 1