def test_negative_create_with_same_name(self): """@test: Create gpg key with valid name and valid gpg key via file import then try to create new one with same name @feature: GPG Keys @assert: gpg key is not created @BZ: 1172009 """ name = gen_string('alphanumeric') gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual(gpg_key[self.search_key], result[self.search_key]) # Try to create a gpg key with the same name with self.assertRaises(CLIFactoryError): make_gpg_key({ 'name': name, 'organization-id': self.org['id'], })
def test_positive_update_gpg_key(self): """Update product's gpg keys @Feature: Product @Assert: Product gpg key is updated """ first_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) second_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) product = make_product({ u'gpg-key-id': first_gpg_key['id'], u'organization-id': self.org['id'], }) # Update the Descriptions Product.update({ u'gpg-key-id': second_gpg_key['id'], u'id': product['id'], }) # Fetch it product = Product.info({ u'id': product['id'], u'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], second_gpg_key['id']) self.assertNotEqual(product['gpg']['gpg-key-id'], first_gpg_key['id'])
def test_negative_create_with_same_name(self): """Create gpg key with valid name and valid gpg key via file import then try to create new one with same name :id: 3f1423da-bcc1-4320-8b9b-260784eb123c :expectedresults: gpg key is not created :CaseImportance: Critical """ name = gen_string('alphanumeric') gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual(gpg_key[self.search_key], result[self.search_key]) # Try to create a gpg key with the same name with self.assertRaises(CLIFactoryError): make_gpg_key({ 'name': name, 'organization-id': self.org['id'], })
def test_negative_create_with_same_name(self): """Create gpg key with valid name and valid gpg key via file import then try to create new one with same name :id: 3f1423da-bcc1-4320-8b9b-260784eb123c :expectedresults: gpg key is not created :CaseImportance: Critical """ name = gen_string('alphanumeric') gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) # Can we find the new object? result = GPGKey.exists({'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key])) self.assertEqual(gpg_key[self.search_key], result[self.search_key]) # Try to create a gpg key with the same name with self.assertRaises(CLIFactoryError): make_gpg_key({ 'name': name, 'organization-id': self.org['id'], })
def test_positive_update_gpg_key(self): """Update product's gpg keys :id: e7febd14-ac8b-424e-9ddf-bf0f63ebe430 :expectedresults: Product gpg key is updated :CaseImportance: Critical """ first_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) second_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) product = make_product({ u'gpg-key-id': first_gpg_key['id'], u'organization-id': self.org['id'], }) # Update the Descriptions Product.update({ u'gpg-key-id': second_gpg_key['id'], u'id': product['id'], }) # Fetch it product = Product.info({ u'id': product['id'], u'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], second_gpg_key['id']) self.assertNotEqual(product['gpg']['gpg-key-id'], first_gpg_key['id'])
def test_positive_update_gpg_key(self): """Update product's gpg keys @id: e7febd14-ac8b-424e-9ddf-bf0f63ebe430 @Assert: Product gpg key is updated """ first_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) second_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) product = make_product({ u'gpg-key-id': first_gpg_key['id'], u'organization-id': self.org['id'], }) # Update the Descriptions Product.update({ u'gpg-key-id': second_gpg_key['id'], u'id': product['id'], }) # Fetch it product = Product.info({ u'id': product['id'], u'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], second_gpg_key['id']) self.assertNotEqual(product['gpg']['gpg-key-id'], first_gpg_key['id'])
def test_positive_update_2(self): """@Test: Update product's gpg keys @Feature: Product @Assert: Product gpg key is updated """ first_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) second_gpg_key = make_gpg_key({u'organization-id': self.org['id']}) product = make_product({ u'gpg-key-id': first_gpg_key['id'], u'organization-id': self.org['id'], }) # Update the Descriptions Product.update({ u'gpg-key-id': second_gpg_key['id'], u'id': product['id'], }) # Fetch it product = Product.info({ u'id': product['id'], u'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], second_gpg_key['id']) self.assertNotEqual(product['gpg']['gpg-key-id'], first_gpg_key['id'])
def test_positive_update_gpg_key(self): """Update the original gpg key @id: 367ff375-4f52-4a8c-b974-8c1c54e3fdd3 @Assert: Repository gpg key is updated """ gpg_key = make_gpg_key({"organization-id": self.org["id"]}) gpg_key_new = make_gpg_key({"organization-id": self.org["id"]}) new_repo = self._make_repository({u"gpg-key-id": gpg_key["id"]}) Repository.update({u"id": new_repo["id"], u"gpg-key-id": gpg_key_new["id"]}) result = Repository.info({"id": new_repo["id"]}) self.assertEqual(result["gpg-key"]["id"], gpg_key_new["id"])
def test_positive_create_with_default_org(self): """Create gpg key with valid name and valid gpg key via file import using the default created organization @id: c64d4959-e53e-44c0-82da-dc4dd4c89733 @assert: gpg key is created """ org = Org.info({'name': DEFAULT_ORG}) for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_redmine_4272(self): """ @Test: gpg info should display key content @Feature: GPG Keys @Assert: gpg info should display key content @BZ: Redmine#4272 """ # GPG Key data data = {'name': generate_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file content = generate_name() gpg_key = self.create_gpg_key_file(content=content) self.assertIsNotNone(gpg_key, 'GPG Key file must be created') data['key'] = gpg_key try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info( {'id': new_obj['id']} ) self.assertEqual(result.return_code, 0, "Failed to get object information") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") self.assertEqual( result.stdout['content'], content)
def test_positive_add_product_with_repos(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has more than one repository :id: b05c5223-44d5-4a48-9d99-18ca351c84a5 :expectedresults: gpg key is associated with product as well as with the repositories :CaseLevel: Integration """ product = make_product({'organization-id': self.org['id']}) repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] gpg_key = make_gpg_key({'organization-id': self.org['id']}) Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
def test_negative_create_with_invalid_name(self): """Create gpg key with invalid name and valid gpg key via file import @id: 93160f88-b653-42a9-b44f-9b2ba56f38d9 @assert: gpg key is not created """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIFactoryError): # factory will provide a valid key make_gpg_key({ 'name': name, 'organization-id': self.org['id'], })
def test_positive_add_repo_from_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has one repository @id: 1427f145-9faf-41ef-ae42-dc91d61ce1f6 @assert: gpg key is associated with the repository but not with the product @CaseLevel: Integration """ product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) Repository.update({ 'gpg-key-id': gpg_key['id'], 'id': repo['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id']) self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
def test_positive_create_with_custom_org(self): """Create gpg key with valid name and valid gpg key via file import using a new organization :id: f1bcf748-0890-4b54-8f30-2df4924c80b3 :expectedresults: gpg key is created :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': self.org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_pos_create_default_org(self): """@test: Create gpg key with valid name and valid gpg key via file import using the default created organization @feature: GPG Keys @assert: gpg key is created @BZ: 1172009 """ result = Org.list() self.assertGreater(len(result), 0, 'No organization found') org = result[0] for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_negative_create_1(self): """@test: Create gpg key with valid name and valid gpg key via file import then try to create new one with same name @feature: GPG Keys @assert: gpg key is not created @BZ: 1172009 """ test_data = {'name': gen_string('alphanumeric')} # Setup data to pass to the factory test_data = test_data.copy() test_data['organization-id'] = self.org['id'] gpg_key = make_gpg_key(test_data) # Can we find the new object? result = GPGKey().exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual(gpg_key[self.search_key], result[self.search_key]) # Setup a new key file test_data['key'] = '/tmp/%s' % gen_alphanumeric() gpg_key = create_gpg_key_file() self.assertIsNotNone(gpg_key, 'GPG Key file must be created') ssh.upload_file(local_file=gpg_key, remote_file=test_data['key']) # Try to create a gpg key with the same name with self.assertRaises(CLIReturnCodeError): GPGKey().create(test_data)
def test_positive_create_6(self, name): """@Test: Check if repository can be created with gpg key name @Feature: Repository @Assert: Repository is created and has gpg key @BZ: 1103944 """ # Make a new gpg key new_gpg_key = make_gpg_key({'organization-id': self.org['id']}) new_repo = self._make_repository({ u'name': name, u'gpg-key': new_gpg_key['name'], }) # Fetch it again result = Repository.info({'id': new_repo['id']}) self.assertEqual(result.return_code, 0, "Repository was not found") self.assertEqual(len(result.stderr), 0, "No error was expected") # Assert that data matches data passed self.assertEqual(result.stdout['gpg-key']['id'], new_gpg_key['id'], "GPG Keys ID don't match") self.assertEqual(result.stdout['gpg-key']['name'], new_gpg_key['name'], "GPG Keys name don't match")
def test_redmine_4272(self): """@Test: gpg info should display key content @Feature: GPG Keys @Assert: gpg info should display key content @BZ: Redmine#4272 """ # GPG Key data data = {'name': gen_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file content = gen_alphanumeric() gpg_key = self.create_gpg_key_file(content=content) self.assertIsNotNone(gpg_key, 'GPG Key file must be created') data['key'] = gpg_key try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to get object information") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") self.assertEqual(result.stdout['content'], content)
def test_positive_add_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has one repository @id: 5529a852-9ef6-48f8-b2bc-2bbf463657dd @assert: gpg key is associated with product as well as with the repository @CaseLevel: Integration """ product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id']) self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
def test_positive_create_2(self, data): """@test: Create gpg key with valid name and valid gpg key via file import using the a new organization @feature: GPG Keys @assert: gpg key is created @BZ: 1172009 """ # Setup data to pass to the factory data = data.copy() data['key'] = VALID_GPG_KEY_FILE_PATH data['organization-id'] = self.org['id'] try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().exists({'organization-id': self.org['id']}, (self.search_key, new_obj[self.search_key])) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") self.assertEqual(new_obj[self.search_key], result.stdout[self.search_key])
def test_redmine_4271(self): """@Test: cvs output for gpg subcommand doesn\'t work @Feature: GPG Keys @Assert: cvs output for gpg info works @BZ: Redmine#4271 """ # GPG Key data data = {'name': gen_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file data['key'] = VALID_GPG_KEY_FILE_PATH try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to get object information") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") self.assertEqual(new_obj[self.search_key], result.stdout[self.search_key])
def test_positive_create_4(self, test_name): """@Test: Check if product can be created with gpg key @Feature: Product @Assert: Product is created and has gpg key """ new_gpg_key = make_gpg_key( {u'organization-id': self.org['id']} ) new_product = make_product( { u'name': test_name['name'], u'organization-id': self.org['id'], u'gpg-key-id': new_gpg_key['id'], } ) # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertEqual( result.return_code, 0, "Product was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertEqual( result.stdout['name'], new_product['name'], "Names don't match") self.assertEqual( result.stdout['gpg']['gpg-key-id'], new_gpg_key['id'], "GPG Keys don't match")
def test_bugzilla_1108227(self): """@Test: Hammer fails to get a gpg info by name @Feature: GPG Keys @Assert: can get gpg key info by name @BZ: 1108227 """ # GPG Key data data = {'name': gen_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file data['key'] = VALID_GPG_KEY_FILE_PATH try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info({ 'name': new_obj['name'], 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") self.assertEqual(new_obj[self.search_key], result.stdout[self.search_key])
def test_positive_update_key(self): """Create gpg key with valid name and valid gpg key via file import then update its gpg key file :id: 58a8ed14-adfc-4046-af63-59a7008ff4d7 :expectedresults: gpg key is updated :CaseImportance: Critical """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) content = gen_alphanumeric(gen_integer(20, 50)) self.assertNotEqual(gpg_key['content'], content) local_key = create_gpg_key_file(content) self.assertIsNotNone(local_key, 'GPG Key file must be created') key = '/tmp/%s' % gen_alphanumeric() ssh.upload_file(local_file=local_key, remote_file=key) GPGKey.update({ 'key': key, 'name': gpg_key['name'], 'organization-id': self.org['id'], }) gpg_key = GPGKey.info({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['content'], content)
def test_positive_delete(self): """Create gpg key with valid name and valid gpg key via file import then delete it :id: 5bf72e5c-767a-4321-8781-a5cea9474421 :expectedresults: gpg key is deleted :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] ) GPGKey.delete({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual(len(result), 0)
def test_positive_create_with_default_org(self): """Create gpg key with valid name and valid gpg key via file import using the default created organization @id: c64d4959-e53e-44c0-82da-dc4dd4c89733 @assert: gpg key is created """ result = Org.list() self.assertGreater(len(result), 0, 'No organization found') org = result[0] for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_redmine_4271(self): """@Test: cvs output for gpg subcommand doesn\'t work @Feature: GPG Keys @Assert: cvs output for gpg info works @BZ: Redmine#4271 """ # GPG Key data data = {'name': gen_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file data['key'] = VALID_GPG_KEY_FILE_PATH try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info( {'id': new_obj['id']} ) self.assertEqual(result.return_code, 0, "Failed to get object information") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") self.assertEqual( new_obj[self.search_key], result.stdout[self.search_key])
def test_positive_delete_key_for_empty_product(self): """@test: Create gpg key with valid name and valid gpg key via file import then associate it with empty (no repos) custom product then delete it @feature: GPG Keys @assert: gpg key is associated with product during creation but removed from product after deletion """ # Create a product and a gpg key gpg_key = make_gpg_key({'organization-id': self.org['id']}) product = make_product({ 'gpg-key-id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) # Delete the gpg key GPGKey.delete({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) # Verify gpg key was actually deleted with self.assertRaises(CLIReturnCodeError): GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key was disassociated from the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name'])
def test_positive_add_product_with_repos(self): """@test: Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has more than one repository @feature: GPG Keys @assert: gpg key is associated with product as well as with the repositories """ product = make_product({'organization-id': self.org['id']}) repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] gpg_key = make_gpg_key({'organization-id': self.org['id']}) Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
def test_bugzilla_1108227(self): """@Test: Hammer fails to get a gpg info by name @Feature: GPG Keys @Assert: can get gpg key info by name @BZ: 1108227 """ # GPG Key data data = {'name': gen_string("alpha", 10)} data['organization-id'] = self.org['id'] # Setup a new key file data['key'] = VALID_GPG_KEY_FILE_PATH try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().info({ 'name': new_obj['name'], 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") self.assertEqual( new_obj[self.search_key], result.stdout[self.search_key])
def test_positive_add_repo_from_product_with_repo(self): """@test: Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has one repository @feature: GPG Keys @assert: gpg key is associated with the repository but not with the product """ product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) Repository.update({ 'gpg-key-id': gpg_key['id'], 'id': repo['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id']) self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
def test_positive_delete(self): """@test: Create gpg key with valid name and valid gpg key via file import then delete it @feature: GPG Keys @assert: gpg key is deleted """ for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] ) GPGKey.delete({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual(len(result), 0)
def test_positive_update_key(self): """@test: Create gpg key with valid name and valid gpg key via file import then update its gpg key file @feature: GPG Keys @assert: gpg key is updated """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) content = gen_alphanumeric(gen_integer(20, 50)) self.assertNotEqual(gpg_key['content'], content) local_key = create_gpg_key_file(content) self.assertIsNotNone(local_key, 'GPG Key file must be created') key = '/tmp/%s' % gen_alphanumeric() ssh.upload_file(local_file=local_key, remote_file=key) GPGKey.update({ 'key': key, 'name': gpg_key['name'], 'organization-id': self.org['id'], }) gpg_key = GPGKey.info({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['content'], content)
def test_positive_add_repo_from_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has one repository :id: 1427f145-9faf-41ef-ae42-dc91d61ce1f6 :expectedresults: gpg key is associated with the repository but not with the product :CaseLevel: Integration """ product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) Repository.update({ 'gpg-key-id': gpg_key['id'], 'id': repo['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id']) self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id'])
def test_positive_add_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has one repository :id: 5529a852-9ef6-48f8-b2bc-2bbf463657dd :expectedresults: gpg key is associated with product as well as with the repository :CaseLevel: Integration """ product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(product['gpg']['gpg-key-id'], gpg_key['id']) self.assertEqual(repo['gpg-key']['id'], gpg_key['id'])
def test_positive_create_4(self, test_name): """ @Test: Check if product can be created with gpg key @Feature: Product @Assert: Product is created and has gpg key @BZ: 1096320 """ new_gpg_key = make_gpg_key( {u'organization-id': self.org['id']} ) new_product = make_product( { u'name': test_name['name'], u'organization-id': self.org['id'], u'gpg-key-id': new_gpg_key['id'], } ) # Fetch it result = Product.info( {u'id': new_product['id'], u'organization-id': self.org['id']}) self.assertEqual( result.return_code, 0, "Product was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertEqual( result.stdout['name'], new_product['name'], "Names don't match") self.assertEqual( result.stdout['gpg']['gpg-key-id'], new_gpg_key['id'], "GPG Keys don't match")
def test_positive_delete(self): """Create gpg key with valid name and valid gpg key via file import then delete it :id: 5bf72e5c-767a-4321-8781-a5cea9474421 :expectedresults: gpg key is deleted :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key])) self.assertEqual(gpg_key[self.search_key], result[self.search_key]) GPGKey.delete({ 'name': name, 'organization-id': self.org['id'], }) result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key])) self.assertEqual(len(result), 0)
def test_positive_create_2(self, data): """@test: Create gpg key with valid name and valid gpg key via file import using the a new organization @feature: GPG Keys @assert: gpg key is created @BZ: 1172009 """ # Setup data to pass to the factory data = data.copy() data['key'] = VALID_GPG_KEY_FILE_PATH data['organization-id'] = self.org['id'] try: new_obj = make_gpg_key(data) except CLIFactoryError as err: self.fail(err) # Can we find the new object? result = GPGKey().exists( {'organization-id': self.org['id']}, (self.search_key, new_obj[self.search_key]) ) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") self.assertEqual( new_obj[self.search_key], result.stdout[self.search_key])
def test_positive_create_6(self, name): """@Test: Check if repository can be created with gpg key name @Feature: Repository @Assert: Repository is created and has gpg key @BZ: 1103944 """ new_gpg_key = make_gpg_key({'organization-id': self.org['id']}) new_repo = self._make_repository({ u'name': name, u'gpg-key': new_gpg_key['name'], }) # Assert that data matches data passed self.assertEqual( new_repo['gpg-key']['id'], new_gpg_key['id'], "GPG Keys ID don't match" ) self.assertEqual( new_repo['gpg-key']['name'], new_gpg_key['name'], "GPG Keys name don't match" )
def test_positive_add_repo_from_product_with_repos(self): """@test: Create gpg key via file import and associate with custom repo GPGKey should contain valid name and valid key and should be associated to one repository from custom product. Make sure custom product should have more than one repository. @feature: GPG Keys @assert: gpg key is associated with the repository """ product = make_product({'organization-id': self.org['id']}) repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] gpg_key = make_gpg_key({'organization-id': self.org['id']}) Repository.update({ 'gpg-key': gpg_key['name'], 'id': repos[0]['id'], 'organization-id': self.org['id'], }) product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg'].get('gpg-key-id'), gpg_key['id']) # First repo should have a valid gpg key assigned repo = Repository.info({'id': repos.pop(0)['id']}) self.assertEqual(repo['gpg-key']['id'], gpg_key['id']) # The rest of repos should not for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertNotEqual(repo['gpg-key'].get('id'), gpg_key['id'])
def test_negative_create_with_invalid_name(self): """@test: Create gpg key with invalid name and valid gpg key via file import @feature: GPG Keys @assert: gpg key is not created """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIFactoryError): # factory will provide a valid key make_gpg_key({ 'name': name, 'organization-id': self.org['id'], })
def test_positive_create_with_custom_org(self): """@test: Create gpg key with valid name and valid gpg key via file import using a new organization @feature: GPG Keys @assert: gpg key is created @BZ: 1172009 """ for name in valid_data_list(): with self.subTest(name): gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': self.org['id'], }) # Can we find the new object? result = GPGKey.exists( {'organization-id': self.org['id']}, (self.search_key, gpg_key[self.search_key]) ) self.assertEqual( gpg_key[self.search_key], result[self.search_key] )
def test_positive_create_5(self, name): """@Test: Check if repository can be created with gpg key ID @Feature: Repository @Assert: Repository is created and has gpg key """ # Make a new gpg key new_gpg_key = make_gpg_key({'organization-id': self.org['id']}) new_repo = self._make_repository({ u'name': name, u'gpg-key-id': new_gpg_key['id'], }) # Fetch it again result = Repository.info({'id': new_repo['id']}) self.assertEqual( result.return_code, 0, "Repository was not found") self.assertEqual( len(result.stderr), 0, "No error was expected") # Assert that data matches data passed self.assertEqual( result.stdout['gpg-key']['id'], new_gpg_key['id'], "GPG Keys ID don't match" ) self.assertEqual( result.stdout['gpg-key']['name'], new_gpg_key['name'], "GPG Keys name don't match" )
def test_positive_update_key_for_product_with_repos(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has more than one repository then update the key :id: a95eb51b-4b6b-4c04-bb4d-cbe600431850 :expectedresults: gpg key is associated with product before/after update as well as with the repositories :CaseLevel: Integration """ # Create a product and a gpg key product = make_product({'organization-id': self.org['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Create repositories and assign them to the product repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] # Associate gpg key with a product Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name']) # Update the gpg key new_name = gen_choice(valid_data_list()) GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], }) # Verify changes are reflected in the gpg key gpg_key = GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['name'], new_name) # Verify changes are reflected in the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], new_name) # Verify changes are reflected in the repositories for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), new_name)
def test_positive_update_gpg_key(self): """Update the original gpg key @id: 367ff375-4f52-4a8c-b974-8c1c54e3fdd3 @Assert: Repository gpg key is updated """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) gpg_key_new = make_gpg_key({'organization-id': self.org['id']}) new_repo = self._make_repository({ u'gpg-key-id': gpg_key['id'], }) Repository.update({ u'id': new_repo['id'], u'gpg-key-id': gpg_key_new['id'], }) result = Repository.info({'id': new_repo['id']}) self.assertEqual(result['gpg-key']['id'], gpg_key_new['id'])
def test_positive_delete_key_for_product_with_repos(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has more than one repository then delete it :id: f92d4643-1892-4f95-ae6b-fcea8e726946 :expectedresults: gpg key is associated with product and its repositories during creation but removed from the product and the repositories after deletion :CaseLevel: Integration """ # Create product, repositories and gpg key product = make_product({'organization-id': self.org['id']}) repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Associate gpg key with a product Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated with product and its repositories product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name']) # Delete the gpg key GPGKey.delete({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) # Verify gpg key was actually deleted with self.assertRaises(CLIReturnCodeError): GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key was disassociated from the product and its # repositories product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
def test_positive_update_key_for_repo_from_product_with_repos(self): """Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has more than one repository then update the key :id: 773a9141-9f04-40ba-b3df-4b6d80db25a6 :expectedresults: gpg key is associated with a single repository before/after update and not associated with product or other repositories :CaseLevel: Integration """ # Create a product and a gpg key product = make_product({'organization-id': self.org['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Create repositories and assign them to the product repos = [ make_repository({'product-id': product['id']}) for _ in range(gen_integer(2, 5)) ] # Associate gpg key with a single repository Repository.update({ 'gpg-key': gpg_key['name'], 'id': repos[0]['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated repos[0] = Repository.info({'id': repos[0]['id']}) self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name']) # Update the gpg key new_name = gen_choice(valid_data_list()) GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], }) # Verify changes are reflected in the gpg key gpg_key = GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['name'], new_name) # Verify changes are reflected in the associated repository repos[0] = Repository.info({'id': repos[0]['id']}) self.assertEqual(repos[0]['gpg-key'].get('name'), new_name) # Verify changes are not reflected in the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], new_name) # Verify changes are not reflected in the rest of repositories for repo in repos[1:]: repo = Repository.info({'id': repo['id']}) self.assertNotEqual(repo['gpg-key'].get('name'), new_name)
def test_positive_update_key_for_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has one repository then update the key :id: 3fb550a7-507e-4988-beb6-35bdfc2e99a8 :expectedresults: gpg key is associated with product before/after update as well as with the repository :CaseLevel: Integration """ # Create a product and a gpg key product = make_product({'organization-id': self.org['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Create a repository and assign it to the product repo = make_repository({'product-id': product['id']}) # Associate gpg key with a product Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name']) # Update the gpg key new_name = gen_choice(valid_data_list()) GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], }) # Verify changes are reflected in the gpg key gpg_key = GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['name'], new_name) # Verify changes are reflected in the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], new_name) # Verify changes are reflected in the repository repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('id'), gpg_key['id'])
def test_positive_list(self): """Create gpg key and list it @id: 5da535b3-1728-4edf-bd33-3822c4427ef3 @assert: gpg key is displayed/listed """ gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'organization-id': self.org['id'], }) gpg_keys_list = GPGKey.list({'organization-id': self.org['id']}) self.assertIn(gpg_key['id'], [gpg['id'] for gpg in gpg_keys_list])
def test_positive_delete_key_for_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it with custom product that has one repository then delete it :id: a5d4ea02-f015-4026-b4dc-7365eaf00049 :expectedresults: gpg key is associated with product but and its repository during creation but removed from product and repository after deletion :CaseLevel: Integration """ # Create product, repository and gpg key product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Associate gpg key with a product Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated both with product and its repository product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name']) # Delete the gpg key GPGKey.delete({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) # Verify gpg key was actually deleted with self.assertRaises(CLIReturnCodeError): GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key was disassociated from the product and its repository product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name']) self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
def test_positive_delete_key_for_repo_from_product_with_repos(self): """Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has more than one repository then delete the key :id: e7ed4ed9-ecfe-4954-b806-cdd0668e8822 :expectedresults: gpg key is associated with a single repository but not the product during creation and removed from repository after deletion :CaseLevel: Integration """ # Create product, repositories and gpg key product = make_product({'organization-id': self.org['id']}) repos = [] for _ in range(gen_integer(2, 5)): repos.append(make_repository({'product-id': product['id']})) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Associate gpg key with a repository Repository.update({ 'gpg-key': gpg_key['name'], 'id': repos[0]['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated with the repository repos[0] = Repository.info({'id': repos[0]['id']}) self.assertEqual(repos[0]['gpg-key']['name'], gpg_key['name']) # Delete the gpg key GPGKey.delete({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) # Verify gpg key was actually deleted with self.assertRaises(CLIReturnCodeError): GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key is not associated with any repository or the product # itself product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name']) for repo in repos: repo = Repository.info({'id': repo['id']}) self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
def test_negative_create_1(self, data): """ @test: Create gpg key with valid name and valid gpg key via file import then try to create new one with same name @feature: GPG Keys @assert: gpg key is not created """ # Setup data to pass to the factory data = data.copy() data['organization-id'] = self.org['id'] try: new_obj = make_gpg_key(data) except Exception, e: self.fail(e)
def test_positive_list(self): """Create gpg key and list it :id: 5da535b3-1728-4edf-bd33-3822c4427ef3 :expectedresults: gpg key is displayed/listed :CaseImportance: Critical """ gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'organization-id': self.org['id'] }) gpg_keys_list = GPGKey.list({'organization-id': self.org['id']}) self.assertIn(gpg_key['id'], [gpg['id'] for gpg in gpg_keys_list])
def test_positive_create_2(self, data): """ @test: Create gpg key with valid name and valid gpg key via file import using the a new organization @feature: GPG Keys @assert: gpg key is created """ # Setup data to pass to the factory data = data.copy() data['key'] = VALID_GPG_KEY_FILE_PATH data['organization-id'] = self.org['id'] try: new_obj = make_gpg_key(data) except Exception, e: self.fail(e)
def test_positive_add_empty_product(self): """Create gpg key with valid name and valid gpg key via file import then associate it with empty (no repos) custom product :id: b7477c2f-586c-4593-96c0-1fbc532ce8bf :expectedresults: gpg key is associated with product :CaseLevel: Integration """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) product = make_product({ 'gpg-key-id': gpg_key['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name'])
def test_positive_delete_key_for_repo_from_product_with_repo(self): """Create gpg key with valid name and valid gpg key via file import then associate it to repository from custom product that has one repository then delete the key :id: 3658e04d-fc63-499f-a22d-b512941cc96b :expectedresults: gpg key is associated with the single repository but not the product during creation and was removed from repository after deletion :CaseLevel: Integration """ # Create product, repository and gpg key product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Associate gpg key with a repository Repository.update({ 'gpg-key': gpg_key['name'], 'id': repo['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated with the repository but not with the # product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) repo = Repository.info({'id': repo['id']}) self.assertNotEqual(product['gpg']['gpg-key'], gpg_key['name']) self.assertEqual(repo['gpg-key'].get('name'), gpg_key['name']) # Delete the gpg key GPGKey.delete({ 'name': gpg_key['name'], 'organization-id': self.org['id'], }) # Verify gpg key was actually deleted with self.assertRaises(CLIReturnCodeError): GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) # Verify gpg key was disassociated from the repository repo = Repository.info({'id': repo['id']}) self.assertNotEqual(repo['gpg-key'].get('name'), gpg_key['name'])
def test_positive_update_key_for_empty_product(self): """Create gpg key with valid name and valid gpg key via file import then associate it with empty (no repos) custom product then update the key :id: c0c84c45-21fc-4940-9d52-00babb807ec7 :expectedresults: gpg key is associated with product before/after update :CaseLevel: Integration """ # Create a product and a gpg key product = make_product({'organization-id': self.org['id']}) gpg_key = make_gpg_key({'organization-id': self.org['id']}) # Associate gpg key with a product Product.update({ 'gpg-key': gpg_key['name'], 'id': product['id'], 'organization-id': self.org['id'], }) # Verify gpg key was associated product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], gpg_key['name']) # Update the gpg key new_name = gen_choice(valid_data_list()) GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], }) # Verify changes are reflected in the gpg key gpg_key = GPGKey.info({ 'id': gpg_key['id'], 'organization-id': self.org['id'], }) self.assertEqual(gpg_key['name'], new_name) # Verify changes are reflected in the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertEqual(product['gpg']['gpg-key'], new_name)