Exemplo n.º 1
0
    def test_update_password(self):
        test_user = self.http_req.user

        # make sure user who is shooting the request has proper permission to
        # update an user's attributes, whatever itself or others.
        user_should_have_perm(test_user, 'auth.change_user')

        user_new_attrs = self.user_new_attrs.copy()
        new_password = '******'
        user_new_attrs['password'] = new_password

        self.assertRaisesXmlrpcFault(FORBIDDEN, XUser.update,
                                     self.http_req, user_new_attrs, test_user.pk)

        user_new_attrs['old_password'] = '******'
        self.assertRaisesXmlrpcFault(FORBIDDEN, XUser.update,
                                     self.http_req, user_new_attrs, test_user.pk)

        user_new_attrs['old_password'] = test_user.username
        data = XUser.update(self.http_req, user_new_attrs, test_user.pk)
        self.assert_('password' not in data)
        self.assertEqual(data['first_name'], user_new_attrs['first_name'])
        self.assertEqual(data['last_name'], user_new_attrs['last_name'])
        self.assertEqual(data['email'], user_new_attrs['email'])

        user = User.objects.get(pk=test_user.pk)
        self.assert_(user.check_password(new_password))
Exemplo n.º 2
0
    def setUpTestData(cls):
        super(TestOperateComponentView, cls).setUpTestData()

        cls.comp_application = ComponentFactory(name='Application',
                                                product=cls.product,
                                                initial_owner=cls.tester,
                                                initial_qa_contact=cls.tester)
        cls.comp_database = ComponentFactory(name='Database',
                                             product=cls.product,
                                             initial_owner=cls.tester,
                                             initial_qa_contact=cls.tester)
        cls.comp_cli = ComponentFactory(name='CLI',
                                        product=cls.product,
                                        initial_owner=cls.tester,
                                        initial_qa_contact=cls.tester)
        cls.comp_api = ComponentFactory(name='API',
                                        product=cls.product,
                                        initial_owner=cls.tester,
                                        initial_qa_contact=cls.tester)

        TestCaseComponentFactory(case=cls.case_1, component=cls.comp_cli)
        TestCaseComponentFactory(case=cls.case_1, component=cls.comp_api)

        user_should_have_perm(cls.tester, 'testcases.add_testcasecomponent')

        cls.cases_component_url = reverse('tcms.testcases.views.component')
Exemplo n.º 3
0
    def setUpTestData(cls):
        super(TestOperateComponentView, cls).setUpTestData()

        cls.comp_application = ComponentFactory(name='Application',
                                                product=cls.product,
                                                initial_owner=cls.tester,
                                                initial_qa_contact=cls.tester)
        cls.comp_database = ComponentFactory(name='Database',
                                             product=cls.product,
                                             initial_owner=cls.tester,
                                             initial_qa_contact=cls.tester)
        cls.comp_cli = ComponentFactory(name='CLI',
                                        product=cls.product,
                                        initial_owner=cls.tester,
                                        initial_qa_contact=cls.tester)
        cls.comp_api = ComponentFactory(name='API',
                                        product=cls.product,
                                        initial_owner=cls.tester,
                                        initial_qa_contact=cls.tester)

        TestCaseComponentFactory(case=cls.case_1, component=cls.comp_cli)
        TestCaseComponentFactory(case=cls.case_1, component=cls.comp_api)

        cls.tester = User.objects.create(username='******', email='*****@*****.**')
        cls.tester.set_password('password')
        cls.tester.save()

        user_should_have_perm(cls.tester, 'testcases.add_testcasecomponent')

        cls.cases_component_url = reverse('tcms.testcases.views.component')
Exemplo n.º 4
0
    def setUpTestData(cls):
        super(TestUploadFile, cls).setUpTestData()

        cls.password = '******'
        cls.user = create_request_user(username='******', password=cls.password)
        user_should_have_perm(cls.user, 'management.add_testattachment')
        user_should_have_perm(cls.user, 'testcases.add_testcaseattachment')
Exemplo n.º 5
0
    def test_update_other_with_proper_permission(self):
        user_should_have_perm(self.http_req.user, 'auth.change_user')

        data = XUser.update(self.http_req, self.user_new_attrs, self.user.pk)
        updated_user = User.objects.get(pk=self.user.pk)
        self.assertEqual(data['first_name'], updated_user.first_name)
        self.assertEqual(data['last_name'], updated_user.last_name)
        self.assertEqual(data['email'], updated_user.email)
