Beispiel #1
0
    def test_set_marking(self):
        before = {
            "title":
            "test title",
            "description":
            "test description",
            "object_marking_refs": [
                "marking-definition--1", "marking-definition--2",
                "marking-definition--3"
            ]
        }
        after = {
            "title":
            "test title",
            "description":
            "test description",
            "object_marking_refs":
            ["marking-definition--7", "marking-definition--9"]
        }

        api.set_markings(before, None,
                         ["marking-definition--7", "marking-definition--9"])

        for m in before["object_marking_refs"]:
            self.assertTrue(
                m in ["marking-definition--7", "marking-definition--9"])

        self.assertTrue([
            "marking-definition--1", "marking-definition--2",
            "marking-definition--3"
        ] not in before["object_marking_refs"])

        for x in before["object_marking_refs"]:
            self.assertTrue(x in after["object_marking_refs"])
    def test_set_marking_mark_another_property_same_marking(self):
        before = {
            "description": "test description",
            "title": "foo",
            "granular_markings": [
                {
                    "selectors": ["description"],
                    "marking_ref": "marking-definition--1"
                }
            ]
        }
        after = {
            "description": "test description",
            "title": "foo",
            "granular_markings": [
                {
                    "selectors": ["description"],
                    "marking_ref": "marking-definition--7"
                },
                {
                    "selectors": ["description"],
                    "marking_ref": "marking-definition--8"
                },
            ]
        }
        api.set_markings(before, ["description"], ["marking-definition--7", "marking-definition--8"])

        for m in before["granular_markings"]:
            self.assertTrue(m in after["granular_markings"])
Beispiel #3
0
 def test_set_marking_mark_multiple_selector_one_refs(self):
     before = {
         "description":
         "test description",
         "title":
         "foo",
         "granular_markings": [
             {
                 "selectors": ["description", "title"],
                 "marking_ref": "marking-definition--3"
             },
         ]
     }
     after = {
         "description":
         "test description",
         "title":
         "foo",
         "granular_markings": [
             {
                 "selectors": ["description", "title"],
                 "marking_ref": "marking-definition--1"
             },
         ]
     }
     api.set_markings(before, ["description", "title"],
                      ["marking-definition--1"])
     self.assertEqual(before, after)
Beispiel #4
0
 def test_set_marking_mark_one_selector_multiple_refs(self):
     before = {
         "description": "test description",
         "title": "foo",
     }
     after = {
         "description":
         "test description",
         "title":
         "foo",
         "granular_markings": [
             {
                 "selectors": ["description"],
                 "marking_ref": "marking-definition--1"
             },
             {
                 "selectors": ["description"],
                 "marking_ref": "marking-definition--2"
             },
         ]
     }
     api.set_markings(before, ["description"],
                      ["marking-definition--1", "marking-definition--2"])
     for m in before["granular_markings"]:
         self.assertTrue(m in after["granular_markings"])
def main():
    file = open("campaign-marked.json")
    campaign = json.load(file)

    new_markings = [
        "marking-definition--3a3d3484-d67d-41b3-8e28-7ab3ddb16f3b",
        "marking-definition--7e38ee56-abf2-47dd-9bab-28a3c598c84e"
    ]

    api.set_markings(campaign, "created_by_ref", new_markings)

    print(json.dumps(campaign, indent=4, sort_keys=True))
 def test_set_marking_mark_same_property_same_marking(self):
     before = {
         "description": "test description",
         "title": "foo",
         "granular_markings": [
             {
                 "selectors": ["description"],
                 "marking_ref": "marking-definition--1"
             }
         ]
     }
     after = {
         "description": "test description",
         "title": "foo",
         "granular_markings": [
             {
                 "selectors": ["description"],
                 "marking_ref": "marking-definition--1"
             }
         ]
     }
     api.set_markings(before, ["description"], ["marking-definition--1"])
     self.assertEqual(before, after)