Skip to content

Commit 488a1cb

Browse files
committed
Add _bug_under_embargo unit tests
1 parent 4bd61e4 commit 488a1cb

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

jenkins_pipelines/scripts/tests/test_bugzilla_client.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_get_bugs_success(self, mock_api_call):
2020
mock_api_call.assert_called_once()
2121
# check None keys are dropped
2222
mock_api_call.assert_called_with(self.bugzilla_client._bugs_endpoint, params = {'Bugzilla_api_key': 'test_key', "product": "Test Product"})
23+
# embargoed bug should have been dropped
2324
self.assertEqual(len(bugs), 3)
2425
for i in range(len(bugs)):
2526
bug: dict[str, Any] = bugs[i]
@@ -42,5 +43,37 @@ def test_parse_release_notes(self):
4243
# first line is not ----------------
4344
self.assertRaises(ValueError, self.bugzilla_client._parse_release_notes, './tests/testdata/test_invalid_release_notes.changes')
4445

46+
def test_bug_under_embargo(self):
47+
bsc: dict[str, any] = {
48+
"classification": "Test",
49+
"component": "Test components",
50+
"creation_time": "2024-03-03T00:00:00Z",
51+
"creator": "tester@suse.com",
52+
"deadline": None,
53+
"depends_on": [],
54+
"id": 3,
55+
"is_cc_accessible": True,
56+
"is_confirmed": True,
57+
"is_creator_accessible": True,
58+
"is_open": True,
59+
"priority": "P0 - Critical",
60+
"product": "Test Product",
61+
"remaining_time": 0,
62+
"resolution": "",
63+
"severity": "High",
64+
"status": "CONFIRMED",
65+
"summary": "VUL-0: EMBARGOED: Test BSC",
66+
"version": "Test"
67+
}
68+
# explicit mention in the summary
69+
self.assertTrue(self.bugzilla_client._bug_under_embargo(bsc))
70+
# no embargo mention
71+
bsc['summary'] = "CVE 123456789: Test BSC"
72+
self.assertFalse(self.bugzilla_client._bug_under_embargo(bsc))
73+
bsc['summary'] = "Test BSC"
74+
self.assertFalse(self.bugzilla_client._bug_under_embargo(bsc))
75+
76+
77+
4578
if __name__ == '__main__':
4679
unittest.main()

jenkins_pipelines/scripts/tests/testdata/bugzilla_bugs.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@
6262
"status": "CONFIRMED",
6363
"summary": "Test BSC 3",
6464
"version": "Test"
65+
},
66+
{
67+
"classification": "Test",
68+
"component": "Test components",
69+
"creation_time": "2024-03-03T00:00:00Z",
70+
"creator": "tester@suse.com",
71+
"deadline": null,
72+
"depends_on": [],
73+
"id": 3,
74+
"is_cc_accessible": true,
75+
"is_confirmed": true,
76+
"is_creator_accessible": true,
77+
"is_open": true,
78+
"priority": "P0 - Critical",
79+
"product": "Test Product",
80+
"remaining_time": 0,
81+
"resolution": "",
82+
"severity": "High",
83+
"status": "CONFIRMED",
84+
"summary": "VUL-0: EMBARGOED: CVE-123456789 Test BSC 4",
85+
"version": "Test"
6586
}
6687
]
6788
}

0 commit comments

Comments
 (0)