コード例 #1
0
    def test_positive_list(self):
        """@Test: Check if Org can be listed

        @Feature: Organization

        @Assert: Org is listed
        """
        Org.list()
コード例 #2
0
    def test_positive_CRD(self):
        """Create organization with valid name, label and description

        :id: 35840da7-668e-4f78-990a-738aa688d586

        :expectedresults: organization is created with attributes

        :CaseImportance: Critical

        create read
        """
        # Create
        name = valid_org_names_list()[0]
        label = valid_labels_list()[0]
        desc = valid_data_list()[0]
        org = make_org({
            'name': name,
            'label': label,
            'description': desc,
        })
        self.assertEqual(org['name'], name)
        self.assertEqual(org['label'], label)
        self.assertEqual(org['description'], desc)

        # List
        result = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result), 1)
        self.assertEqual(result[0]['name'], org['name'])

        # Search scoped
        for query in [
                'label = {}'.format(label),
                'description ~ {}'.format(desc[:-5]),
                'name ^ "{}"'.format(org['name']),
        ]:
            result = Org.list({'search': query})
            self.assertTrue(len(result), 1)
            self.assertEqual(result[0]['name'], org['name'])

        # Search by name and label
        result = Org.exists(search=('name', org['name']))
        self.assertEqual(org['name'], result['name'])
        result = Org.exists(search=('label', org['label']))
        self.assertEqual(org['name'], result['name'])

        # Info by name and label
        result = Org.info({'label': org['label']})
        self.assertEqual(org['id'], result['id'])
        result = Org.info({'name': org['name']})
        self.assertEqual(org['id'], result['id'])

        # Delete
        Org.delete({'id': org['id']})
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
コード例 #3
0
def test_positive_CRD():
    """Create organization with valid name, label and description

    :id: 35840da7-668e-4f78-990a-738aa688d586

    :expectedresults: organization is created with attributes

    :CaseImportance: Critical

    create read
    """
    # Create
    name = valid_org_names_list()[0]
    label = valid_labels_list()[0]
    desc = list(valid_data_list().values())[0]
    org = make_org({'name': name, 'label': label, 'description': desc})

    assert org['name'] == name
    assert org['label'] == label
    assert org['description'] == desc

    # List
    result = Org.list({'search': f'name={name}'})
    assert len(result) == 1
    assert result[0]['name'] == name

    # Search scoped
    for query in [
        f'label = {label}',
        f'description ~ {desc[:-5]}',
        f'name ^ "{name}"',
    ]:
        result = Org.list({'search': query})
        assert len(result) == 1
        assert result[0]['name'] == name

    # Search by name and label
    result = Org.exists(search=('name', name))
    assert result['name'] == name
    result = Org.exists(search=('label', label))
    assert result['name'] == name

    # Info by name and label
    result = Org.info({'label': label})
    assert result['id'] == org['id']
    result = Org.info({'name': name})
    assert org['id'] == result['id']

    # Delete
    Org.delete({'id': org['id']})
    with pytest.raises(CLIReturnCodeError):
        result = Org.info({'id': org['id']})
コード例 #4
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_orgs_recovery(self, test_data):
        """@test: Try to Import organizations with the same name to invoke
        usage of a recovery strategy (rename, map, none)

        @feature: Import Organizations Recover

        @assert: 2nd Import will result in No Action Taken, 3rd one will rename
        the new organizations, and the 4th one will map them

        """
        # prepare the data
        files = dict(self.default_dataset[1])
        files['users'] = update_csv_values(
            files['users'],
            'organization_id',
            test_data,
            self.default_dataset[0]
        )
        # initial import
        self.assertEqual(
            Import.organization({'csv-file': files['users']}).return_code, 0)
        # clear the .transition_data to clear the transition mapping
        ssh.command('rm -rf "${HOME}"/.transition_data')

        # use the 'none' strategy
        orgs_before = Org.list().stdout
        Import.organization({'csv-file': files['users'], 'recover': 'none'})
        self.assertEqual(orgs_before, Org.list().stdout)

        # use the default (rename) strategy
        ssh_imp_rename = Import.organization_with_tr_data(
            {'csv-file': files['users']}
        )
        self.assertEqual(len(ssh_imp_rename[1]), len(test_data))
        for record in ssh_imp_rename[1]:
            self.assertEqual(Org.info({'id': record['sat6']}).return_code, 0)
        Import.organization({'csv-file': files['users'], 'delete': True})

        # use the 'map' strategy
        ssh_imp_map = Import.organization_with_tr_data({
            'csv-file': files['users'],
            'recover': 'map',
        })
        for record in ssh_imp_map[1]:
            self.assertEqual(
                Org.info({'id': record['sat6']}).return_code, 0
            )
        Import.organization({'csv-file': files['users'], 'delete': True})
