示例#1
0
    def test_delete_problems(self):
        description = {"analyzer": "problems2testsuite_analyzer",
                       "type": "problems2testsuite_type",
                       "reason": "Application has been killed",
                       "backtrace": "die()",
                       "executable": "/usr/bin/true",
                       "duphash": None,
                       "uuid": None}

        description["duphash"] = description["uuid"] = "DEADBEEF"
        task_one_path = self.p2.NewProblem(description, 0x1)
        one = wait_for_task_new_problem(self, self.bus, task_one_path)

        description["duphash"] = description["uuid"] = "81680083"
        task_two_path = self.p2.NewProblem(description, 0x1)
        two = wait_for_task_new_problem(self, self.bus, task_two_path)

        description["duphash"] = description["uuid"] = "FFFFFFFF"
        task_three_path = self.p2.NewProblem(description, 0x1)
        three = wait_for_task_new_problem(self, self.bus, task_three_path)

        p = self.p2.GetProblems(0, dict())

        self.assertIn(one, p)
        self.assertIn(two, p)
        self.assertIn(three, p)

        self.p2.DeleteProblems([one])

        p = self.p2.GetProblems(0, dict())

        self.assertNotIn(one, p)
        self.assertIn(two, p)
        self.assertIn(three, p)

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems,
                                   [two, three, one])

        p = self.p2.GetProblems(0, dict())

        self.assertNotIn(one, p)
        self.assertNotIn(two, p)
        self.assertNotIn(three, p)

        self.p2.DeleteProblems([])

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems,
                                   ["/invalid/path"])

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems,
                                   ["/org/freedesktop/Problems2/Entry/FAKE"])
示例#2
0
    def test_delete_problems(self):
        description = {
            "analyzer": "problems2testsuite_analyzer",
            "type": "problems2testsuite_type",
            "reason": "Application has been killed",
            "backtrace": "die()",
            "executable": "/usr/bin/true",
            "duphash": None,
            "uuid": None
        }

        description["duphash"] = description["uuid"] = "DEADBEEF"
        task_one_path = self.p2.NewProblem(description, 0x1)
        one = wait_for_task_new_problem(self, self.bus, task_one_path)

        description["duphash"] = description["uuid"] = "81680083"
        task_two_path = self.p2.NewProblem(description, 0x1)
        two = wait_for_task_new_problem(self, self.bus, task_two_path)

        description["duphash"] = description["uuid"] = "FFFFFFFF"
        task_three_path = self.p2.NewProblem(description, 0x1)
        three = wait_for_task_new_problem(self, self.bus, task_three_path)

        p = self.p2.GetProblems(0, dict())

        self.assertIn(one, p)
        self.assertIn(two, p)
        self.assertIn(three, p)

        self.p2.DeleteProblems([one])

        p = self.p2.GetProblems(0, dict())

        self.assertNotIn(one, p)
        self.assertIn(two, p)
        self.assertIn(three, p)

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems, [two, three, one])

        p = self.p2.GetProblems(0, dict())

        self.assertNotIn(one, p)
        self.assertNotIn(two, p)
        self.assertNotIn(three, p)

        self.p2.DeleteProblems([])

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems, ["/invalid/path"])

        self.assertRaisesDBusError(DBUS_ERROR_BAD_ADDRESS,
                                   self.p2.DeleteProblems,
                                   ["/org/freedesktop/Problems2/Entry/FAKE"])
示例#3
0
    def test_duplicates(self):
        description = {
            "analyzer": "problems2testsuite_analyzer",
            "reason": "Application has been killed",
            "backtrace": "die()",
            "duphash": "NEW_PROBLEM_DUPLICATES",
            "uuid": "NEW_PROBLEM_DUPLICATES",
            "executable": "/usr/bin/true",
            "type": "abrt-problems2-dupes"
        }

        task_path = self.p2.NewProblem(description, 0x1)
        self.p2_entry_path = wait_for_task_new_problem(self, self.bus,
                                                       task_path)

        task_duplicate_path = self.p2.NewProblem(description, 0x1)

        self.p2_entry_duplicate_path = wait_for_task_new_problem(
            self, self.bus, task_duplicate_path)

        self.assertEqual(self.p2_entry_path, self.p2_entry_duplicate_path)
        self.p2_entry_duplicate_path = None