Exemplo n.º 6
0
    def setUpTestData(cls):
        super(TestOperateCategoryView, cls).setUpTestData()

        cls.case_cat_full_auto = TestCaseCategoryFactory(name='Full Auto', product=cls.product)
        cls.case_cat_full_manual = TestCaseCategoryFactory(name='Full Manual', product=cls.product)

        user_should_have_perm(cls.tester, 'testcases.add_testcasecomponent')

        cls.case_category_url = reverse('tcms.testcases.views.category')
Exemplo n.º 7
0
    def setUpTestData(cls):
        super(TestImportCasesToPlan, cls).setUpTestData()

        cls.plan_tester = User.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******')

        user_should_have_perm(cls.plan_tester, 'testcases.add_testcaseplan')
Exemplo n.º 8
0
    def test_404_if_group_pk_not_exist(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_modify_url,
                                   {'action': 'modify',
                                    'id': 999999999,
                                    'status': 1})
        self.assertEqual(http_client.NOT_FOUND, response.status_code)
Exemplo n.º 9
0
    def test_add_a_plan(self):
        user_should_have_perm(self.plan_tester, 'testcases.add_testcaseplan')
        self.client.login(username=self.plan_tester.username, password='******')
        response = self.client.get(self.case_plans_url,
                                   {'a': 'add', 'plan_id': self.plan_test_add.pk})

        self.assert_list_case_plans(response, self.case_1)

        self.assertTrue(TestCasePlan.objects.filter(
            plan=self.plan_test_add, case=self.case_1).exists())
Exemplo n.º 10
0
    def setUpTestData(cls):
        super(TestEditRun, cls).setUpTestData()

        user_should_have_perm(cls.tester, 'testruns.change_testrun')
        cls.edit_url = reverse('testruns-edit', args=[cls.test_run.pk])

        cls.new_build = BuildFactory(name='FastTest',
                                     product=cls.test_run.plan.product)
        cls.intern = UserFactory(username='******',
                                 email='*****@*****.**')
Exemplo n.º 11
0
    def setUpTestData(cls):
        super(TestAddIssueToCase, cls).setUpTestData()

        cls.plan_tester = User.objects.create_user(username='******',
                                                   email='*****@*****.**',
                                                   password='******')
        user_should_have_perm(cls.plan_tester, 'testcases.change_testcasebug')

        cls.case_bug_url = reverse('tcms.testcases.views.bug', args=[cls.case_1.pk])
        cls.issue_tracker = TestCaseBugSystem.objects.get(name='Bugzilla')
Exemplo n.º 12
0
def make_http_request(user=None, user_perm=None, data=None):
    '''Factory method to make instance of FakeHTTPRequest'''
    _user = user
    if _user is None:
        _user = create_http_user()

    if user_perm is not None:
        user_should_have_perm(_user, user_perm)

    return FakeHTTPRequest(_user, data)
Exemplo n.º 13
0
    def test_404_if_group_pk_not_exist(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_modify_url, {
            'action': 'modify',
            'id': 999999999,
            'status': 1
        })
        self.assertEqual(http.client.NOT_FOUND, response.status_code)
