@@ -150,7 +150,7 @@ def test_create_bom_multiple_purls(self, capsys: Any) -> None:
150
150
content_type = "application/json" ,
151
151
adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
152
152
)
153
-
153
+ self . add_project_attachment_responses ()
154
154
cdx_components , _ = sut .create_project_bom (self .get_project_for_test (),
155
155
create_controlfile = False )
156
156
captured = capsys .readouterr ()
@@ -217,6 +217,86 @@ def add_project_releases_responses(self):
217
217
)
218
218
return release
219
219
220
+ def add_project_attachment_responses (self ):
221
+ responses .add (
222
+ method = responses .GET ,
223
+ url = self .MYURL + "resource/api/attachments/r001a002" ,
224
+ body = """
225
+ {
226
+ "filename": "wheel-0.38.4.zip",
227
+ "attachmentType": "SOURCE"
228
+ }""" ,
229
+ status = 200 ,
230
+ content_type = "application/json" ,
231
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
232
+ )
233
+ responses .add (
234
+ method = responses .GET ,
235
+ url = self .MYURL + "resource/api/attachments/r001a001" ,
236
+ body = """
237
+ {
238
+ "filename": "CLIXML_wheel-0.38.4.xml",
239
+ "sha1": "ccd9f1ed2f59c46ff3f0139c05bfd76f83fd9851",
240
+ "attachmentType": "COMPONENT_LICENSE_INFO_XML"
241
+ }""" ,
242
+ status = 200 ,
243
+ content_type = "application/json" ,
244
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
245
+ )
246
+
247
+ responses .add (
248
+ method = responses .GET ,
249
+ url = self .MYURL + "resource/api/attachments/r002a001" ,
250
+ body = """
251
+ {
252
+ "filename": "clipython-1.3.0.zip",
253
+ "attachmentType": "SOURCE"
254
+ }""" ,
255
+ status = 200 ,
256
+ content_type = "application/json" ,
257
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
258
+ )
259
+ responses .add (
260
+ method = responses .GET ,
261
+ url = self .MYURL + "resource/api/attachments/r002a002" ,
262
+ body = """
263
+ {
264
+ "filename": "CLIXML_clipython-1.3.0.xml",
265
+ "sha1": "dd4c38387c6811dba67d837af7742d84e61e20de",
266
+ "attachmentType": "COMPONENT_LICENSE_INFO_XML",
267
+
268
+ "checkStatus": "ACCEPTED",
269
+
270
+ }""" ,
271
+ status = 200 ,
272
+ content_type = "application/json" ,
273
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
274
+ )
275
+ responses .add (
276
+ method = responses .GET ,
277
+ url = self .MYURL + "resource/api/attachments/r002a003" ,
278
+ body = """
279
+ {
280
+ "filename": "clipython-repacked-for-fun.zip",
281
+ "attachmentType": "SOURCE_SELF"
282
+ }""" ,
283
+ status = 200 ,
284
+ content_type = "application/json" ,
285
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
286
+ )
287
+ responses .add (
288
+ method = responses .GET ,
289
+ url = self .MYURL + "resource/api/attachments/r002a004" ,
290
+ body = """
291
+ {
292
+ "filename": "clipython-1.3.0.docx",
293
+ "attachmentType": "CLEARING_REPORT"
294
+ }""" ,
295
+ status = 200 ,
296
+ content_type = "application/json" ,
297
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
298
+ )
299
+
220
300
@responses .activate
221
301
def test_project_by_id (self ) -> None :
222
302
sut = CreateBom ()
@@ -225,6 +305,7 @@ def test_project_by_id(self) -> None:
225
305
sut .login (token = TestBasePytest .MYTOKEN , url = TestBasePytest .MYURL )
226
306
227
307
release = self .add_project_releases_responses ()
308
+ self .add_project_attachment_responses ()
228
309
project = self .get_project_for_test ()
229
310
230
311
cdx_bom , _ = sut .create_project_cdx_bom ("p001" , create_controlfile = False )
@@ -278,37 +359,8 @@ def test_project_by_id_controlfile(self):
278
359
sut .login (token = TestBasePytest .MYTOKEN , url = TestBasePytest .MYURL )
279
360
280
361
self .add_project_releases_responses ()
362
+ self .add_project_attachment_responses ()
281
363
282
- # attachment info
283
- responses .add (
284
- method = responses .GET ,
285
- url = self .MYURL + "resource/api/attachments/r001a001" ,
286
- body = """
287
- {
288
- "filename": "CLIXML_wheel-0.38.4.xml",
289
- "sha1": "ccd9f1ed2f59c46ff3f0139c05bfd76f83fd9851",
290
- "attachmentType": "COMPONENT_LICENSE_INFO_XML"
291
- }""" ,
292
- status = 200 ,
293
- content_type = "application/json" ,
294
- adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
295
- )
296
- responses .add (
297
- method = responses .GET ,
298
- url = self .MYURL + "resource/api/attachments/r002a002" ,
299
- body = """
300
- {
301
- "filename": "CLIXML_clipython-1.3.0.xml",
302
- "sha1": "dd4c38387c6811dba67d837af7742d84e61e20de",
303
- "attachmentType": "COMPONENT_LICENSE_INFO_XML",
304
-
305
- "checkStatus": "ACCEPTED",
306
-
307
- }""" ,
308
- status = 200 ,
309
- content_type = "application/json" ,
310
- adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
311
- )
312
364
responses .add (
313
365
method = responses .GET ,
314
366
url = self .MYURL + "resource/api/attachments/r002a004" ,
@@ -418,6 +470,7 @@ def test_project_show_by_name(self) -> None:
418
470
content_type = "application/json" ,
419
471
adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
420
472
)
473
+ self .add_project_attachment_responses ()
421
474
422
475
self .delete_file (self .OUTPUTFILE )
423
476
out = self .capture_stdout (sut .run , args )
@@ -457,6 +510,7 @@ def test_create_project_bom_release_error(self):
457
510
content_type = "application/json" ,
458
511
adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
459
512
)
513
+ self .add_project_attachment_responses ()
460
514
with pytest .raises (SystemExit ):
461
515
bom , _ = sut .create_project_bom (self .get_project_for_test (), create_controlfile = False )
462
516
@@ -483,6 +537,18 @@ def test_create_project_bom_controlfile_attachment_error(self):
483
537
content_type = "application/json" ,
484
538
adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
485
539
)
540
+ responses .add (
541
+ method = responses .GET ,
542
+ url = self .MYURL + "resource/api/attachments/r002a001" ,
543
+ body = """
544
+ {
545
+ "filename": "clipython-1.3.0.zip",
546
+ "attachmentType": "COMPONENT_LICENSE_INFO_XML"
547
+ }""" ,
548
+ status = 200 ,
549
+ content_type = "application/json" ,
550
+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
551
+ )
486
552
responses .add (
487
553
method = responses .GET ,
488
554
url = self .MYURL + "resource/api/attachments/r002a002" ,
0 commit comments