示例#4
0
    def test_duplicates(self):
        description = {"analyzer": "problems2testsuite_analyzer",
                       "reason": "Application has been killed",
                       "backtrace": "die()",
                       "duphash": "NEW_PROBLEM_DUPLICATES",
                       "uuid": "NEW_PROBLEM_DUPLICATES",
                       "executable": "/usr/bin/true",
                       "type": "abrt-problems2-dupes"}

        task_path = self.p2.NewProblem(description, 0x1)
        self.p2_entry_path = wait_for_task_new_problem(self,
                                                       self.bus,
                                                       task_path)

        task_duplicate_path = self.p2.NewProblem(description, 0x1)

        self.p2_entry_duplicate_path = wait_for_task_new_problem(
                                                         self,
                                                         self.bus,
                                                         task_duplicate_path)

        self.assertEqual(self.p2_entry_path, self.p2_entry_duplicate_path)
        self.p2_entry_duplicate_path = None
示例#5
0
    def test_new_problem_sane_default_elements(self):
        description = {}

        task_path = self.p2.NewProblem(description, 0x1)
        self.p2_entry_path = wait_for_task_new_problem(self, self.bus,
                                                       task_path)
        self.assertTrue(self.p2_entry_path,
                        "Failed to create problem without elements")

        p2e = Problems2Entry(self.bus, self.p2_entry_path)
        self.assertEqual("libreport", p2e.getproperty("Type"), "Created type")
        self.assertTrue(p2e.getproperty("UUID"), "Created UUID")

        resp = p2e.ReadElements(["analyzer"], 0)
        if self.assertIn("analyzer", resp, "Created analyzer element"):
            self.assertEqual("libreport", resp["analyzer"])
示例#6
0
    def test_new_problem_sanitized_uid(self):
        description = {"analyzer": "problems2testsuite_analyzer",
                       "type": "sanitized-uid",
                       "uid": "0",
                       "reason": "Application has been killed",
                       "duphash": "SANITIZED_UID",
                       "backtrace": "die()",
                       "executable": "/usr/bin/foo"}

        task_path = self.p2.NewProblem(description, 0x1)
        self.p2_entry_path = wait_for_task_new_problem(self,
                                                       self.bus,
                                                       task_path)

        self.assertTrue(self.p2_entry_path,
                        "Failed to create problem with uid 0")

        p2e = Problems2Entry(self.bus, self.p2_entry_path)
        self.assertEqual(os.geteuid(), p2e.getproperty("UID"), "Sanitized UID")
示例#7
0
    def test_not_allowed_elements(self):
        description = {"analyzer": "problems2testsuite_analyzer",
                       "type": "Kerneloops",
                       "reason": "Application has been killed",
                       "duphash": "NOT_ALLOWED_ELEMENTS",
                       "uuid": "NOT_ALLOWED_ELEMENTS",
                       "backtrace": "Machine Check Exception: fake"}

        task_path = self.p2.NewProblem(description, 0x1)

        self.assertRaisesProblems2Exception(
                "Failed to create new "
                "problem directory: You are not allowed to create element "
                "'type' containing 'Kerneloops'",
                wait_for_task_new_problem, self, self.bus, task_path)

        task_root_path = self.root_p2.NewProblem(description, 0x1)

        self.p2_entry_root_path = wait_for_task_new_problem(self,
                                                            self.root_bus,
                                                            task_root_path)

        self.assertTrue(self.p2_entry_root_path,
                        "root is not allowed to create type=CCpp")
示例#8
0
    def test_pipes(self):
        rp, wp = os.pipe()
        try:
            description = {"analyzer": "problems2testsuite_analyzer",
                           "reason": "Application has been killed",
                           "backtrace": "die()",
                           "duphash": "NON_BLOCKING_OPERATIONS",
                           "uuid": "NON_BLOCKING_OPERATIONS",
                           "pipe": dbus.types.UnixFd(rp),
                           "executable": "/usr/bin/foo",
                           "type": "abrt-problems2-sanity"}

            task_path = self.p2.NewProblem(description, 0x1)
            self.assertRaisesProblems2Exception(
                    "Failed to create new "
                    "problem directory: Failed to save data of passed file "
                    "descriptor",
                    wait_for_task_new_problem, self, self.bus, task_path)

            os.write(wp, b"Epic success!")
            os.close(wp)
            wp = -1

            task_path = self.p2.NewProblem(description, 0x1)
            self.p2_entry_path = wait_for_task_new_problem(self, self.bus,
                                                           task_path)
            entry = Problems2Entry(self.bus, self.p2_entry_path)

            data = entry.ReadElements(["pipe"], 0x0)

            self.assertIn("pipe", data)
            self.assertEqual(data["pipe"], "Epic success!")
        finally:
            os.close(rp)
            if wp != -1:
                os.close(wp)