コード例 #5
0
ファイル: test_gpgkey.py プロジェクト: rohitkadam19/robottelo
    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]
                )
コード例 #6
0
ファイル: test_gpgkey.py プロジェクト: tkolhar/robottelo
    def test_positive_create_with_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]
                )
コード例 #7
0
ファイル: test.py プロジェクト: ares/robottelo
 def _get_organization_id(cls):
     """Get organization id"""
     result = OrgCli.list(per_page=False)
     if result.return_code != 0:
         cls.logger.error('Fail to get organization id.')
         raise RuntimeError('Invalid organization id. Stop!')
     return result.stdout[0]['id']
コード例 #8
0
ファイル: test_gpgkey.py プロジェクト: lpramuk/robottelo
    def test_positive_create_1(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

        """
        for test_data in positive_create_data():
            with self.subTest(test_data):
                result = Org.list()
                self.assertGreater(len(result), 0, 'No organization found')
                org = result[0]
                # Setup data to pass to the factory
                test_data = test_data.copy()
                test_data['key'] = VALID_GPG_KEY_FILE_PATH
                test_data['organization-id'] = org['id']
                gpg_key = make_gpg_key(test_data)
                # 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]
                )
コード例 #9
0
ファイル: test_gpgkey.py プロジェクト: cswiii/robottelo
    def test_positive_create_1(self, data):
        """@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.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = 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': 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])
コード例 #10
0
 def _get_organization_id(cls):
     """Get organization id"""
     result = OrgCli.list(per_page=False)
     if result.return_code != 0:
         cls.logger.error('Fail to get organization id.')
         raise RuntimeError('Invalid organization id. Stop!')
     return result.stdout[0]['id']
コード例 #11
0
    def test_positive_create_1(self, data):
        """
        @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
        """

        result = Org.list()
        self.assertGreater(len(result.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = 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': 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])
コード例 #12
0
ファイル: test.py プロジェクト: blrm/robottelo
 def _get_organization_id(cls):
     """Get organization id"""
     try:
         result = OrgCli.list(per_page=False)
     except CLIReturnCodeError:
         cls.logger.error('Fail to get organization id.')
         raise RuntimeError('Invalid organization id. Stop!')
     return result[0]['id']
コード例 #13
0
 def _get_organization_id(cls):
     """Get organization id"""
     try:
         result = OrgCli.list(per_page=False)
     except CLIReturnCodeError:
         cls.logger.error('Fail to get organization id.')
         raise RuntimeError('Invalid organization id. Stop!')
     return result[0]['id']
コード例 #14
0
    def test_positive_list(self):
        """Check if Org can be listed

        @Feature: Organization

        @Assert: Org is listed
        """
        org = make_org()
        result_list = Org.list({
            'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #15
0
    def test_positive_list(self):
        """Check if Org can be listed

        @id: bdd26bb3-e3d2-4a5c-8be7-fb12c1114ccc

        @Assert: Org is listed
        """
        org = make_org()
        result_list = Org.list({
            'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #16
0
    def test_positive_list(self):
        """Check if Org can be listed

        @Feature: Organization

        @Assert: Org is listed
        """
        org = make_org()
        result_list = Org.list({
            'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #17
0
    def test_positive_list(self):
        """Check if Org can be listed

        @id: bdd26bb3-e3d2-4a5c-8be7-fb12c1114ccc

        @Assert: Org is listed
        """
        org = make_org()
        result_list = Org.list({
            'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #18
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_positive_list(self):
        """Check if Org can be listed

        :id: bdd26bb3-e3d2-4a5c-8be7-fb12c1114ccc

        :expectedresults: Org is listed

        :CaseImportance: Critical
        """
        org = make_org()
        result_list = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #19
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_reimport_orgs_default_negative(self, test_data):
        """@test: Try to Import all organizations from the
        predefined source and try to import them again

        @feature: Import Organizations twice

        @assert: 2nd Import will result in No Action Taken

        """
        files = dict(self.default_dataset[1])
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        self.assertEqual(
            Import.organization({'csv-file': files['users']}).return_code, 0)
        orgs_before = Org.list().stdout
        self.assertEqual(
            Import.organization({'csv-file': files['users']}).return_code, 0)
        self.assertEqual(orgs_before, Org.list().stdout)
コード例 #20
0
    def test_positive_list(self):
        """Check if Org can be listed

        :id: bdd26bb3-e3d2-4a5c-8be7-fb12c1114ccc

        :expectedresults: Org is listed

        :CaseImportance: Critical
        """
        org = make_org()
        result_list = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result_list) > 0)
        self.assertEqual(result_list[0]['name'], org['name'])
コード例 #21
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_orgs_manifests(self, test_data):
        """@test: Import all organizations from the default data set
        (predefined source) and upload manifests for each of them

        @feature: Import Organizations including Manifests

        @assert: 3 Organizations are created with 3 manifests uploaded

        """
        files = dict(self.default_dataset[1])
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        csv_records = csv_to_dataset([files['users']])
        # create number of manifests corresponding to the number of orgs
        manifest_list = []
        man_dir = ssh.command(
            u'mktemp -d -p {}'.format(self.default_dataset[0])
        ).stdout[0]
        for org in set([rec['organization'] for rec in csv_records]):
            for char in [' ', '.', '#']:
                org = org.replace(char, '_')
            man_file = manifests.clone()
            ssh.upload_file(man_file, u'{0}/{1}.zip'.format(man_dir, org))
            manifest_list.append(u'{0}/{1}.zip'.format(man_dir, org))
            os.remove(man_file)
        ssh_import = Import.organization({
            'csv-file': files['users'],
            'upload-manifests-from': man_dir,
        })
        # now to check whether the orgs from csv appeared in satellite
        orgs = set(org['name'] for org in Org.list().stdout)
        imp_orgs = set(
            org['organization'] for
            org in csv_to_dataset([files['users']])
        )
        self.assertEqual(ssh_import.return_code, 0)
        self.assertTrue(imp_orgs.issubset(orgs))
        for org in imp_orgs:
            manifest_history = Subscription.manifest_history(
                {'organization': org}
            ).stdout[3]
            self.assertIn('SUCCESS', manifest_history)
コード例 #22
0
    def test_verify_bugzilla_1078866(self):
        """hammer organization <info,list> --help types information
        doubled

        @Feature: Organization

        @Assert: no duplicated lines in usage message
        """
        # org list --help:
        result = Org.list({'help': True})
        # get list of lines and check they all are unique
        lines = [line['message'] for line in result]
        self.assertEqual(len(set(lines)), len(lines))

        # org info --help:info returns more lines (obviously), ignore exception
        result = Org.info({'help': True})

        # get list of lines and check they all are unique
        lines = [line for line in result['options']]
        self.assertEqual(len(set(lines)), len(lines))
コード例 #23
0
    def test_verify_bugzilla_1078866(self):
        """hammer organization <info,list> --help types information
        doubled

        @id: 7938bcc4-7107-40b0-bb88-6288ebec0dcd

        @Assert: no duplicated lines in usage message
        """
        # org list --help:
        result = Org.list({'help': True})
        # get list of lines and check they all are unique
        lines = [line['message'] for line in result]
        self.assertEqual(len(set(lines)), len(lines))

        # org info --help:info returns more lines (obviously), ignore exception
        result = Org.info({'help': True})

        # get list of lines and check they all are unique
        lines = [line for line in result['options']]
        self.assertEqual(len(set(lines)), len(lines))
コード例 #24
0
    def test_positive_create_1(self, data):
        """
        @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
        """

        result = Org.list()
        self.assertGreater(len(result.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = org['label']

        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
コード例 #25
0
    def test_positive_create_1(self, data):
        """
        @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
        """

        result = Org.list()
        self.assertGreater(len(result.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = org['id']

        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
コード例 #26
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_positive_search_scoped(self):
        """Check if scoped search work properly for organization entity

        :id: d66ebe1d-aba1-4042-87e4-7de8ea0f8fc8

        :customerscenario: true

        :expectedresults: Necessary organization is listed

        :BZ: 1259374

        :CaseImportance: High
        """
        label = gen_string('alpha')
        desc = gen_string('alpha', 15)
        org = make_org({'label': label, 'description': desc})
        for query in [
            'label = {}'.format(label),
            'description ~ {}'.format(desc[:-5]),
            'name ^ "{}"'.format(org['name']),
        ]:
            result_list = Org.list({'search': query})
            self.assertTrue(len(result_list), 1)
            self.assertEqual(result_list[0]['name'], org['name'])
コード例 #27
0
    def test_positive_multibyte_latin1_org_names(self):
        """Hammer Multibyte and Latin-1 Org names break list pagination

        :id: 4fa0afe7-6d0a-4c3e-a0fc-4ecb95c50fc9

        :BZ: 1418412

        :expectedresults: Multibyte and latin1 names need to be
            displayed with consistent spacing
        """
        org_names = [
            gen_string('alpha', random.randint(1, 30)),
            gen_string('latin1', random.randint(1, 30)),
            u'大傻瓜-{0}'.format(gen_string('alpha', 5)),
            u'你好你-{0}'.format(gen_string('alpha', 5)),
            u'jalapeño-{0}'.format(gen_string('alpha', 5)),
            u'организация-{0}'.format(gen_string('alpha', 5)),
        ]
        for org in org_names:
            make_org({'name': org})
        org_list_lines = [
            line.strip() for line in Org.list(output_format='table') if line]
        self.assertGreaterEqual(len(org_list_lines), len(org_names))
        org_names_lines = [
            line
            for line in org_list_lines
            if any(name in line for name in org_names)
        ]
        self.assertEqual(len(org_names_lines), len(org_names))
        for org_str in org_names_lines:
            width = sum(
                1 if unicodedata.east_asian_width(char)
                in ["Na", "N", "A", "H"]
                else 2 for char in org_str
            )
            self.assertEqual(len(org_names_lines[0]), width)
コード例 #28
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_verify_bugzilla_1078866(self):
        """hammer organization <info,list> --help types information
        doubled

        :id: 7938bcc4-7107-40b0-bb88-6288ebec0dcd

        :bz: 1078866, 1647323

        :expectedresults: no duplicated lines in usage message

        :CaseImportance: Critical
        """
        # org list --help:
        result = Org.list({'help': True}, output_format=None)
        # get list of lines and check they all are unique
        lines = [line for line in result if line != '']
        self.assertEqual(len(set(lines)), len(lines))

        # org info --help:info returns more lines (obviously), ignore exception
        result = Org.info({'help': True}, output_format=None)

        # get list of lines and check they all are unique
        lines = [line for line in result['options']]
        self.assertEqual(len(set(lines)), len(lines))
コード例 #29
0
    def test_positive_search_scoped(self):
        """Check if scoped search work properly for organization entity

        :id: d66ebe1d-aba1-4042-87e4-7de8ea0f8fc8

        :customerscenario: true

        :expectedresults: Necessary organization is listed

        :BZ: 1259374

        :CaseImportance: High
        """
        label = gen_string('alpha')
        desc = gen_string('alpha', 15)
        org = make_org({'label': label, 'description': desc})
        for query in [
            'label = {}'.format(label),
            'description ~ {}'.format(desc[:-5]),
            'name ^ "{}"'.format(org['name']),
        ]:
            result_list = Org.list({'search': query})
            self.assertTrue(len(result_list), 1)
            self.assertEqual(result_list[0]['name'], org['name'])
コード例 #30
0
def test_verify_bugzilla_1078866():
    """hammer organization <info,list> --help types information
    doubled

    :id: 7938bcc4-7107-40b0-bb88-6288ebec0dcd

    :BZ: 1078866, 1647323

    :expectedresults: no duplicated lines in usage message

    :CaseImportance: Low
    """
    # org list --help:
    result = Org.list({'help': True}, output_format=None)
    # get list of lines and check they all are unique
    lines = [line for line in result if line != '' and '----' not in line]
    assert len(set(lines)) == len(lines)

    # org info --help:info returns more lines (obviously), ignore exception
    result = Org.info({'help': True}, output_format=None)

    # get list of lines and check they all are unique
    lines = [line for line in result['options']]
    assert len(set(lines)) == len(lines)
コード例 #31
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_positive_multibyte_latin1_org_names(self):
        """Hammer Multibyte and Latin-1 Org names break list pagination

        :id: 4fa0afe7-6d0a-4c3e-a0fc-4ecb95c50fc9

        :BZ: 1418412

        :expectedresults: Multibyte and latin1 names need to be
            displayed with consistent spacing
        """
        org_names = [
            gen_string('alpha', random.randint(1, 30)),
            gen_string('latin1', random.randint(1, 30)),
            u'大傻瓜-{0}'.format(gen_string('alpha', 5)),
            u'你好你-{0}'.format(gen_string('alpha', 5)),
            u'jalapeño-{0}'.format(gen_string('alpha', 5)),
            u'организация-{0}'.format(gen_string('alpha', 5)),
        ]
        for org in org_names:
            make_org({'name': org})
        org_list_lines = [
            line.strip() for line in Org.list(output_format='table') if line]
        self.assertGreaterEqual(len(org_list_lines), len(org_names))
        org_names_lines = [
            line
            for line in org_list_lines
            if any(name in line for name in org_names)
        ]
        self.assertEqual(len(org_names_lines), len(org_names))
        for org_str in org_names_lines:
            width = sum(
                1 if unicodedata.east_asian_width(char)
                in ["Na", "N", "A", "H"]
                else 2 for char in org_str
            )
            self.assertEqual(len(org_names_lines[0]), width)