コード例 #1
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_users_default(self, test_data):
        """@test: Import all 3 users from the default data set (predefined
        source).

        @feature: Import Users

        @assert: 3 Users created

        """
        tmp_dir = self.default_dataset[0]
        files = dict(self.default_dataset[1])
        pwdfile = os.path.join(tmp_dir, gen_string('alpha', 6))

        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        Import.organization({'csv-file': files['users']})
        ssh_import = Import.user({
            'csv-file': files['users'],
            'new-passwords': pwdfile
        })
        self.assertEqual(ssh_import.return_code, 0)
        # list the users and check whether users from csv are in the listing
        logins = set(user['login'] for user in User.list().stdout)
        imp_users = set(
            user['username']
            for user in csv_to_dataset([files['users']])
        )
        self.assertTrue(imp_users.issubset(logins))
コード例 #2
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_merge_orgs(self, test_data):
        """@test: Try to Import all organizations and their users from CSV
        to a mapped organizaition.

        @feature: Import User Mapped Org

        @assert: 3 Organizations Mapped and their Users created
        in a single Organization

        """
        # create a new Organization and prepare CSV files
        new_org = make_org()
        tmp_dir = self.default_dataset[0]
        files = dict(self.default_dataset[1])
        pwdfile = os.path.join(tmp_dir, gen_string('alpha', 6))
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        self.assertEqual(
            Import.organization({
                'csv-file': files['users'],
                'into-org-id': new_org['id'],
                'verbose': True,
            }).return_code,
            0
        )
        Import.user({'csv-file': files['users'], 'new-passwords': pwdfile})

        # list users by org-id and check whether users from csv are in listing
        users = User.list({u'organization-id': new_org['id']})
        logins = set(user['login'] for user in users.stdout)
        imp_users = set(
            user['username']
            for user in csv_to_dataset([files['users']])
        )
        self.assertTrue(all((user in logins for user in imp_users)))
コード例 #3
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_reimport_users_default_negative(self, test_data):
        """@test: Try to Import all users from the
        predefined source and try to import them again

        @feature: Repetitive User Import

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

        """
        tmp_dir = self.default_dataset[0]
        files = dict(self.default_dataset[1])
        pwdfile = os.path.join(tmp_dir, gen_string('alpha', 6))
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        # Import the organizations first
        self.assertEqual(
            Import.organization({
                'csv-file': files['users'],
            }).return_code, 0)
        self.assertEqual(
            Import.user({
                'csv-file': files['users'],
                'new-passwords': pwdfile,
            }).return_code, 0)
        ssh.command(u'rm -rf {}'.format(pwdfile))
        users_before = set(user['login'] for user in User.list().stdout)
        self.assertEqual(
            Import.user({
                'csv-file': files['users'],
                'new-passwords': pwdfile,
            }).return_code, 0)
        users_after = set(user['login'] for user in User.list().stdout)
        self.assertTrue(users_after.issubset(users_before))
コード例 #4
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_users_merge(self, test_data):
        """@test: Try to Merge users with the same name using 'merge-users'
        option.

        @feature: Import Users Map-users

        @assert: Users imported in 2nd import are being mapped to the existing
        ones with the same name

        """
        # prepare the data
        tmp_dir = self.default_dataset[0]
        files = dict(self.default_dataset[1])
        pwdfiles = [
            os.path.join(tmp_dir, gen_string('alpha', 6)) for _ in range(2)
        ]
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        # initial import
        for result in (
            Import.organization({'csv-file': files['users']}),
            Import.user({
                'csv-file': files['users'], 'new-passwords': pwdfiles[0],
            }),
        ):
            self.assertEqual(result.return_code, 0)
        # clear the .transition_data to clear the transition mapping
        ssh.command('rm -rf "${HOME}"/.transition_data/users*')
        # import users using merge-users option
        import_merge = Import.user_with_tr_data({
            'csv-file': files['users'],
            'new-passwords': pwdfiles[1],
            'merge-users': True,
        })
        for record in import_merge[1]:
            self.assertNotEqual(User.info({'id': record['sat6']}).stdout, '')
コード例 #5
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_users_recovery(self, test_data):
        """@test: Try to Import users with the same name to invoke
        usage of a recovery strategy (rename, map, none)

        @feature: Import Users Recover

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

        """
        # prepare the data
        tmp_dir = self.default_dataset[0]
        files = dict(self.default_dataset[1])
        pwdfiles = [
            os.path.join(tmp_dir, gen_string('alpha', 6)) for _ in range(4)
        ]
        files['users'] = update_csv_values(
            files['users'],
            u'organization_id',
            test_data,
            self.default_dataset[0]
        )
        # initial import
        for result in (
            Import.organization({'csv-file': files['users']}),
            Import.user({
                'csv-file': files['users'],
                'new-passwords': pwdfiles[0],
            }),
        ):
            self.assertEqual(result.return_code, 0)
        # clear the .transition_data to clear the transition mapping
        ssh.command('rm -rf "${HOME}"/.transition_data/users*')

        # use the default (rename) strategy
        import_rename = Import.user_with_tr_data({
            'csv-file': files['users'],
            'new-passwords': pwdfiles[1],
        })
        for record in import_rename[1]:
            self.assertEqual(User.info({'id': record['sat6']}).return_code, 0)
        Import.user({'csv-file': files['users'], 'delete': True})

        # use the 'none' strategy
        users_before = set(user['login'] for user in User.list().stdout)
        Import.user({
            'csv-file': files['users'],
            'new-passwords': pwdfiles[2],
            'recover': 'none',
        })
        users_after = set(user['login'] for user in User.list().stdout)
        self.assertEqual(users_before, users_after)

        # use the 'map' strategy
        import_map = Import.user_with_tr_data({
            'csv-file': files['users'],
            'recover': 'map',
            'new-passwords': pwdfiles[3],
        })
        for record in import_map[1]:
            self.assertEqual(
                User.info({'id': record['sat6']}).return_code, 0
            )

        # do the cleanup
        ssh.command(u'rm -rf {}'.format(' '.join(pwdfiles)))