@@ -35,6 +35,7 @@ public class SPDXSBOMReaderForExternalDocumentReferenceTests
3535 private const string JsonMissingNamespace = "{\" name\" : \" docname\" ,\" spdxVersion\" : \" SPDX-2.2\" , \" documentDescribes\" :[\" SPDXRef - RootPackage\" ]}" ;
3636 private const string JsonMissingVersion = "{\" name\" : \" docname\" ,\" documentNamespace\" : \" namespace\" ,\" documentDescribes\" :[\" SPDXRef - RootPackage\" ]}" ;
3737 private const string JsonInvalidVersion = "{\" name\" : \" docname\" ,\" documentNamespace\" : \" namespace\" , \" spdxVersion\" : \" SPDX-2.1\" , \" documentDescribes\" :[\" SPDXRef - RootPackage\" ]}" ;
38+ private const string JsonSpdx30Version = "{\" name\" : \" docname\" ,\" documentNamespace\" : \" namespace\" , \" spdxVersion\" : \" SPDX-3.0\" , \" documentDescribes\" :[\" SPDXRef - RootPackage\" ]}" ;
3839 private const string JsonMissingDocumentDescribe = "{\" name\" : \" docname\" ,\" documentNamespace\" : \" namespace\" , \" spdxVersion\" : \" SPDX-2.2\" }" ;
3940
4041 public SPDXSBOMReaderForExternalDocumentReferenceTests ( )
@@ -191,4 +192,43 @@ public async Task When_ParseSBOMFile_WithSPDXDocumentIssues_ThenThrowException(s
191192 Assert . IsTrue ( await errors . ReadAllAsync ( ) . AnyAsync ( ) ) ;
192193 Assert . IsFalse ( await output . ReadAllAsync ( ) . AnyAsync ( ) ) ;
193194 }
195+
196+ [ TestMethod ]
197+ public async Task When_ParseSBOMFile_WithValidSPDX30Json_ThenTestPass ( )
198+ {
199+ mockHashGenerator . Setup ( h => h . GenerateHashes ( It . IsAny < string > ( ) , It . IsAny < AlgorithmName [ ] > ( ) ) )
200+ . Returns ( ( string fileName , AlgorithmName [ ] algos ) =>
201+ algos . Select ( a =>
202+ new Checksum
203+ {
204+ ChecksumValue = "hash" ,
205+ Algorithm = a
206+ } )
207+ . ToArray ( ) ) ;
208+
209+ fileSystemMock . Setup ( f => f . OpenRead ( It . IsAny < string > ( ) ) ) . Returns ( TestUtils . GenerateStreamFromString ( JsonSpdx30Version ) ) ;
210+
211+ var sbomLocations = new List < string >
212+ {
213+ @"d:\directorya\directoryb\file1.spdx.json"
214+ } ;
215+
216+ var sbomLocationChannel = Channel . CreateUnbounded < string > ( ) ;
217+ foreach ( var sbomLocation in sbomLocations )
218+ {
219+ await sbomLocationChannel . Writer . WriteAsync ( sbomLocation ) ;
220+ }
221+
222+ sbomLocationChannel . Writer . Complete ( ) ;
223+
224+ var spdxSBOMReaderForExternalDocumentReference = new SPDXSbomReaderForExternalDocumentReference ( mockHashGenerator . Object , mockLogger . Object , sbomConfigs , manifestGeneratorProvider , fileSystemMock . Object ) ;
225+ var ( output , errors ) = spdxSBOMReaderForExternalDocumentReference . ParseSbomFile ( sbomLocationChannel ) ;
226+ await foreach ( var externalDocumentReferenceInfo in output . ReadAllAsync ( ) )
227+ {
228+ Assert . AreEqual ( "namespace" , externalDocumentReferenceInfo . DocumentNamespace ) ;
229+ Assert . AreEqual ( "docname" , externalDocumentReferenceInfo . ExternalDocumentName ) ;
230+ }
231+
232+ Assert . IsFalse ( await errors . ReadAllAsync ( ) . AnyAsync ( ) ) ;
233+ }
194234}
0 commit comments