@@ -57,12 +57,60 @@ def tearDown(cls) -> None:
5757 with suppress (FileNotFoundError ):
5858 remove (TEST_SBOM_DOWNLOAD_PATH )
5959
60+ def test_sbom_upload_with_public_privacy (self ):
61+ """
62+ Test sbom upload with privacy
63+ """
64+ now = now_timestamp ()
65+ print ("Title:" , self .title , now )
66+ with open (TEST_SBOM_PATH , "rb" ) as fd :
67+ metadata = self .arch .sboms .upload (
68+ fd , confirm = True , params = {"privacy" : "PUBLIC" }
69+ )
70+ print ("first upload" , json_dumps (metadata .dict (), indent = 4 ))
71+ identity = metadata .identity
72+
73+ metadata1 = self .arch .sboms .read (identity )
74+ print ("read" , json_dumps (metadata1 .dict (), indent = 4 ))
75+ self .assertEqual (
76+ metadata ,
77+ metadata1 ,
78+ msg = "Metadata not correct" ,
79+ )
80+
81+ def test_sbom_upload_with_confirmation (self ):
82+ """
83+ Test sbom upload with confirmation
84+ """
85+ now = now_timestamp ()
86+ print ("Title:" , self .title , now )
87+ with open (TEST_SBOM_PATH , "rb" ) as fd :
88+ metadata = self .arch .sboms .upload (fd , confirm = True )
89+ print ("first upload" , json_dumps (metadata .dict (), indent = 4 ))
90+ identity = metadata .identity
91+
92+ metadata1 = self .arch .sboms .read (identity )
93+ print ("read" , json_dumps (metadata1 .dict (), indent = 4 ))
94+ self .assertEqual (
95+ metadata ,
96+ metadata1 ,
97+ msg = "Metadata not correct" ,
98+ )
99+
100+ sleep (1 ) # the data may have not reached cogsearch
101+ metadatas = list (self .arch .sboms .list (metadata = {"uploaded_since" : now }))
102+ self .assertEqual (
103+ len (metadatas ),
104+ 1 ,
105+ msg = "No. of SBOMS should be 1" ,
106+ )
107+
60108 def test_sbom_upload_and_download (self ):
61109 """
62110 Test sbom upload and download through the SDK
63111 """
64- print ("Title:" , self .title )
65112 now = now_timestamp ()
113+ print ("Title:" , self .title , now )
66114 with open (TEST_SBOM_PATH , "rb" ) as fd :
67115 metadata = self .arch .sboms .upload (fd )
68116
@@ -83,11 +131,8 @@ def test_sbom_upload_and_download(self):
83131 msg = "Metadata not correct" ,
84132 )
85133
86- sleep (1 ) # otherwise test fails
134+ sleep (1 ) # the data may have not reached cogsearch
87135 metadatas = list (self .arch .sboms .list (metadata = {"uploaded_since" : now }))
88- for i , m in enumerate (metadatas ):
89- print (i , ":" , json_dumps (m .dict (), indent = 4 ))
90-
91136 self .assertEqual (
92137 len (metadatas ),
93138 1 ,
@@ -99,6 +144,9 @@ def test_sbom_upload_and_download(self):
99144 msg = "Metadata not correct" ,
100145 )
101146
147+ for i , m in enumerate (metadatas ):
148+ print (i , ":" , json_dumps (m .dict (), indent = 4 ))
149+
102150 metadata2 = self .arch .sboms .publish (identity , confirm = True )
103151 print ("publish" , json_dumps (metadata2 .dict (), indent = 4 ))
104152 self .assertNotEqual (
@@ -135,7 +183,6 @@ def test_sbom_upload_and_download(self):
135183 msg = "Withdrawn_date not correct" ,
136184 )
137185
138- sleep (1 ) # otherwise test fails
139186 metadatas = list (
140187 self .arch .sboms .list (
141188 page_size = 50 ,
0 commit comments