Exemplo n.º 14
0
    def test_disable_a_group(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.get(self.group_modify_url, {
            'action': 'modify',
            'id': self.group_nitrate.pk,
            'status': 0
        })

        group = EnvGroup.objects.get(pk=self.group_nitrate.pk)
        self.assertFalse(group.is_active)
Exemplo n.º 15
0
    def verify_get_with_permission(self):
        user_should_have_perm(self.tester, "testruns.view_testrun")

        response = self.client.get(self.url, {
            "p": self.plan.pk,
            "c": self.case_1.pk
        })

        self.assertContains(response, self.plan.name)
        self.assertContains(response, self.case_1.summary)
Exemplo n.º 16
0
    def setUpTestData(cls):
        super(TestAddIssueToCase, cls).setUpTestData()

        cls.plan_tester = User.objects.create_user(username='******',
                                                   email='*****@*****.**',
                                                   password='******')
        user_should_have_perm(cls.plan_tester, 'testcases.change_bug')

        cls.case_bug_url = reverse('testcases-bug', args=[cls.case_1.pk])
        cls.issue_tracker = BugSystem.objects.get(name='Bugzilla')
Exemplo n.º 17
0
    def setUpTestData(cls):
        super(TestUploadFile, cls).setUpTestData()

        cls.upload_file_url = reverse('tcms.core.files.upload_file')

        cls.password = '******'
        cls.user = create_request_user(username='******',
                                       password=cls.password)
        user_should_have_perm(cls.user, 'management.add_testattachment')
        user_should_have_perm(cls.user, 'testcases.add_testcaseattachment')
Exemplo n.º 18
0
    def verify_post_with_permission(self):
        user_should_have_perm(self.tester, "testruns.view_testrun")

        response = self.client.post(self.url, self.post_data)
        self.test_run.refresh_from_db()

        self.assertEqual(self.test_run.summary, "New run summary")
        self.assertEqual(self.test_run.build, self.new_build)
        self.assertEqual(self.test_run.notes, "New run notes")
        self.assertRedirects(response, reverse("testruns-get", args=[self.test_run.pk]))
Exemplo n.º 19
0
    def test_change_status_to_running(self):
        user_should_have_perm(self.tester, 'testruns.change_testrun')
        response = self.client.get(self.url, {'finished': 0})

        self.assertRedirects(
            response,
            reverse('testruns-get', args=[self.test_run.pk]))

        self.test_run.refresh_from_db()
        self.assertIsNone(self.test_run.stop_date)
Exemplo n.º 20
0
    def test_refuse_to_add_if_missing_user(self):
        user_should_have_perm(self.tester, 'testruns.change_testrun')
        response = self.client.get(self.cc_url, {'do': 'add'})

        response_text = html.unescape(
            str(response.content, encoding=settings.DEFAULT_CHARSET))
        self.assertIn(str(_('The user you typed does not exist in database')),
                      response_text)

        self.assert_cc(response, [self.cc_user_2, self.cc_user_3])
Exemplo n.º 21
0
    def test_add_a_plan(self):
        user_should_have_perm(self.plan_tester, 'testcases.add_testcaseplan')
        self.client.login(username=self.plan_tester.username, password='******')
        response = self.client.get(self.case_plans_url,
                                   {'a': 'add', 'plan_id': self.plan_test_add.pk})

        self.assert_list_case_plans(response, self.case_1)

        self.assertTrue(TestCasePlan.objects.filter(
            plan=self.plan_test_add, case=self.case_1).exists())
Exemplo n.º 22
0
    def test_update_another_user_password(self):
        user_should_have_perm(self.api_user, 'auth.change_user')

        user_new_attrs = self.user_new_attrs.copy()
        user_new_attrs['password'] = '******'

        with self.assertRaisesRegex(
                XmlRPCFault,
                'Password updates for other users are not allowed via RPC!'):
            self.rpc_client.User.update(self.another_user.pk, user_new_attrs)
Exemplo n.º 23
0
    def setUpTestData(cls):
        super().setUpTestData()

        cls.proposed_case = TestCaseFactory(
            author=cls.tester,
            default_tester=None,
            reviewer=cls.tester,
            case_status=cls.case_status_proposed,
            plan=[cls.plan],
        )

        # test data for https://github.com/kiwitcms/Kiwi/issues/334

        Priority.objects.filter(value="P4").update(is_active=False)

        user_should_have_perm(cls.tester, "testcases.change_testcase")
        user_should_have_perm(cls.tester, "testcases.view_testcase")
        cls.case_edit_url = reverse("testcases-edit", args=[cls.case_1.pk])

        # Copy, then modify or add new data for specific tests below
        cls.edit_data = {
            "author": cls.case_1.author.pk,
            "from_plan": cls.plan.pk,
            "summary": cls.case_1.summary,
            "product": cls.case_1.category.product.pk,
            "category": cls.case_1.category.pk,
            "default_tester": "",
            # specify in seconds
            "testing_duration": "0",
            "setup_duration": "3600",
            "case_status": cls.case_status_confirmed.pk,
            "arguments": "",
            "extra_link": "",
            "notes": "",
            "is_automated": "0",
            "requirement": "",
            "script": "",
            "priority": cls.case_1.priority.pk,
            "tag": "RHEL",
            "text": "Given-When-Then",
            "email_settings-0-auto_to_case_author": "on",
            "email_settings-0-auto_to_run_manager": "on",
            "email_settings-0-auto_to_execution_assignee": "on",
            "email_settings-0-auto_to_case_tester": "on",
            "email_settings-0-auto_to_run_tester": "on",
            "email_settings-0-notify_on_case_update": "on",
            "email_settings-0-notify_on_case_delete": "on",
            "email_settings-0-cc_list": "",
            "email_settings-0-case": cls.case_1.pk,
            "email_settings-0-id": cls.case_1.emailing.pk,
            "email_settings-TOTAL_FORMS": "1",
            "email_settings-INITIAL_FORMS": "1",
            "email_settings-MIN_NUM_FORMS": "0",
            "email_settings-MAX_NUM_FORMS": "1",
        }
Exemplo n.º 24
0
    def test_disable_a_group(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        self.client.get(self.group_modify_url,
                        {'action': 'modify',
                         'id': self.group_nitrate.pk,
                         'status': 0})

        group = TCMSEnvGroup.objects.get(pk=self.group_nitrate.pk)
        self.assertFalse(group.is_active)
Exemplo n.º 25
0
    def test_refuse_if_user_not_exist(self):
        user_should_have_perm(self.tester, 'testruns.change_testrun')
        response = self.client.get(self.cc_url, {
            'do': 'add',
            'user': '******'
        })

        self.assertContains(response,
                            'The user you typed does not exist in database')

        self.assert_cc(response, [self.cc_user_2, self.cc_user_3])
Exemplo n.º 26
0
    def test_delete_group_by_non_manager(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        response = self.client.get(self.group_delete_url,
                                   {'action': 'del', 'id': self.group_fedora.pk})

        self.assertEqual({'rc': 0, 'response': 'ok'}, json_loads(response.content))

        self.assertFalse(
            TCMSEnvGroup.objects.filter(pk=self.group_fedora.pk).exists())
Exemplo n.º 27
0
    def test_get_status_options_with_permission(self):
        user_should_have_perm(self.tester, "testruns.change_testexecution")
        response = self.client.get(self.url)
        self.assertEqual(HTTPStatus.OK, response.status_code)

        for execution_status in TestExecutionStatus.objects.all():
            self.assertContains(
                response,
                f'<span class="{execution_status.icon}"></span>{execution_status.name}',
                html=True,
            )
Exemplo n.º 28
0
    def test_remove_a_plan(self):
        user_should_have_perm(self.plan_tester, 'testcases.change_testcaseplan')
        self.client.login(username=self.plan_tester.username, password='******')
        response = self.client.get(self.case_plans_url,
                                   {'a': 'remove', 'plan_id': self.plan_test_remove.pk})

        self.assert_list_case_plans(response, self.case_1)

        not_linked_to_plan = not TestCasePlan.objects.filter(
            case=self.case_1, plan=self.plan_test_remove).exists()
        self.assertTrue(not_linked_to_plan)
Exemplo n.º 29
0
    def test_update_another_user_password(self):
        user_should_have_perm(self.api_user, "auth.change_user")

        user_new_attrs = self.user_new_attrs.copy()
        user_new_attrs["password"  # nosec:B105:hardcoded_password_string
                       ] = "new password"

        with self.assertRaisesRegex(
                XmlRPCFault,
                "Password updates for other users are not allowed via RPC!"):
            self.rpc_client.User.update(self.another_user.pk, user_new_attrs)
Exemplo n.º 30
0
    def setUpTestData(cls):
        super(TestOperateCategoryView, cls).setUpTestData()

        cls.case_cat_full_auto = CategoryFactory(name='Full Auto',
                                                 product=cls.product)
        cls.case_cat_full_manual = CategoryFactory(name='Full Manual',
                                                   product=cls.product)

        user_should_have_perm(cls.tester, 'testcases.add_testcasecomponent')

        cls.case_category_url = reverse('testcases-category')
Exemplo n.º 31
0
    def setUpTestData(cls):
        cls.bug = BugFactory()

        cls.url = reverse("bugs-comment")
        cls.post_data = {
            "bug": cls.bug.pk,
            "text": "A comment text",
        }

        super().setUpTestData()
        tests.user_should_have_perm(cls.tester, "bugs.view_bug")
Exemplo n.º 32
0
    def setUpTestData(cls):
        super(TestAddCasesToRun, cls).setUpTestData()

        cls.proposed_case = TestCaseFactory(
            author=cls.tester,
            default_tester=None,
            reviewer=cls.tester,
            case_status=cls.case_status_proposed,
            plan=[cls.plan])

        user_should_have_perm(cls.tester, 'testruns.add_testexecution')
Exemplo n.º 33
0
    def test_remove_a_plan(self):
        user_should_have_perm(self.plan_tester, 'testcases.change_testcaseplan')
        self.client.login(username=self.plan_tester.username, password='******')
        response = self.client.get(self.case_plans_url,
                                   {'a': 'remove', 'plan_id': self.plan_test_remove.pk})

        self.assert_list_case_plans(response, self.case_1)

        not_linked_to_plan = not TestCasePlan.objects.filter(
            case=self.case_1, plan=self.plan_test_remove).exists()
        self.assertTrue(not_linked_to_plan)
Exemplo n.º 34
0
    def setUpTestData(cls):
        cls.bug = BugFactory()

        cls.url = reverse('bugs-comment')
        cls.post_data = {
            'bug': cls.bug.pk,
            'text': 'A comment text',
        }

        super().setUpTestData()
        tests.user_should_have_perm(cls.tester, 'bugs.view_bug')
Exemplo n.º 35
0
    def setUpTestData(cls):
        super(TestCloneView, cls).setUpTestData()

        cls.another_plan = TestPlanFactory(name='Another plan for test',
                                           author=cls.tester,
                                           owner=cls.tester,
                                           product=cls.product,
                                           product_version=cls.version)
        cls.another_case_1 = TestCaseFactory(author=cls.tester,
                                             default_tester=None,
                                             reviewer=cls.tester,
                                             plan=[cls.another_plan])
        cls.another_case_2 = TestCaseFactory(author=cls.tester,
                                             default_tester=None,
                                             reviewer=cls.tester,
                                             plan=[cls.another_plan])

        cls.third_plan = TestPlanFactory(name='Third plan for test',
                                         author=cls.tester,
                                         owner=cls.tester,
                                         product=cls.product,
                                         product_version=cls.version)
        cls.third_case_1 = TestCaseFactory(author=cls.tester,
                                           default_tester=None,
                                           reviewer=cls.tester,
                                           plan=[cls.third_plan])
        cls.third_case_2 = TestCaseFactory(author=cls.tester,
                                           default_tester=None,
                                           reviewer=cls.tester,
                                           plan=[cls.third_plan])

        cls.totally_new_plan = TestPlanFactory(
            name='Test clone plan with copying cases',
            author=cls.tester,
            owner=cls.tester,
            product=cls.product,
            product_version=cls.version)
        cls.case_maintain_original_author = TestCaseFactory(
            author=cls.tester,
            default_tester=None,
            reviewer=cls.tester,
            plan=[cls.totally_new_plan])
        cls.case_keep_default_tester = TestCaseFactory(
            author=cls.tester,
            default_tester=None,
            reviewer=cls.tester,
            plan=[cls.totally_new_plan])

        cls.plan_tester = User.objects.create_user(  # nosec:B106:hardcoded_password_funcarg
            username='******',
            email='*****@*****.**',
            password='******')
        user_should_have_perm(cls.plan_tester, 'testplans.add_testplan')
        cls.plan_clone_url = reverse('plans-clone')
Exemplo n.º 36
0
    def setUpTestData(cls):
        cls.test_run = factories.TestRunFactory()

        cls.url = reverse('testruns-get', args=[cls.test_run.pk])
        super().setUpTestData()

        cls.add_comment_html = \
            '<a href="#" class="addBlue9 js-show-commentdialog">{0}</a>' \
            .format(_('Add'))

        user_should_have_perm(cls.tester, 'testruns.view_testrun')
Exemplo n.º 37
0
    def setUpTestData(cls):
        super().setUpTestData()
        cls.url = reverse('testruns-get', args=[cls.test_run.pk])
        user_should_have_perm(cls.tester, 'testruns.view_testrun')
        cls.status_menu_html = []

        for execution_status in TestExecutionStatus.objects.all():
            cls.status_menu_html.append(
                '<i class="{0}" style="color: {1}"></i>{2}'.format(
                    execution_status.icon, execution_status.color,
                    execution_status.name))
Exemplo n.º 38
0
    def test_visit_group_page_with_permission(self):
        user_should_have_perm(self.tester, 'management.change_envgroup')
        group_edit_url = reverse('mgmt-environment_group_edit')

        response = self.client.get(self.group_url)

        for group in (self.group_1, self.group_2):
            self.assertContains(response,
                                '<a href="{}?id={}">{}</a>'.format(
                                    group_edit_url, group.pk, group.name),
                                html=True)
Exemplo n.º 39
0
    def test_refuse_invalid_status_value(self):
        user_should_have_perm(self.tester, self.permission)

        # Status value is not valid as long as it's not 0 or 1.
        for invalid_status in ('true', 'false', 'yes', 'no', '2'):
            response = self.client.get(self.group_modify_url,
                                       {'action': 'modify',
                                        'id': self.group_nitrate.pk,
                                        'status': invalid_status})
            self.assertJSONEqual(
                str(response.content, encoding=settings.DEFAULT_CHARSET),
                {'rc': 1, 'response': 'Argument illegal.'})
Exemplo n.º 40
0
    def setUpTestData(cls):
        super(TestAddGroup, cls).setUpTestData()

        cls.group_add_url = reverse('management-env-groups')

        cls.tester = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        cls.new_group_name = 'nitrate-dev'

        cls.permission = 'management.add_tcmsenvgroup'
        user_should_have_perm(cls.tester, cls.permission)
Exemplo n.º 41
0
    def test_refuse_invalid_status_value(self):
        user_should_have_perm(self.tester, self.permission)
        self.client.login(username=self.tester.username, password='******')

        # Status value is not valid as long as it's not 0 or 1.
        for invalid_status in ('true', 'false', 'yes', 'no', '2'):
            response = self.client.get(self.group_modify_url,
                                       {'action': 'modify',
                                        'id': self.group_nitrate.pk,
                                        'status': invalid_status})
            self.assertEqual({'rc': 1, 'response': 'Argument illegel.'},
                             json_loads(response.content))
Exemplo n.º 42
0
    def setUpTestData(cls):
        cls.url = reverse('linkref-add')
        cls.test_execution = TestExecutionFactory()

        cls.tester = UserFactory()
        cls.tester.set_password('password')
        cls.tester.save()
        user_should_have_perm(cls.tester, 'testruns.change_testexecution')

        cls.tester_without_perms = UserFactory()
        cls.tester_without_perms.set_password('password')
        cls.tester_without_perms.save()
Exemplo n.º 43
0
    def setUpTestData(cls):
        cls.plan_tester = UserFactory(username="******")
        cls.plan_tester.set_password("password")
        cls.plan_tester.save()
        user_should_have_perm(cls.plan_tester, "testplans.view_testplan")

        cls.plan_1 = TestPlanFactory()
        cls.testcase_1 = TestCaseFactory()
        cls.testcase_2 = TestCaseFactory()

        cls.plan_1.add_case(cls.testcase_1)
        cls.plan_1.add_case(cls.testcase_2)
Exemplo n.º 44
0
    def setUpTestData(cls):
        super(TestAddGroup, cls).setUpTestData()

        cls.group_add_url = reverse('tcms.management.views.environment_groups')

        cls.tester = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        cls.new_group_name = 'nitrate-dev'

        cls.permission = 'management.add_tcmsenvgroup'
        user_should_have_perm(cls.tester, cls.permission)
Exemplo n.º 45
0
    def setUpTestData(cls):
        super(TestOperateCategoryView, cls).setUpTestData()

        cls.case_cat_full_auto = TestCaseCategoryFactory(name='Full Auto', product=cls.product)
        cls.case_cat_full_manual = TestCaseCategoryFactory(name='Full Manual', product=cls.product)

        cls.tester = User.objects.create(username='******', email='*****@*****.**')
        cls.tester.set_password('password')
        cls.tester.save()

        user_should_have_perm(cls.tester, 'testcases.add_testcasecomponent')

        cls.case_category_url = reverse('tcms.testcases.views.category')
Exemplo n.º 46
0
    def setUpTestData(cls):
        super(TestVisitEnvironmentGroupPage, cls).setUpTestData()

        cls.tester = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        user_should_have_perm(cls.tester, 'management.change_tcmsenvgroup')

        cls.group_edit_url = reverse('management-env-group-edit')
        cls.group_nitrate = TCMSEnvGroupFactory(name='nitrate', manager=cls.tester)
        cls.disabled_group = TCMSEnvGroupFactory(name='disabled-group',
                                                 is_active=False,
                                                 manager=cls.tester)
Exemplo n.º 47
0
    def setUpTestData(cls):
        super(TestChangeCasesAutomated, cls).setUpTestData()

        cls.change_data = {
            'case': [cls.case_1.pk, cls.case_2.pk],
            'a': 'change',
            # Add necessary automated value here:
            # o_is_automated
            # o_is_manual
            # o_is_automated_proposed
        }

        user_should_have_perm(cls.tester, 'testcases.change_testcase')
        cls.change_url = reverse('tcms.testcases.views.automated')
Exemplo n.º 48
0
    def test_visit_group_page_with_permission(self):
        self.client.login(username=self.new_tester.username, password='******')

        user_should_have_perm(self.new_tester, 'management.change_tcmsenvgroup')
        group_edit_url = reverse('management-env-group-edit')

        response = self.client.get(self.group_url)

        for group in (self.group_1, self.group_2):
            self.assertContains(
                response,
                '<a href="{}?id={}">{}</a>'.format(group_edit_url,
                                                   group.pk,
                                                   group.name),
                html=True)
Exemplo n.º 49
0
    def setUpTestData(cls):
        super(TestEditEnvironmentGroup, cls).setUpTestData()

        cls.tester = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        user_should_have_perm(cls.tester, 'management.change_tcmsenvgroup')

        cls.group_nitrate = TCMSEnvGroupFactory(name='nitrate', manager=cls.tester)
        cls.duplicate_group = TCMSEnvGroupFactory(name='fedora', manager=cls.tester)

        cls.property_1 = TCMSEnvPropertyFactory()
        cls.property_2 = TCMSEnvPropertyFactory()
        cls.property_3 = TCMSEnvPropertyFactory()

        cls.group_edit_url = reverse('management-env-group-edit')
Exemplo n.º 50
0
    def test_remove_components(self):
        user_should_have_perm(self.tester, 'testcases.delete_testcasecomponent')

        post_data = {
            'o_component': [self.comp_cli.pk, self.comp_api.pk],
            'case': [self.case_1.pk],
            'a': 'remove',
        }
        response = self.client.post(self.cases_component_url, post_data)

        data = json.loads(response.content)
        self.assertEqual({'rc': 0, 'response': 'ok', 'errors_list': []}, data)

        for comp in (self.comp_cli, self.comp_api):
            has_comp = TestCaseComponent.objects.filter(case=self.case_1, component=comp).exists()
            self.assertFalse(has_comp)
Exemplo n.º 51
0
    def test_add_a_few_plans(self):
        user_should_have_perm(self.plan_tester, 'testcases.add_testcaseplan')
        self.client.login(username=self.plan_tester.username, password='******')
        # This time, add a few plans to another case
        url = reverse('tcms.testcases.views.plan', args=[self.case_2.pk])

        response = self.client.get(url,
                                   {'a': 'add', 'plan_id': [self.plan_test_add.pk,
                                                            self.plan_test_remove.pk]})

        self.assert_list_case_plans(response, self.case_2)

        self.assertTrue(TestCasePlan.objects.filter(
            case=self.case_2, plan=self.plan_test_add).exists())
        self.assertTrue(TestCasePlan.objects.filter(
            case=self.case_2, plan=self.plan_test_remove).exists())
Exemplo n.º 52
0
    def test_link_cases(self):
        user_should_have_perm(self.plan_tester, 'testcases.add_testcaseplan')

        post_data = {'a': 'link_cases', 'action': 'add_to_plan',
                     'case': [self.another_case_1.pk, self.another_case_2.pk]}
        response = self.client.post(self.cases_url, post_data)

        self.assertRedirects(
            response,
            reverse('tcms.testplans.views.get', args=[self.plan.pk]),
            target_status_code=http_client.MOVED_PERMANENTLY)

        self.assertTrue(
            TestCasePlan.objects.filter(plan=self.plan, case=self.another_case_1).exists())
        self.assertTrue(
            TestCasePlan.objects.filter(plan=self.plan, case=self.another_case_2).exists())
Exemplo n.º 53
0
    def setUpTestData(cls):
        super(TestCloneView, cls).setUpTestData()

        cls.another_plan = TestPlanFactory(
            name='Another plan for test',
            author=cls.tester, owner=cls.tester,
            product=cls.product, product_version=cls.version)
        cls.another_case_1 = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.another_plan])
        cls.another_case_2 = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.another_plan])

        cls.third_plan = TestPlanFactory(
            name='Third plan for test',
            author=cls.tester, owner=cls.tester,
            product=cls.product, product_version=cls.version)
        cls.third_case_1 = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.third_plan])
        cls.third_case_2 = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.third_plan])

        cls.totally_new_plan = TestPlanFactory(
            name='Test clone plan with copying cases',
            author=cls.tester, owner=cls.tester,
            product=cls.product, product_version=cls.version)
        cls.case_maintain_original_author = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.totally_new_plan])
        cls.case_keep_default_tester = TestCaseFactory(
            author=cls.tester, default_tester=None,
            reviewer=cls.tester, plan=[cls.totally_new_plan])

        cls.plan_tester = User.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******')
        user_should_have_perm(cls.plan_tester, 'testplans.add_testplan')
        cls.plan_clone_url = reverse('plans-clone')
