예제 #1
0
 def test_add_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", "title"],
                 "marking_ref": "marking-definition--1"
             },
         ]
     }
     api.add_markings(before, ["title"], ["marking-definition--1"])
     self.assertEqual(before, after)
예제 #2
0
    def test_add_marking_mark_multiple_selector_multiple_refs(self):
        before = {
            "description": "test description",
            "title": "foo",
        }
        after = {
            "description":
            "test description",
            "title":
            "foo",
            "granular_markings": [
                {
                    "selectors": ["description", "title"],
                    "marking_ref": "marking-definition--1"
                },
                {
                    "selectors": ["description", "title"],
                    "marking_ref": "marking-definition--2"
                },
            ]
        }
        api.add_markings(before, ["description", "title"],
                         ["marking-definition--1", "marking-definition--2"])

        for m in before["granular_markings"]:
            self.assertTrue(m in after["granular_markings"])
예제 #3
0
    def test_add_markings_one_marking(self):
        before = {"title": "test title", "description": "test description"}

        after = {
            "title": "test title",
            "description": "test description",
            "object_marking_refs": ["marking-definition--1"]
        }

        api.add_markings(before, None, "marking-definition--1")

        self.assertEqual(before, after)
예제 #4
0
    def test_add_markings_combination(self):
        before = {"title": "test title", "description": "test description"}

        after = {
            "title":
            "test title",
            "description":
            "test description",
            "object_marking_refs":
            ["marking-definition--1", "marking-definition--2"],
            "granular_markings": [
                {
                    "selectors": ["title"],
                    "marking_ref": "marking-definition--3"
                },
                {
                    "selectors": ["description"],
                    "marking_ref": "marking-definition--4"
                },
            ]
        }

        api.add_markings(before, None, "marking-definition--1")
        api.add_markings(before, None, "marking-definition--2")
        api.add_markings(before, "title", "marking-definition--3")
        api.add_markings(before, "description", "marking-definition--4")

        for m in before["granular_markings"]:
            self.assertTrue(m in after["granular_markings"])

        for m in before["object_marking_refs"]:
            self.assertTrue(m in after["object_marking_refs"])
예제 #5
0
    def test_add_markings_multiple_marking(self):
        before = {"title": "test title", "description": "test description"}

        after = {
            "title":
            "test title",
            "description":
            "test description",
            "object_marking_refs":
            ["marking-definition--1", "marking-definition--2"]
        }

        api.add_markings(before, None,
                         ["marking-definition--1", "marking-definition--2"])

        for m in before["object_marking_refs"]:
            self.assertTrue(m in after["object_marking_refs"])
 def test_add_marking_mark_multiple_selector_one_refs(self):
     before = {
         "description": "test description",
         "title": "foo",
     }
     after = {
         "description": "test description",
         "title": "foo",
         "granular_markings": [
             {
                 "selectors": ["description", "title"],
                 "marking_ref": "marking-definition--1"
             },
         ]
     }
     api.add_markings(before, ["description", "title"], ["marking-definition--1"])
     self.assertEqual(before, after)
def main():
    file = open("campaign-marked.json")
    campaign = json.load(file)

    new_selectors = ["revision", "modified_time"]

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

    object_marking = [
        "marking-definition--84bc682f-62d3-4657-803e-665d3e2909d4"
    ]

    # Adds granular markings
    api.add_markings(campaign, new_selectors, new_markings)

    # Adds object level marking
    api.add_markings(campaign, None, object_marking)

    print(json.dumps(campaign, indent=4, sort_keys=True))