def test_create_repo_2(self, repo_name): """@Test: Create repository in two different orgs with same name @Assert: Repos is created @Feature: Content Repos - Positive Create """ org_2_name = gen_string("alpha", 10) # Creates new product_1 product_1_name = entities.Product( organization=self.org_id, ).create()['name'] # Create new product_2 under new organization_2 org_2_id = entities.Organization(name=org_2_name).create()['id'] product_2_name = entities.Product( organization=org_2_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, name=repo_name, product=product_1_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) make_repository(session, org=org_2_name, name=repo_name, product=product_2_name, url=FAKE_1_YUM_REPO, force_context=True) self.assertIsNotNone(self.repository.search(repo_name))
def test_create_repo_in_different_orgs(self, repo_name): """@Test: Create repository in two different orgs with same name @Assert: Repos is created @Feature: Content Repos - Positive Create """ # Creates new product_1 product_1 = entities.Product(organization=self.organization).create() # Create new product_2 under new organization_2 org_2 = entities.Organization(name=gen_string('alpha')).create() product_2 = entities.Product(organization=org_2).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product_1.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) make_repository( session, org=org_2.name, name=repo_name, product=product_2.name, url=FAKE_1_YUM_REPO, force_context=True, ) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_srpm_sync(self): """Synchronize repository with SRPMs @id: 1967a540-a265-4046-b87b-627524b63688 @Assert: srpms can be listed in repository """ product = entities.Product(organization=self.session_org).create() repo_name = gen_string('alphanumeric') with Session(self.browser) as session: self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_YUM_SRPM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.setup_navigate_syncnow( session, product.name, repo_name, ) self.assertTrue(self.prd_sync_is_ok(repo_name)) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/Library' '/custom/{}/{}/ | grep .src.rpm'.format( self.session_org.label, product.label, repo_name, )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_negative_create_with_same_names(self): """Try to create two repositories with same name @Feature: Content Repos - Negative Create with same name @Assert: Repository is not created """ repo_name = gen_string('alphanumeric') product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertTrue(self.products.wait_until_element( common_locators['common_invalid']))
def test_positive_update_url(self): """Update content repository with new URL @Feature: Content Repo - Positive Update @Assert: Repository is updated with expected url value """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue( self.repository.validate_field(repo_name, 'url', FAKE_1_YUM_REPO)) self.products.search(product.name).click() self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO) self.products.search(product.name).click() self.assertTrue( self.repository.validate_field(repo_name, 'url', FAKE_2_YUM_REPO))
def test_positive_update_URL(self, repo_name): """@Test: Update content repository with new URL @Feature: Content Repo - Positive Update @Assert: Repo is updated with new url """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue(self.repository.validate_field( repo_name, 'url', FAKE_1_YUM_REPO)) self.navigator.go_to_products() self.products.search(product.name).click() self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO) self.navigator.go_to_products() self.products.search(product.name).click() self.assertTrue(self.repository.validate_field( repo_name, 'url', FAKE_2_YUM_REPO))
def test_negative_create_2(self, repo_name): """@Test: Create repository with same name @Feature: Content Repos - Negative Create with same name @Assert: Repos is not created """ # Creates new product product_name = entities.Product( organization=self.org_id, location=self.loc_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) invalid = self.products.wait_until_element( common_locators["common_invalid"]) self.assertTrue(invalid)
def test_positive_update_checksum_type(self): """Update content repository with new checksum type @Feature: Content Repo - Positive Update of checksum type. @Assert: Repository is updated with expected checksum type. """ repo_name = gen_string('alphanumeric') checksum_default = CHECKSUM_TYPE['default'] checksum_update = CHECKSUM_TYPE['sha1'] product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue( self.repository.validate_field(repo_name, 'checksum', checksum_default)) self.products.search(product.name).click() self.repository.update(repo_name, new_repo_checksum=checksum_update) self.products.search(product.name).click() self.assertTrue( self.repository.validate_field(repo_name, 'checksum', checksum_update))
def test_create_repo_docker_and_sync(self): """@Test: Create and sync a Docker-based repository @Feature: Content Repos - Positive Create @Assert: Docker-based repo is created and synchronized. """ # Creates new product repo_name = gen_string('alpha', 8) product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB, upstream_repo_name=u'busybox' ) self.assertIsNotNone(self.repository.search(repo_name)) # Synchronize it self.navigator.go_to_sync_status() synced = self.sync.sync_custom_repos(product.name, [repo_name]) self.assertTrue(synced)
def test_positive_update_3(self, repo_name): """@Test: Update content repository with new checksum type @Feature: Content Repo - Positive Update of checksum type. @Assert: Repo is updated with new checksum type. """ locator = locators["repo.fetch_checksum"] checksum_default = CHECKSUM_TYPE['default'] checksum_update = CHECKSUM_TYPE['sha1'] # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() checksum_text = self.repository.wait_until_element(locator).text self.assertEqual(checksum_text, checksum_default) self.navigator.go_to_products() self.products.search(product_name).click() self.repository.update(repo_name, new_repo_checksum=checksum_update) checksum_text = self.repository.wait_until_element(locator).text self.assertEqual(checksum_text, checksum_update)
def test_positive_create_in_different_orgs(self): """Create repository in two different orgs with same name @Feature: Content Repos - Positive Create @Assert: Repository is created successfully for both organizations """ org_2 = entities.Organization(name=gen_string('alpha')).create() product_1 = entities.Product(organization=self.organization).create() product_2 = entities.Product(organization=org_2).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product_1.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) set_context(session, org=org_2.name) self.products.search(product_2.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, force_context=True, ) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_update_1(self, repo_name): """@Test: Update content repository with new URL @Feature: Content Repo - Positive Update @Assert: Repo is updated with new url """ locator = locators["repo.fetch_url"] # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() url_text = self.repository.wait_until_element(locator).text self.assertEqual(url_text, FAKE_1_YUM_REPO) self.navigator.go_to_products() self.products.search(product_name).click() self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO) url_text = self.repository.wait_until_element(locator).text self.assertEqual(url_text, FAKE_2_YUM_REPO)
def test_positive_update_checksum_type(self): """Update content repository with new checksum type @Feature: Content Repo - Positive Update of checksum type. @Assert: Repository is updated with expected checksum type. """ repo_name = gen_string('alphanumeric') checksum_default = CHECKSUM_TYPE['default'] checksum_update = CHECKSUM_TYPE['sha1'] product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum_default)) self.products.search(product.name).click() self.repository.update( repo_name, new_repo_checksum=checksum_update) self.products.search(product.name).click() self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum_update))
def test_negative_create_2(self, repo_name): """@Test: Create repository with same name @Feature: Content Repos - Negative Create with same name @Assert: Repos is not created """ # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) invalid = self.products.wait_until_element( common_locators["common_invalid"]) self.assertTrue(invalid)
def test_positive_update_URL(self, repo_name): """@Test: Update content repository with new URL @Feature: Content Repo - Positive Update @Assert: Repo is updated with new url """ locator = locators['repo.fetch_url'] product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() url_text = self.repository.wait_until_element(locator).text self.assertEqual(url_text, FAKE_1_YUM_REPO) self.navigator.go_to_products() self.products.search(product.name).click() self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO) url_text = self.repository.wait_until_element(locator).text self.assertEqual(url_text, FAKE_2_YUM_REPO)
def test_create_repo_5(self, repo_name): """@Test: Create repository with checksum type as sha256. @Feature: Content Repos - Positive Create @Assert: Repos is created with checksum type as sha256. """ locator = locators['repo.fetch_checksum'] checksum = CHECKSUM_TYPE[u'sha256'] # Creates new product product_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO, repo_checksum=checksum) self.repository.search(repo_name).click() self.repository.wait_for_ajax() checksum_text = session.nav.wait_until_element(locator).text self.assertEqual(checksum_text, checksum)
def test_create_repo_4(self): """@Test: Create and sync a Docker-based repository @Feature: Content Repos - Positive Create @Assert: Docker-based repo is created and synchronized. """ # Creates new product repo_name = u'busybox' product_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB) self.assertIsNotNone(self.repository.search(repo_name)) # Synchronize it self.navigator.go_to_sync_status() synced = self.sync.sync_custom_repos(product_name, [repo_name]) self.assertTrue(synced)
def test_positive_update_checksum_type(self, repo_name): """@Test: Update content repository with new checksum type @Feature: Content Repo - Positive Update of checksum type. @Assert: Repo is updated with new checksum type. """ locator = locators['repo.fetch_checksum'] checksum_default = CHECKSUM_TYPE['default'] checksum_update = CHECKSUM_TYPE['sha1'] product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() checksum_text = self.repository.wait_until_element(locator).text self.assertEqual(checksum_text, checksum_default) self.navigator.go_to_products() self.products.search(product.name).click() self.repository.update( repo_name, new_repo_checksum=checksum_update) checksum_text = self.repository.wait_until_element(locator).text self.assertEqual(checksum_text, checksum_update)
def test_positive_create_in_different_orgs(self): """Create repository in two different orgs with same name @id: 019c2242-8802-4bae-82c5-accf8f793dbc @Assert: Repository is created successfully for both organizations @CaseLevel: Integration """ org_2 = entities.Organization(name=gen_string('alpha')).create() product_1 = entities.Product(organization=self.session_org).create() product_2 = entities.Product(organization=org_2).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.session_org.name) self.products.search(product_1.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) set_context(session, org=org_2.name) self.products.search(product_2.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, force_context=True, ) self.assertIsNotNone(self.repository.search(repo_name))
def test_create_repo_2(self, repo_name): """@Test: Create repository in two different orgs with same name @Assert: Repos is created @Feature: Content Repos - Positive Create """ org_2_name = orm.StringField(str_type=('alphanumeric',), len=(5, 80)).get_value() # Creates new product_1 product_1_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] # Create new product_2 under new organization_2 org_2_id = entities.Organization(name=org_2_name).create()['id'] product_2_name = entities.Product( organization=org_2_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_1_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) session.nav.go_to_select_org(org_2_name) make_repository(session, org=org_2_name, loc=self.loc_name, name=repo_name, product=product_2_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_update_checksum_type(self, repo_name): """@Test: Update content repository with new checksum type @Feature: Content Repo - Positive Update of checksum type. @Assert: Repo is updated with new checksum type. """ checksum_default = CHECKSUM_TYPE['default'] checksum_update = CHECKSUM_TYPE['sha1'] product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum_default)) self.navigator.go_to_products() self.products.search(product.name).click() self.repository.update( repo_name, new_repo_checksum=checksum_update) self.navigator.go_to_products() self.products.search(product.name).click() self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum_update))
def test_create_repo_with_checksum(self, repo_name): """@Test: Create repository with checksum type as sha256. @Feature: Content Repos - Positive Create @Assert: Repos is created with checksum type as sha256. """ locator = locators['repo.fetch_checksum'] checksum = CHECKSUM_TYPE[u'sha256'] # Creates new product product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, repo_checksum=checksum, ) self.repository.search(repo_name).click() self.repository.wait_for_ajax() checksum_text = session.nav.wait_until_element(locator).text self.assertEqual(checksum_text, checksum)
def test_negative_create_with_same_names(self, repo_name): """@Test: Create repository with same name @Feature: Content Repos - Negative Create with same name @Assert: Repos is not created """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) invalid = self.products.wait_until_element( common_locators['common_invalid']) self.assertTrue(invalid)
def test_positive_update_url(self): """Update content repository with new URL @Feature: Content Repo - Positive Update @Assert: Repository is updated with expected url value """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue(self.repository.validate_field( repo_name, 'url', FAKE_1_YUM_REPO)) self.products.search(product.name).click() self.repository.update(repo_name, new_url=FAKE_2_YUM_REPO) self.products.search(product.name).click() self.assertTrue(self.repository.validate_field( repo_name, 'url', FAKE_2_YUM_REPO))
def test_negative_create_with_same_names(self): """Try to create two repositories with same name @Feature: Content Repos - Negative Create with same name @Assert: Repository is not created """ repo_name = gen_string('alphanumeric') product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertTrue( self.products.wait_until_element( common_locators['common_invalid']))
def test_positive_srpm_sync_publish_promote_cv(self): """Synchronize repository with SRPMs, add repository to content view, publish and promote content view to lifecycle environment @id: 4563d1c1-cdce-4838-a67f-c0a5d4e996a6 @Assert: srpms can be listed in content view in proper lifecycle environment """ lce = entities.LifecycleEnvironment( organization=self.session_org).create() product = entities.Product(organization=self.session_org).create() repo_name = gen_string('alphanumeric') cv_name = gen_string('alphanumeric') with Session(self.browser) as session: self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_YUM_SRPM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.setup_navigate_syncnow( session, product.name, repo_name, ) self.assertTrue(self.prd_sync_is_ok(repo_name)) make_contentview(session, org=self.session_org.name, name=cv_name) self.assertIsNotNone(self.content_views.search(cv_name)) self.content_views.add_remove_repos(cv_name, [repo_name]) self.assertIsNotNone( self.content_views.wait_until_element( common_locators['alert.success_sub_form'])) self.content_views.publish(cv_name) self.assertIsNotNone( self.content_views.wait_until_element( common_locators['alert.success_sub_form'])) self.content_views.promote(cv_name, 'Version 1', lce.name) self.assertIsNotNone( self.content_views.wait_until_element( common_locators['alert.success_sub_form'])) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/' ' | grep .src.rpm'.format( self.session_org.label, lce.name, cv_name, product.label, repo_name, )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_create_repo_1(self, repo_name): """@Test: Create repository with minimal input parameters @Feature: Content Repos - Positive Create @Assert: Repos is created """ # Creates new product product_name = entities.Product( organization=self.org_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_create_with_default_download_policy(self): """Verify if the default download policy is assigned when creating a YUM repo without `download_policy` field @id: ee7637fe-3864-4b2f-a153-14312658d75a @Assert: YUM repository with a default download policy """ repo_name = gen_string('alphanumeric') with Session(self.browser) as session: session.nav.go_to_select_org(self.session_org.name, force=False) self.products.search_and_click(self.session_prod.name) make_repository(session, name=repo_name, repo_type='yum') self.assertTrue( self.repository.validate_field(repo_name, 'download_policy', 'Immediate'))
def test_positive_create_with_download_policy(self): """Create YUM repositories with available download policies @id: 8099fb98-963d-4370-bf51-6807f5efd6d3 @Assert: YUM repository with a download policy is created """ repo_name = gen_string('alpha') with Session(self.browser) as session: for policy in DOWNLOAD_POLICIES.values(): with self.subTest(policy): self.products.search_and_click(self.session_prod.name) make_repository(session, name=repo_name, repo_type=REPO_TYPE['yum'], download_policy=policy) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_srpm_sync_publish_cv(self): """Synchronize repository with SRPMs, add repository to content view and publish content view @id: 2a57cbde-c616-440d-8bcb-6e18bd2d5c5f @Assert: srpms can be listed in content view """ product = entities.Product(organization=self.session_org).create() repo_name = gen_string('alphanumeric') cv_name = gen_string('alphanumeric') with Session(self.browser) as session: self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_YUM_SRPM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.setup_navigate_syncnow( session, product.name, repo_name, ) self.assertTrue(self.prd_sync_is_ok(repo_name)) make_contentview(session, org=self.session_org.name, name=cv_name) self.assertIsNotNone(self.content_views.search(cv_name)) self.content_views.add_remove_repos(cv_name, [repo_name]) self.assertIsNotNone( self.content_views.wait_until_element( common_locators['alert.success_sub_form'])) self.content_views.publish(cv_name) self.assertIsNotNone( self.content_views.wait_until_element( common_locators['alert.success_sub_form'])) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}' '/1.0/custom/{}/{}/ | grep .src.rpm'.format( self.session_org.label, cv_name, product.label, repo_name, )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_negative_create_with_invalid_download_policy(self): """Verify that YUM repository cannot be created with invalid download policy @id: dded6dda-3576-4485-8f3c-bb7c091e7ff2 @Assert: YUM repository is not created with invalid download policy """ repo_name = gen_string('alphanumeric') with Session(self.browser) as session: self.products.search_and_click(self.session_prod.name) invalid = gen_string('alpha', 5) msg = "Could not locate element with visible text: %s" % invalid with self.assertRaisesRegexp(NoSuchElementException, msg): make_repository(session, name=repo_name, repo_type='yum', download_policy=invalid)
def test_positive_update_2(self, repo_name): """@Test: Update content repository with new gpg-key @Feature: Content Repo - Positive Update @Assert: Repo is updated with new gpg key """ key_1_content = read_data_file(VALID_GPG_KEY_FILE) key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE) locator = locators["repo.fetch_gpgkey"] # Create two new GPGKey's gpgkey_1_name = entities.GPGKey( content=key_1_content, organization=self.org_id, location=self.loc_id ).create()['name'] gpgkey_2_name = entities.GPGKey( content=key_2_content, organization=self.org_id, location=self.loc_id ).create()['name'] # Creates new product product_name = entities.Product( organization=self.org_id, location=self.loc_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO, gpg_key=gpgkey_1_name) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() gpgkey_1_text = self.repository.wait_until_element(locator).text self.assertEqual(gpgkey_1_text, gpgkey_1_name) self.navigator.go_to_products() self.products.search(product_name).click() self.repository.update(repo_name, new_gpg_key=gpgkey_2_name) gpgkey_2_text = self.repository.wait_until_element(locator).text self.assertEqual(gpgkey_2_text, gpgkey_2_name)
def test_create_repo_3(self): """@Test: Create a Docker-based repository @Feature: Content Repos - Positive Create @Assert: Docker-based repo is created. """ # Creates new product repo_name = u'busybox' product_name = entities.Product( organization=self.org_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, name=repo_name, product=product_name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_create_custom_ostree_repo(self): """Create Custom ostree repository. @id: 852cccdc-7289-4d2f-b23a-7caad2dfa195 @Assert: Create custom ostree repository should be successful """ prod = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): session.nav.go_to_select_org(self.organization.name) self.products.click(self.products.search(prod.name)) make_repository( session, name=repo_name, repo_type=REPO_TYPE['ostree'], url=FEDORA23_OSTREE_REPO, ) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_delete(self): """Create content repository and then remove it @Feature: Content Repos - Positive Delete @Assert: Repository is deleted successfully """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.delete(repo_name)
def test_negative_create_with_too_long_name(self, repo_name): """@Test: Create content repository with 256 characters in name @Feature: Content Repos - Negative Create @Assert: Repos is not created """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) error = self.repository.wait_until_element( common_locators['common_haserror']) self.assertTrue(error)
def test_positive_create_with_name(self): """Create repository with different names and minimal input parameters @Feature: Content Repos - Positive Create @Assert: Repository is created successfully """ prod = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(prod.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name))
def test_remove_repo(self, repo_name): """@Test: Create content repository and remove it @Feature: Content Repos - Positive Delete @Assert: Repos is Deleted """ product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, ) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.delete(repo_name) self.assertIsNone(self.repository.search(repo_name))
def test_negative_create_1(self, repo_name): """@Test: Create repository with blank and whitespace in name @Feature: Content Repos - Negative Create zero length @Assert: Repos is not created """ # Creates new product product_name = entities.Product( organization=self.org_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) invalid = self.products.wait_until_element( common_locators["common_invalid"]) self.assertIsNotNone(invalid)
def test_positive_update_2(self, repo_name): """@Test: Update content repository with new gpg-key @Feature: Content Repo - Positive Update @Assert: Repo is updated with new gpg key """ key_1_content = read_data_file(VALID_GPG_KEY_FILE) key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE) locator = locators["repo.fetch_gpgkey"] # Create two new GPGKey's gpgkey_1_name = entities.GPGKey(content=key_1_content, organization=self.org_id, location=self.loc_id).create()['name'] gpgkey_2_name = entities.GPGKey(content=key_2_content, organization=self.org_id, location=self.loc_id).create()['name'] # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO, gpg_key=gpgkey_1_name) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.search(repo_name).click() self.repository.wait_for_ajax() gpgkey_1_text = self.repository.wait_until_element(locator).text self.assertEqual(gpgkey_1_text, gpgkey_1_name) self.navigator.go_to_products() self.products.search(product_name).click() self.repository.update(repo_name, new_gpg_key=gpgkey_2_name) gpgkey_2_text = self.repository.wait_until_element(locator).text self.assertEqual(gpgkey_2_text, gpgkey_2_name)
def _create_repository(session, org, name, product, upstream_name=None): """Creates a Docker-based repository. :param session: The browser session. :param str org: Name of Organization where product should be created :param str name: Name for the repository :param str product: Name of product where repository should be created. :param str upstream_name: A valid name for an existing upstream repository. If ``None`` then defaults to ``busybox``. """ if upstream_name is None: upstream_name = u'busybox' set_context(session, org=org) Products(session.browser).search_and_click(product) make_repository( session, name=name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB, upstream_repo_name=upstream_name, )
def test_create_repo_1(self, repo_name): """@Test: Create repository with minimal input parameters @Feature: Content Repos - Positive Create @Assert: Repos is created """ # Creates new product product_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name))
def test_negative_create_3(self, repo_name): """@Test: Create content repository with 256 characters in name @Feature: Content Repos - Negative Create @Assert: Repos is not created """ # Creates new product product_name = entities.Product( organization=self.org_id, location=self.loc_id ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) error = self.repository.wait_until_element( common_locators["common_haserror"]) self.assertTrue(error)
def test_positive_update_GPG(self, repo_name): """@Test: Update content repository with new gpg-key @Feature: Content Repo - Positive Update @Assert: Repo is updated with new gpg key """ key_1_content = read_data_file(VALID_GPG_KEY_FILE) key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE) # Create two new GPGKey's gpgkey_1 = entities.GPGKey( content=key_1_content, organization=self.organization, ).create() gpgkey_2 = entities.GPGKey( content=key_2_content, organization=self.organization, ).create() product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, gpg_key=gpgkey_1.name, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue(self.repository.validate_field( repo_name, 'gpgkey', gpgkey_1.name)) self.navigator.go_to_products() self.products.search(product.name).click() self.repository.update(repo_name, new_gpg_key=gpgkey_2.name) self.navigator.go_to_products() self.products.search(product.name).click() self.assertTrue(self.repository.validate_field( repo_name, 'gpgkey', gpgkey_2.name))
def test_create_repo_with_checksum(self, repo_name): """@Test: Create repository with checksum type as sha256. @Feature: Content Repos - Positive Create @Assert: Repos is created with checksum type as sha256. """ checksum = CHECKSUM_TYPE[u'sha256'] # Creates new product product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, url=FAKE_1_YUM_REPO, repo_checksum=checksum, ) self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum))
def test_remove_repo(self, repo_name): """@Test: Create content repository and remove it @Feature: Content Repos - Positive Delete @Assert: Repos is Deleted """ # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) self.repository.delete(repo_name) self.assertIsNone(self.repository.search(repo_name))
def test_negative_create_3(self, repo_name): """@Test: Create content repository with 256 characters in name @Feature: Content Repos - Negative Create @Assert: Repos is not created """ # Creates new product product_name = entities.Product(organization=self.org_id, location=self.loc_id).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, url=FAKE_1_YUM_REPO) error = self.repository.wait_until_element( common_locators["common_haserror"]) self.assertTrue(error)
def test_negative_create_with_invalid_name(self): """Create repository with invalid names @Feature: Content Repos - Negative Create @Assert: Repository is not created """ # Creates new product product = entities.Product(organization=self.organization).create() for repo_name in invalid_values_list(interface='ui'): with self.subTest(repo_name): with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, ) invalid = self.products.wait_until_element( common_locators['common_invalid']) self.assertIsNotNone(invalid)
def test_positive_update_gpg(self): """Update content repository with new gpg-key @Feature: Content Repo - Positive Update @Assert: Repository is updated with new gpg key """ repo_name = gen_string('alphanumeric') key_1_content = read_data_file(VALID_GPG_KEY_FILE) key_2_content = read_data_file(VALID_GPG_KEY_BETA_FILE) # Create two new GPGKey's gpgkey_1 = entities.GPGKey( content=key_1_content, organization=self.organization, ).create() gpgkey_2 = entities.GPGKey( content=key_2_content, organization=self.organization, ).create() product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, gpg_key=gpgkey_1.name, ) self.assertIsNotNone(self.repository.search(repo_name)) self.assertTrue( self.repository.validate_field(repo_name, 'gpgkey', gpgkey_1.name)) self.products.search(product.name).click() self.repository.update(repo_name, new_gpg_key=gpgkey_2.name) self.products.search(product.name).click() self.assertTrue( self.repository.validate_field(repo_name, 'gpgkey', gpgkey_2.name))
def test_create_repo_deocker(self): """@Test: Create a Docker-based repository @Feature: Content Repos - Positive Create @Assert: Docker-based repo is created. """ repo_name = gen_string('alpha', 8) # Creates new product product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: make_repository( session, org=self.organization.name, name=repo_name, product=product.name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB, upstream_repo_name=u'busybox', ) self.assertIsNotNone(self.repository.search(repo_name))
def test_create_repo_2(self, repo_name): """@Test: Create repository in two different orgs with same name @Assert: Repos is created @Feature: Content Repos - Positive Create """ org_2_name = gen_string("alpha", 10) # Creates new product_1 product_1_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] # Create new product_2 under new organization_2 org_2_id = entities.Organization(name=org_2_name).create()['id'] product_2_name = entities.Product( organization=org_2_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_1_name, url=FAKE_1_YUM_REPO) self.assertIsNotNone(self.repository.search(repo_name)) make_repository(session, org=org_2_name, loc=self.loc_name, name=repo_name, product=product_2_name, url=FAKE_1_YUM_REPO, force_context=True) self.assertIsNotNone(self.repository.search(repo_name))
def test_create_repo_3(self): """@Test: Create a Docker-based repository @Feature: Content Repos - Positive Create @Assert: Docker-based repo is created. """ # Creates new product repo_name = u'busybox' product_name = entities.Product( organization=self.org_id, location=self.loc_id, ).create()['name'] with Session(self.browser) as session: make_repository(session, org=self.org_name, loc=self.loc_name, name=repo_name, product=product_name, repo_type=REPO_TYPE['docker'], url=DOCKER_REGISTRY_HUB) self.assertIsNotNone(self.repository.search(repo_name))
def test_positive_create_repo_with_checksum(self): """Create repository with checksum type as sha256. @Feature: Content Repos - Positive Create @Assert: Repository is created with expected checksum type. """ checksum = CHECKSUM_TYPE[u'sha256'] # Creates new product product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, repo_checksum=checksum, ) self.assertTrue(self.repository.validate_field( repo_name, 'checksum', checksum))
def test_positive_create_repo_with_checksum(self): """Create repository with checksum type as sha256. @Feature: Content Repos - Positive Create @Assert: Repository is created with expected checksum type. """ checksum = CHECKSUM_TYPE[u'sha256'] # Creates new product product = entities.Product(organization=self.organization).create() with Session(self.browser) as session: for repo_name in generate_strings_list(): with self.subTest(repo_name): set_context(session, org=self.organization.name) self.products.search(product.name).click() make_repository( session, name=repo_name, url=FAKE_1_YUM_REPO, repo_checksum=checksum, ) self.assertTrue( self.repository.validate_field(repo_name, 'checksum', checksum))
def test_smoke(self): """@Test: Check that basic content can be created * Create a new user with admin permissions * Using the new user from above: * Create a new organization * Create two new lifecycle environments * Create a custom product * Create a custom YUM repository * Create a custom PUPPET repository * Synchronize both custom repositories * Create a new content view * Associate both repositories to new content view * Publish content view * Promote content view to both lifecycles * Create a new libvirt compute resource * Create a new subnet * Create a new domain * Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ user_name = gen_string("alpha", 6) password = gen_string("alpha", 6) org_name = gen_string("alpha", 6) env_1_name = gen_string("alpha", 6) env_2_name = gen_string("alpha", 6) product_name = gen_string("alpha", 6) yum_repository_name = gen_string("alpha", 6) puppet_repository_name = gen_string("alpha", 6) cv_name = gen_string("alpha", 6) puppet_module = "httpd" module_ver = 'Latest' compute_resource_name = gen_string("alpha", 6) libvirt_url = "qemu+tcp://%s:16509/system" provider_type = FOREMAN_PROVIDERS['libvirt'] url = (libvirt_url % conf.properties['main.server.hostname']) subnet_name = gen_string("alpha", 6) domain_name = gen_string("alpha", 6) domain = description = DOMAIN % domain_name hostgroup_name = gen_string("alpha", 6) # Create new user with admin permissions with Session(self.browser) as session: make_user(session, username=user_name, password1=password, password2=password) self.assertIsNotNone(self.user.search(user_name, "login")) is_admin_role_selected = self.user.admin_role_to_user(user_name) self.assertTrue(is_admin_role_selected) # FIX ME: UI doesn't authenticate user created via UI auto: Issue #1152 # Once #1152 is fixed; need to pass user_name and password to Session with Session(self.browser) as session: # Create New organization make_org(session, org_name=org_name) self.assertIsNotNone(self.org.search(org_name)) # Create New Lifecycle environment1 make_lifecycle_environment(session, org=org_name, name=env_1_name) strategy, value = locators["content_env.select_name"] self.assertIsNotNone( self.contentenv.wait_until_element( (strategy, value % env_1_name))) # Create New Lifecycle environment2 make_lifecycle_environment(session, org=org_name, name=env_2_name, prior=env_1_name) self.assertIsNotNone( self.contentenv.wait_until_element( (strategy, value % env_2_name))) # Create custom product make_product(session, org=org_name, name=product_name) self.assertIsNotNone(self.products.search(product_name)) # Create a YUM repository make_repository(session, org=org_name, name=yum_repository_name, product=product_name, url=GOOGLE_CHROME_REPO) self.assertIsNotNone(self.repository.search(yum_repository_name)) # Create a puppet Repository make_repository(session, org=org_name, name=puppet_repository_name, product=product_name, url=FAKE_0_PUPPET_REPO, repo_type=REPO_TYPE['puppet']) self.assertIsNotNone( self.repository.search(puppet_repository_name)) # Sync YUM and puppet repository self.navigator.go_to_sync_status() sync = self.sync.sync_custom_repos( product_name, [yum_repository_name, puppet_repository_name]) self.assertIsNotNone(sync) # Create new content-view make_contentview(session, org=org_name, name=cv_name) self.assertIsNotNone(self.content_views.search(cv_name)) # Add YUM repository to content-view self.content_views.add_remove_repos(cv_name, [yum_repository_name]) if not bz_bug_is_open(1191422): self.assertIsNotNone( self.content_views.wait_until_element( common_locators["alert.success"])) # Add puppet-module to content-view self.content_views.add_puppet_module(cv_name, puppet_module, filter_term=module_ver) # Publish content-view self.content_views.publish(cv_name) if not bz_bug_is_open(1191422): self.assertIsNotNone( self.content_views.wait_until_element( common_locators["alert.success"])) # Promote content-view to life-cycle environment 1 self.content_views.promote(cv_name, version="Version 1", env=env_1_name) if not bz_bug_is_open(1191422): self.assertIsNotNone( self.content_views.wait_until_element( common_locators["alert.success"])) # Promote content-view to life-cycle environment 2 self.content_views.promote(cv_name, version="Version 1", env=env_2_name) if not bz_bug_is_open(1191422): self.assertIsNotNone( self.content_views.wait_until_element( common_locators["alert.success"])) # Create a new libvirt compute resource make_resource(session, org=org_name, name=compute_resource_name, provider_type=provider_type, url=url) self.assertIsNotNone( self.compute_resource.search(compute_resource_name)) # Create a subnet make_subnet(session, org=org_name, subnet_name=subnet_name, subnet_network=gen_ipaddr(ip3=True), subnet_mask="255.255.255.0") self.assertIsNotNone(self.subnet.search_subnet(subnet_name)) # Create a Domain make_domain(session, org=org_name, name=domain, description=description) self.assertIsNotNone(self.domain.search(description)) # Create a HostGroup make_hostgroup(session, name=hostgroup_name) self.assertIsNotNone(self.hostgroup.search(hostgroup_name))