Esempio n. 1
0
    def test_create_plan_and_get_plan(self):
        plan = Plan(self.TEST_PLAN)
        res = plan.create()
        self.assertEqual(res.json()["success"], True)
        self._assert_test_plan(res.json()["plan"])

        # Check if we can retrieve the plan we just created
        # retrieve the newly created plan
        res2 = plan.get(plan.plan["name"])
        self.assertEqual(res2.json()["success"], True)
        self._assert_test_plan(res2.json()["plan"])
Esempio n. 2
0
    def test_delete_plan(self):
        plan = Plan(self.TEST_PLAN)
        res1 = plan.create()
        self.assertEqual(res1.json()["success"], True)

        # Delete the plan
        res2 = plan.delete(self.TEST_PLAN["name"])
        self.assertEqual(res2.json()["success"], True)

        # Make sure the plan is gone
        res3 = plan.get(self.TEST_PLAN["name"])
        self.assertEqual(res3.json()["success"], False)
        self.assertEqual(res3.json()["reason"], "Plan does not exist")
Esempio n. 3
0
    def test_update_plan(self):
        plan = Plan(self.TEST_PLAN)
        resp = plan.create()

        # Update the plan
        new_plan = {
            "description":
            "Changed Test",
            "workflow": [{
                "plugin_name": "minion.plugins.basic.XFrameOptionsPlugin",
                "description":
                "Test if the site has an X-Frame-Options header",
                "configuration": {
                    "require": "DENY"
                }
            }]
        }

        res = plan.update(plan.plan["name"], new_plan)
        self.assertEqual(res.json()["success"], True)

        # make a copy of the new plan because we need to fill in the plan name
        _new_plan = dict(new_plan)
        _new_plan["name"] = self.TEST_PLAN["name"]
        # the response contains some unncessary fields, only extract the good one
        _res_plan = {
            key: value
            for key, value in res.json()["plan"].items()
            if key in ("name", "description", "workflow")
        }
        # the new plan we feed into minion and the one we return from response shoudl match
        self.assertEqual(_res_plan, _new_plan)

        # make sure get gives the same result as well
        res2 = plan.get(self.TEST_PLAN["name"])
        _res2_plan = {
            key: value
            for key, value in res2.json()["plan"].items()
            if key in ("name", "description", "workflow")
        }
        self.assertEqual(_res2_plan, _new_plan)