Exemplo n.º 54
0
    def test_link_cases(self):
        self.client.login(username=self.plan_tester.username, password='******')

        user_should_have_perm(self.plan_tester, 'testcases.add_testcaseplan')

        post_data = {
            'case': [self.another_case_1.pk, self.another_case_2.pk]
        }
        response = self.client.post(self.link_cases_url, post_data)

        self.assertRedirects(
            response,
            reverse('plan-get', args=[self.plan.pk]),
            target_status_code=http_client.MOVED_PERMANENTLY)

        self.assertTrue(
            TestCasePlan.objects.filter(
                plan=self.plan, case=self.another_case_1).exists())
        self.assertTrue(
            TestCasePlan.objects.filter(
                plan=self.plan, case=self.another_case_2).exists())
Exemplo n.º 55
0
    def setUpTestData(cls):
        super(TestEditCase, cls).setUpTestData()

        cls.proposed_case = TestCaseFactory(
            author=cls.tester,
            default_tester=None,
            reviewer=cls.tester,
            case_status=cls.case_status_proposed,
            plan=[cls.plan])

        user_should_have_perm(cls.tester, 'testcases.change_testcase')
        cls.case_edit_url = reverse('tcms.testcases.views.edit',
                                    args=[cls.case_1.pk])

        # Copy, then modify or add new data for specific tests below
        cls.edit_data = {
            'from_plan': cls.plan.pk,
            'summary': cls.case_1.summary,
            'product': cls.case_1.category.product.pk,
            'category': cls.case_1.category.pk,
            'default_tester': '',
            'estimated_time': '0m',
            'case_status': cls.case_status_confirmed.pk,
            'arguments': '',
            'extra_link': '',
            'notes': '',
            'is_automated': '0',
            'requirement': '',
            'script': '',
            'alias': '',
            'priority': cls.case_1.priority.pk,
            'tag': 'RHEL',
            'setup': '',
            'action': '',
            'breakdown': '',
            'effect': '',
            'cc_list': '',
        }
Exemplo n.º 56
0
    def test_add_and_remove_a_bug(self):
        user_should_have_perm(self.plan_tester, 'testcases.add_testcasebug')
        user_should_have_perm(self.plan_tester, 'testcases.delete_testcasebug')

        self.client.login(username=self.plan_tester.username, password='******')
        request_data = {
            'handle': 'add',
            'case': self.case_1.pk,
            'bug_id': '123456',
            'bug_system': self.issue_tracker.pk,
        }
        self.client.get(self.case_bug_url, request_data)
        self.assertTrue(self.case_1.case_bug.filter(bug_id='123456').exists())

        request_data = {
            'handle': 'remove',
            'case': self.case_1.pk,
            'bug_id': '123456',
        }
        self.client.get(self.case_bug_url, request_data)

        not_have_bug = self.case_1.case_bug.filter(bug_id='123456').exists()
        self.assertTrue(not_have_bug)
Exemplo n.º 57
0
 def setUp(self):
     user_should_have_perm(self.tester, self.permission)
Exemplo n.º 58
0
    def setUpTestData(cls):
        super(TestCloneCase, cls).setUpTestData()

        user_should_have_perm(cls.tester, 'testcases.add_testcase')
        cls.clone_url = reverse('tcms.testcases.views.clone')