def test_positive_update_gpg(self): """Create a product and update its GPGKey :id: 3b08f155-a0d6-4987-b281-dc02e8d5a03e :expectedresults: The updated product points to a new GPG key. :CaseLevel: Integration """ # Create a product and make it point to a GPG key. gpg_key_1 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_FILE), organization=self.org, ).create() product = entities.Product(gpg_key=gpg_key_1, organization=self.org).create() # Update the product and make it point to a new GPG key. gpg_key_2 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_BETA_FILE), organization=self.org, ).create() product.gpg_key = gpg_key_2 product = product.update() self.assertEqual(product.gpg_key.id, gpg_key_2.id)
def test_positive_update_gpg(self): """Create a repository and update its GPGKey @id: 0e9319dc-c922-4ecf-9f83-d221cfdf54c2 @Assert: The updated repository points to a new GPG key. @CaseLevel: Integration """ # Create a repo and make it point to a GPG key. gpg_key_1 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_FILE), organization=self.org, ).create() repo = entities.Repository( gpg_key=gpg_key_1, product=self.product, ).create() # Update the repo and make it point to a new GPG key. gpg_key_2 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_BETA_FILE), organization=self.org, ).create() repo.gpg_key = gpg_key_2 repo = repo.update() self.assertEqual(repo.gpg_key.id, gpg_key_2.id)
def test_positive_update_gpg(self): """Create a repository and update its GPGKey @Assert: The updated repository points to a new GPG key. @Feature: Repository """ # Create a repo and make it point to a GPG key. gpg_key_1 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_FILE), organization=self.org, ).create() repo = entities.Repository( gpg_key=gpg_key_1, product=self.product, ).create() # Update the repo and make it point to a new GPG key. gpg_key_2 = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_BETA_FILE), organization=self.org, ).create() repo.gpg_key = gpg_key_2 repo = repo.update() self.assertEqual(repo.gpg_key.id, gpg_key_2.id)
def test_positive_end_to_end_custom_yum_crud(session, module_org, module_prod): """Perform end to end testing for custom yum repository :id: 8baf11c9-019e-4625-a549-ec4cd9312f75 :expectedresults: All expected CRUD actions finished successfully :CaseLevel: Integration :CaseImportance: High """ repo_name = gen_string('alpha') checksum_type = 'sha256' new_repo_name = gen_string('alphanumeric') new_checksum_type = 'sha1' gpg_key = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_FILE), organization=module_org ).create() new_gpg_key = entities.GPGKey( content=read_data_file(VALID_GPG_KEY_BETA_FILE), organization=module_org ).create() with session: session.repository.create( module_prod.name, { 'name': repo_name, 'repo_type': REPO_TYPE['yum'], 'repo_content.upstream_url': settings.repos.yum_1.url, 'repo_content.checksum_type': checksum_type, 'repo_content.gpg_key': gpg_key.name, 'repo_content.download_policy': DOWNLOAD_POLICIES['immediate'], }, ) assert session.repository.search(module_prod.name, repo_name)[0]['Name'] == repo_name repo_values = session.repository.read(module_prod.name, repo_name) assert repo_values['repo_content']['upstream_url'] == settings.repos.yum_1.url assert repo_values['repo_content']['metadata_type'] == checksum_type assert repo_values['repo_content']['gpg_key'] == gpg_key.name assert repo_values['repo_content']['download_policy'] == DOWNLOAD_POLICIES['immediate'] session.repository.update( module_prod.name, repo_name, { 'name': new_repo_name, 'repo_content.upstream_url': settings.repos.yum_2.url, 'repo_content.metadata_type': new_checksum_type, 'repo_content.gpg_key': new_gpg_key.name, 'repo_content.download_policy': DOWNLOAD_POLICIES['immediate'], }, ) assert not session.repository.search(module_prod.name, repo_name) repo_values = session.repository.read(module_prod.name, new_repo_name) assert repo_values['name'] == new_repo_name assert repo_values['repo_content']['upstream_url'] == settings.repos.yum_2.url assert repo_values['repo_content']['metadata_type'] == new_checksum_type assert repo_values['repo_content']['gpg_key'] == new_gpg_key.name assert repo_values['repo_content']['download_policy'] == DOWNLOAD_POLICIES['immediate'] session.repository.delete(module_prod.name, new_repo_name) assert not session.repository.search(module_prod.name, new_repo_name)
def test_negative_create_with_same_name(self): """Attempt to create a GPG key providing a name of already existent entity @id: 78299f13-5977-4409-9bc7-844e54349926 @Assert: A GPG key is not created and error is raised. """ name = gen_string('alphanumeric') entities.GPGKey(organization=self.org, name=name).create() with self.assertRaises(HTTPError): entities.GPGKey(organization=self.org, name=name).create()
def test_negative_update_same_name(self): """Attempt to update GPG key name to the name of existing GPG key entity @id: e294e3b2-1125-4ad9-969a-eb3f1966419e @Assert: GPG key is not updated """ name = gen_string('alpha') entities.GPGKey(organization=self.org, name=name).create() new_gpg_key = entities.GPGKey(organization=self.org).create() new_gpg_key.name = name with self.assertRaises(HTTPError): new_gpg_key.update(['name'])
def test_negative_create_with_same_name(module_org): """Attempt to create a GPG key providing a name of already existent entity :id: 78299f13-5977-4409-9bc7-844e54349926 :expectedresults: A GPG key is not created and 422 error is raised. :CaseImportance: Critical """ name = gen_string('alphanumeric') entities.GPGKey(organization=module_org, name=name).create() with pytest.raises(HTTPError) as error: entities.GPGKey(organization=module_org, name=name).create() assert error.value.response.status_code == 422 assert 'Validation failed:' in error.value.response.text
def test_positive_end_to_end(session, module_org): """Perform end to end testing for product component :id: d0e1f0d1-2380-4508-b270-62c1d8b3e2ff :expectedresults: All expected CRUD actions finished successfully :CaseLevel: Integration :CaseImportance: Critical """ product_name = gen_string('alpha') new_product_name = gen_string('alpha') product_label = gen_string('alpha') product_description = gen_string('alpha') gpg_key = entities.GPGKey(content=read_data_file(VALID_GPG_KEY_FILE), organization=module_org).create() sync_plan = entities.SyncPlan(organization=module_org).create() with session: # Create new product using different parameters session.product.create({ 'name': product_name, 'label': product_label, 'gpg_key': gpg_key.name, 'sync_plan': sync_plan.name, 'description': product_description, }) assert session.product.search(product_name)[0]['Name'] == product_name # Verify that created entity has expected parameters product_values = session.product.read(product_name) assert product_values['details']['name'] == product_name assert product_values['details']['label'] == product_label assert product_values['details']['gpg_key'] == gpg_key.name assert product_values['details']['description'] == product_description assert product_values['details']['sync_plan'] == sync_plan.name # Update a product with a different name session.product.update(product_name, {'details.name': new_product_name}) assert session.product.search(product_name)[0]['Name'] != product_name assert session.product.search( new_product_name)[0]['Name'] == new_product_name # Add a repo to product session.repository.create( new_product_name, { 'name': gen_string('alpha'), 'repo_type': REPO_TYPE['yum'], 'repo_content.upstream_url': FAKE_1_YUM_REPO, }, ) # Synchronize the product result = session.product.synchronize(new_product_name) assert result['result'] == 'success' product_values = session.product.read(new_product_name) assert product_values['details']['repos_count'] == '1' assert product_values['details']['sync_state'] == 'Syncing Complete.' # Delete product session.product.delete(new_product_name) assert session.product.search( new_product_name)[0]['Name'] != new_product_name
def test_positive_add_repo_from_product_with_repo(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has one repository :id: 5d78890f-4130-4dc3-9cfe-48999149422f :expectedresults: gpg key is associated with the repository but not with the product :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product product = entities.Product(organization=module_org).create() # Creates new repository repo = entities.Repository(url=FAKE_1_YUM_REPO, product=product).create() with session: values = session.contentcredential.read(name) assert values['products']['table'][0]['Name'] == empty_message # Associate gpg key with repository session.repository.update(product.name, repo.name, {'repo_content.gpg_key': gpg_key.name}) values = session.contentcredential.read(name) assert values['products']['table'][0]['Name'] == empty_message assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo.name assert values['repositories']['table'][0]['Product'] == product.name
def test_positive_delete_key_for_empty_product(self): """Create gpg key with valid name and valid gpg key then associate it with empty (no repos) custom product then delete it :id: b9766403-61b2-4a88-a744-a25d53d577fb :expectedresults: gpg key is associated with product during creation but removed from product after deletion :CaseLevel: Integration """ name = get_random_gpgkey_name() gpg_key = entities.GPGKey( content=self.key_content, name=name, organization=self.organization, ).create() # Creates new product and associate GPGKey with it product = entities.Product( gpg_key=gpg_key, name=gen_string('alpha'), organization=self.organization, ).create() with Session(self) as session: session.nav.go_to_select_org(self.organization.name) # Assert that GPGKey is associated with product self.assertIsNotNone( self.gpgkey.get_product_repo(name, product.name)) self.gpgkey.delete(name) # Assert GPGKey isn't associated with product prd_element = self.products.search(product.name) self.assertIsNone( self.gpgkey.assert_key_from_product(name, prd_element))
def test_positive_add_empty_product(self, session): """Create gpg key with valid name and valid gpg key then associate it with empty (no repos) custom product :id: e18ae9f5-43d9-4049-92ca-1eafaca05096 :expectedresults: gpg key is associated with product :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey( content=self.key_content, name=name, organization=self.organization, ).create() # Creates new product and associate GPGKey with it product = entities.Product( gpg_key=gpg_key, organization=self.organization, ).create() with session: session.organization.select(org_name=self.organization.name) values = session.contentcredential.read(name) assert len(values['products']['resources']) == 1 assert values['products']['resources'][0]['Name'] == product.name assert values['products']['resources'][0]['Used as'] == 'GPG Key'
def test_positive_delete_key_for_repo_from_product_with_repo( session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has one repository then delete the key :id: 92ba492e-79af-48fe-84cb-763102b42fa7 :expectedresults: gpg key is associated with single repository during creation but removed from repository after deletion :CaseLevel: Integration """ gpg_key = entities.GPGKey(content=gpg_content, organization=module_org).create() # Creates new product without selecting GPGkey product = entities.Product(name=gen_string('alpha'), organization=module_org).create() # Creates new repository with GPGKey repo = entities.Repository(name=gen_string('alpha'), url=FAKE_1_YUM_REPO, product=product, gpg_key=gpg_key).create() with session: # Assert that GPGKey is associated with product values = session.contentcredential.read(gpg_key.name) assert values['products']['table'][0]['Name'] == empty_message assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo.name repo_values = session.repository.read(product.name, repo.name) assert repo_values['repo_content']['gpg_key'] == gpg_key.name session.contentcredential.delete(gpg_key.name) # Assert GPGKey isn't associated with repository repo_values = session.repository.read(product.name, repo.name) assert not repo_values['repo_content']['gpg_key']
def test_positive_add_repo_from_product_with_repos(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has more than one repository :id: 1fb38e01-4c04-4609-842d-069f96157317 :expectedresults: gpg key is associated with one of the repositories but not with the product :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product without selecting GPGkey product = entities.Product(organization=module_org).create() # Creates new repository with GPGKey repo1 = entities.Repository(url=FAKE_1_YUM_REPO, product=product, gpg_key=gpg_key).create() # Creates new repository without GPGKey entities.Repository(url=FAKE_2_YUM_REPO, product=product).create() with session: values = session.contentcredential.read(name) assert values['products']['table'][0]['Name'] == empty_message assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo1.name
def test_positive_delete_key_for_empty_product(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with empty (no repos) custom product then delete it :id: b9766403-61b2-4a88-a744-a25d53d577fb :expectedresults: gpg key is associated with product during creation but removed from product after deletion :CaseLevel: Integration """ gpg_key = entities.GPGKey(content=gpg_content, organization=module_org).create() # Creates new product and associate GPGKey with it product = entities.Product(gpg_key=gpg_key, name=gen_string('alpha'), organization=module_org).create() with session: # Assert that GPGKey is associated with product gpg_values = session.contentcredential.read(gpg_key.name) assert len(gpg_values['products']['table']) == 1 assert gpg_values['products']['table'][0]['Name'] == product.name product_values = session.product.read(product.name) assert product_values['details']['gpg_key'] == gpg_key.name session.contentcredential.delete(gpg_key.name) # Assert GPGKey isn't associated with product product_values = session.product.read(product.name) assert not product_values['details']['gpg_key']
def test_positive_update_key_for_repo_from_product_with_repo( session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has one repository then update the key :id: 9827306e-76d7-4aef-8074-e97fc39d3bbb :expectedresults: gpg key is associated with repository after update but not with product. :CaseLevel: Integration """ name = gen_string('alpha') new_name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product without selecting GPGkey product = entities.Product(organization=module_org).create() # Creates new repository with GPGKey repo = entities.Repository(gpg_key=gpg_key, product=product, url=FAKE_1_YUM_REPO).create() with session: session.contentcredential.update(name, {'details.name': new_name}) values = session.contentcredential.read(new_name) # Assert that after update GPGKey is not associated with product assert values['products']['table'][0]['Name'] == empty_message # Assert that after update GPGKey is still associated # with repository assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo.name
def test_positive_update_key_for_repo_from_product_with_repos( session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has more than one repository then update the key :id: d4f2fa16-860c-4ad5-b04f-8ce24b5618e9 :expectedresults: gpg key is associated with single repository after update but not with product :CaseLevel: Integration """ name = gen_string('alpha') new_name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product without selecting GPGkey product = entities.Product(organization=module_org).create() # Creates new repository_1 with GPGKey repo1 = entities.Repository(url=FAKE_1_YUM_REPO, product=product, gpg_key=gpg_key).create() # Creates new repository_2 without GPGKey entities.Repository(product=product, url=FAKE_2_YUM_REPO).create() with session: session.contentcredential.update(name, {'details.name': new_name}) values = session.contentcredential.read(new_name) assert values['products']['table'][0]['Name'] == empty_message assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo1.name
def test_positive_update_key_for_product_with_repo(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with custom product that has one repository then update the key :id: 02cb0601-6aa2-4589-b61e-3d3785a7e100 :expectedresults: gpg key is associated with product as well as with repository after update :CaseLevel: Integration """ name = gen_string('alpha') new_name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product and associate GPGKey with it product = entities.Product(gpg_key=gpg_key, organization=module_org).create() # Creates new repository without GPGKey repo = entities.Repository(product=product, url=FAKE_1_YUM_REPO).create() with session: session.contentcredential.update(name, {'details.name': new_name}) values = session.contentcredential.read(new_name) # Assert that GPGKey is still associated with product assert len(values['products']['table']) == 1 assert values['products']['table'][0]['Name'] == product.name assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo.name
def test_positive_update_key_for_product_with_repos(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with custom product that has more than one repository then update the key :id: 3ca4d9ff-8032-4c2a-aed9-00ac2d1352d1 :expectedresults: gpg key is associated with product as well as with repositories after update :CaseLevel: Integration """ name = gen_string('alpha') new_name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product and associate GPGKey with it product = entities.Product(gpg_key=gpg_key, organization=module_org).create() # Creates new repository_1 without GPGKey repo1 = entities.Repository(product=product, url=FAKE_1_YUM_REPO).create() # Creates new repository_2 without GPGKey repo2 = entities.Repository(product=product, url=FAKE_2_YUM_REPO).create() with session: session.contentcredential.update(name, {'details.name': new_name}) values = session.contentcredential.read(new_name) assert len(values['repositories']['table']) == 2 assert {repo1.name, repo2.name} == { repo['Name'] for repo in values['repositories']['table'] }
def test_positive_add_repo_from_product_with_repo(self, session): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has one repository :id: 5d78890f-4130-4dc3-9cfe-48999149422f :expectedresults: gpg key is associated with the repository but not with the product :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey( content=self.key_content, name=name, organization=self.organization, ).create() # Creates new product without selecting GPGkey product = entities.Product(organization=self.organization).create() # Creates new repository with GPGKey repo = entities.Repository( url=FAKE_1_YUM_REPO, product=product, gpg_key=gpg_key, ).create() with session: session.organization.select(org_name=self.organization.name) values = session.contentcredential.read(name) assert len(values['repositories']['resources']) == 1 assert values['repositories']['resources'][0]['Name'] == repo.name assert (values['repositories']['resources'][0]['Product'] == product.name)
def test_positive_update_key_for_empty_product(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with empty (no repos) custom product then update the key :id: 519817c3-9b67-4859-8069-95987ebf9453 :expectedresults: gpg key is associated with product before/after update :CaseLevel: Integration """ name = gen_string('alpha') new_name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product and associate GPGKey with it product = entities.Product(gpg_key=gpg_key, organization=module_org).create() with session: values = session.contentcredential.read(name) # Assert that GPGKey is associated with product assert len(values['products']['table']) == 1 assert values['products']['table'][0]['Name'] == product.name session.contentcredential.update(name, {'details.name': new_name}) values = session.contentcredential.read(new_name) # Assert that GPGKey is still associated with product assert len(values['products']['table']) == 1 assert values['products']['table'][0]['Name'] == product.name
def test_positive_add_product_with_repos(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with custom product that has more than one repository :id: 0edffad7-0ab4-4bef-b16b-f6c8de55b0dc :expectedresults: gpg key is properly associated with repositories :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product and associate GPGKey with it product = entities.Product(gpg_key=gpg_key, organization=module_org).create() # Creates new repository_1 without GPGKey repo1 = entities.Repository(product=product, url=FAKE_1_YUM_REPO).create() # Creates new repository_2 without GPGKey repo2 = entities.Repository(product=product, url=FAKE_2_YUM_REPO).create() with session: values = session.contentcredential.read(name) assert len(values['repositories']['table']) == 2 assert {repo1.name, repo2.name} == { repo['Name'] for repo in values['repositories']['table'] }
def test_positive_add_product_with_repo(session, module_org, gpg_content): """Create gpg key with valid name and valid gpg key then associate it with custom product that has one repository :id: 7514b33a-da75-43bd-a84b-5a805c84511d :expectedresults: gpg key is associated with product as well as with the repository :CaseLevel: Integration """ name = gen_string('alpha') gpg_key = entities.GPGKey(content=gpg_content, name=name, organization=module_org).create() # Creates new product product = entities.Product(organization=module_org).create() # Creates new repository without GPGKey repo = entities.Repository(url=FAKE_1_YUM_REPO, product=product).create() with session: values = session.contentcredential.read(name) assert values['products']['table'][0]['Name'] == empty_message # Associate gpg key with a product session.product.update(product.name, {'details.gpg_key': gpg_key.name}) values = session.contentcredential.read(name) assert len(values['products']['table']) == 1 assert values['products']['table'][0]['Name'] == product.name assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo.name assert values['repositories']['table'][0]['Product'] == product.name assert values['repositories']['table'][0]['Type'] == 'yum' assert values['repositories']['table'][0][ 'Used as'] == CONTENT_CREDENTIALS_TYPES['gpg']
def test_negative_create_with_content(self): """Attempt to create GPG key with empty content. @id: fc79c840-6bcb-4d97-9145-c0008d5b028d @Assert: A GPG key is not created and error is raised. """ with self.assertRaises(HTTPError): entities.GPGKey(content='').create()
def test_negative_update_same_name(module_org): """Attempt to update GPG key name to the name of existing GPG key entity :id: e294e3b2-1125-4ad9-969a-eb3f1966419e :expectedresults: GPG key is not updated and 422 error is raised. :CaseImportance: Critical """ name = gen_string('alpha') entities.GPGKey(organization=module_org, name=name).create() new_gpg_key = entities.GPGKey(organization=module_org).create() new_gpg_key.name = name with pytest.raises(HTTPError) as error: new_gpg_key.update(['name']) assert error.value.response.status_code == 422 assert 'Validation failed:' in error.value.response.text
def test_positive_delete_key_for_product_with_repos(self, session): """Create gpg key with valid name and valid gpg key then associate it with custom product that has more than one repository then delete it :id: cb5d4efd-863a-4b8e-b1f8-a0771e90ff5e :expectedresults: gpg key is associated with product as well as with repositories during creation but removed from product after deletion :CaseLevel: Integration """ gpg_key = entities.GPGKey( content=self.key_content, organization=self.organization, ).create() # Creates new product and associate GPGKey with it product = entities.Product( gpg_key=gpg_key, name=gen_string('alpha'), organization=self.organization, ).create() # Creates new repository_1 without GPGKey repo1 = entities.Repository( name=gen_string('alpha'), product=product, url=FAKE_1_YUM_REPO, ).create() # Creates new repository_2 without GPGKey repo2 = entities.Repository( name=gen_string('alpha'), product=product, url=FAKE_2_YUM_REPO, ).create() with session: session.organization.select(org_name=self.organization.name) # Assert that GPGKey is associated with product values = session.contentcredential.read(gpg_key.name) assert len(values['products']['table']) == 1 assert values['products']['table'][0]['Name'] == product.name assert len(values['repositories']['table']) == 2 assert ( {repo1.name, repo2.name} == set([ repo['Name'] for repo in values['repositories']['table']]) ) session.contentcredential.delete(gpg_key.name) # Assert GPGKey isn't associated with product and repositories product_values = session.product.read(product.name) assert not product_values['details']['gpg_key'] for repo in [repo1, repo2]: repo_values = session.repository.read(product.name, repo.name) assert not repo_values['repo_content']['gpg_key']
def test_positive_create_with_content(self): """Create a GPG key with valid name and valid gpg key text. @id: cfa6690e-fed7-49cf-94f9-fd2deed941c0 @Assert: A GPG key is created with the expected content. """ gpg_key = entities.GPGKey(organization=self.org, content=self.key_content).create() self.assertEqual(self.key_content, gpg_key.content)
def test_positive_delete_key_for_repo_from_product_with_repos( self, session): """Create gpg key with valid name and valid gpg key then associate it to repository from custom product that has more than one repository then delete the key :id: 5f204a44-bf7b-4a9c-9974-b701e0d38860 :expectedresults: gpg key is associated with single repository but not with product during creation but removed from repository after deletion :BZ: 1461804 :CaseLevel: Integration """ # Creates New GPGKey gpg_key = entities.GPGKey( content=self.key_content, organization=self.organization, ).create() # Creates new product without GPGKey association product = entities.Product( name=gen_string('alpha'), organization=self.organization, ).create() # Creates new repository_1 with GPGKey association repo1 = entities.Repository( gpg_key=gpg_key, name=gen_string('alpha'), product=product, url=FAKE_1_YUM_REPO, ).create() repo2 = entities.Repository( name=gen_string('alpha'), product=product, url=FAKE_2_YUM_REPO, # notice that we're not making this repo point to the GPG key ).create() with session: session.organization.select(org_name=self.organization.name) # Assert that GPGKey is associated with product values = session.contentcredential.read(gpg_key.name) assert len(values['products']['table']) == 0 assert len(values['repositories']['table']) == 1 assert values['repositories']['table'][0]['Name'] == repo1.name repo_values = session.repository.read(product.name, repo1.name) assert repo_values['repo_content']['gpg_key'] == gpg_key.name repo_values = session.repository.read(product.name, repo2.name) assert not repo_values['repo_content']['gpg_key'] session.contentcredential.delete(gpg_key.name) # Assert GPGKey isn't associated with repositories for repo in [repo1, repo2]: repo_values = session.repository.read(product.name, repo.name) assert not repo_values['repo_content']['gpg_key']
def test_negative_create_with_content(self): """Attempt to create GPG key with empty content. :id: fc79c840-6bcb-4d97-9145-c0008d5b028d :expectedresults: A GPG key is not created and error is raised. :CaseImportance: Critical """ with self.assertRaises(HTTPError): entities.GPGKey(content='').create()
def test_positive_delete(self): """Create a GPG key with different names and then delete it. @id: b06d211f-2827-40f7-b627-8b1fbaee2eb4 @Assert: The GPG key deleted successfully. """ gpg_key = entities.GPGKey(organization=self.org).create() gpg_key.delete() with self.assertRaises(HTTPError): gpg_key.read()
def test_negative_create_name(self): """Attempt to create GPG key with invalid names only. @id: 904a3ed0-7d50-495e-a700-b4f1ae913599 @Assert: A GPG key is not created and error is raised. """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(HTTPError): entities.GPGKey(name=name).create()