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_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_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_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_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_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_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_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 @assert: 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_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_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 @assert: 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_key_associate_13(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 more than one repository then update the key @feature: GPG Keys @assert: gpg key is associated with a single repository before/after update and not associated with product or other repositories """ # 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 @assert: 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_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_negative_create_with_no_gpg_key(self): """@test: Create gpg key with valid name and no gpg key @feature: GPG Keys @assert: gpg key is not created """ for name in valid_data_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): GPGKey.create({ 'name': name, 'organization-id': self.org['id'], })
def test_negative_create_with_no_gpg_key(self): """Create gpg key with valid name and no gpg key @id: 9440a1a0-eb0d-445e-88d3-3139c2b1d17a @assert: gpg key is not created """ for name in valid_data_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): GPGKey.create({ 'name': name, 'organization-id': self.org['id'], })
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_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_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_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 """ name = gen_string('utf8') result = GPGKey.create({ 'name': name, 'organization-id': self.org['id'], 'key': VALID_GPG_KEY_FILE_PATH, }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) 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) self.assertEqual(len(result.stderr), 0) self.assertEqual(result.stdout['name'], name)
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_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_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_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_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_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_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_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_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_negative_create_with_no_gpg_key(self): """Create gpg key with valid name and no gpg key :id: 9440a1a0-eb0d-445e-88d3-3139c2b1d17a :expectedresults: gpg key is not created :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): with self.assertRaises(CLIReturnCodeError): GPGKey.create({ '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_key_associate_16(self): """@test: 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 @feature: GPG Keys @assert: gpg key is associated with product but and its repository during creation but removed from product and repository after deletion """ # 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_negative_update_name(self): """@test: Create gpg key with valid name and valid gpg key via file import then fail to update its name @feature: GPG Keys @assert: gpg key is not updated """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], })
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)
def test_negative_update_name(self): """Create gpg key with valid name and valid gpg key via file import then fail to update its name @id: 938d2925-c82c-43b6-8dfc-29c42eca7424 @assert: gpg key is not updated """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], })
def test_key_associate_20(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 more than one repository then delete the key @feature: GPG Keys @assert: gpg key is associated with a single repository but not the product during creation and removed from repository after deletion """ # 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_positive_update_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 update the key :id: 549e2e1e-fd10-4487-a3a5-fdee9b8cfc48 :expectedresults: gpg key is associated with the repository before/after update, but not with the product :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 repository, assign product and gpg-key repo = make_repository({ 'gpg-key-id': gpg_key['id'], 'product-id': product['id'], }) # Verify gpg key was associated 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 repositories repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), new_name) # Verify gpg key wasn't added to the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], new_name)
def test_positive_update_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 update the key @id: 549e2e1e-fd10-4487-a3a5-fdee9b8cfc48 @assert: gpg key is associated with the repository before/after update, but not with the product @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 repository, assign product and gpg-key repo = make_repository({ 'gpg-key-id': gpg_key['id'], 'product-id': product['id'], }) # Verify gpg key was associated 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 repositories repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), new_name) # Verify gpg key wasn't added to the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], new_name)
def test_negative_update_name(self): """Create gpg key with valid name and valid gpg key via file import then fail to update its name :id: 938d2925-c82c-43b6-8dfc-29c42eca7424 :expectedresults: gpg key is not updated :CaseImportance: Critical """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], })
def test_positive_update_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 update the key @feature: GPG Keys @assert: gpg key is associated with product before/after update """ # 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)
def test_key_associate_12(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 then update the key @feature: GPG Keys @assert: gpg key is associated with the repository before/after update, but not with the product """ # 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 repository, assign product and gpg-key repo = make_repository({ 'gpg-key-id': gpg_key['id'], 'product-id': product['id'], }) # Verify gpg key was associated 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 repositories repo = Repository.info({'id': repo['id']}) self.assertEqual(repo['gpg-key'].get('name'), new_name) # Verify gpg key wasn't added to the product product = Product.info({ 'id': product['id'], 'organization-id': self.org['id'], }) self.assertNotEqual(product['gpg']['gpg-key'], new_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 @BZ: 1172009 """ # Setup data to pass to the factory data = data.copy() 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]) # Setup a new key file data['key'] = '/tmp/%s' % gen_alphanumeric() gpg_key = self.create_gpg_key_file() self.assertIsNotNone(gpg_key, 'GPG Key file must be created') ssh.upload_file(local_file=gpg_key, remote_file=data['key']) # Try to create a gpg key with the same name new_obj = GPGKey().create(data) self.assertNotEqual(new_obj.return_code, 0, "Object should not be created") self.assertGreater(len(new_obj.stderr), 0, "Should have raised an exception")
def test_positive_update_name(self): """Create gpg key with valid name and valid gpg key via file import then update its name @id: e18d7cd8-2757-4134-9ed9-7eb68f2872e2 @assert: gpg key is updated """ gpg_key = make_gpg_key({'organization-id': self.org['id']}) for new_name in valid_data_list(): with self.subTest(new_name): GPGKey.update({ 'name': gpg_key['name'], 'new-name': new_name, 'organization-id': self.org['id'], }) gpg_key = GPGKey.info({ 'name': new_name, 'organization-id': self.org['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_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 delete it :id: da76cada-5ccf-47e1-8c12-24f30c41c8b6 :expectedresults: gpg key is associated with product during creation but removed from product after deletion :CaseLevel: Integration """ # 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_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_negative_create_2(self, data): """ @test: Create gpg key with valid name and no gpg key @feature: GPG Keys @assert: gpg key is not created """ # Setup data to pass to create data = data.copy() data['organization-id'] = self.org['id'] # Try to create a new object passing @data to factory method new_obj = GPGKey().create(data) self.assertNotEqual(new_obj.return_code, 0, "Object should not be created") self.assertGreater(len(new_obj.stderr), 0, "Should have raised an exception")
def test_positive_get_info_by_name(self): """Create single gpg key and get its info by name @id: be418cf8-8a90-46db-9e8c-8ff349c98401 @Assert: specific information for GPG key matches the creation name """ name = gen_string('utf8') gpg_key = make_gpg_key({ u'key': VALID_GPG_KEY_FILE_PATH, u'name': name, u'organization-id': self.org['id'], }) gpg_key = GPGKey.info({ u'name': gpg_key['name'], u'organization-id': self.org['id'], }) self.assertEqual(gpg_key['name'], name)
def test_positive_search(self): """Create gpg key and search/find it :id: 9ef15add-b067-4134-b930-aaeda18bddfa :expectedresults: gpg key can be found :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']}, search=('name', gpg_key['name'])) self.assertEqual(gpg_key['name'], result['name'])
def test_positive_get_info_by_name(self): """Create single gpg key and get its info by name :id: be418cf8-8a90-46db-9e8c-8ff349c98401 :expectedresults: specific information for GPG key matches the creation name :CaseImportance: Critical """ name = gen_string('utf8') gpg_key = make_gpg_key({ 'key': VALID_GPG_KEY_FILE_PATH, 'name': name, 'organization-id': self.org['id'] }) gpg_key = GPGKey.info({ 'name': gpg_key['name'], 'organization-id': self.org['id'] }) self.assertEqual(gpg_key['name'], name)
def test_negative_create_3(self, data): """ @test: Create gpg key with invalid name and valid gpg key via file import @feature: GPG Keys @assert: gpg key is not created """ # Setup data to pass to create data = data.copy() data['key'] = '/tmp/%s' % generate_name() data['organization-id'] = self.org['id'] ssh.upload_file(local_file=VALID_GPG_KEY_FILE_PATH, remote_file=data['key']) # Try to create a new object passing @data to factory method new_obj = GPGKey().create(data) self.assertNotEqual(new_obj.return_code, 0, "Object should not be created") self.assertGreater(len(new_obj.stderr), 0, "Should have raised an exception")