11use flate2:: read:: GzDecoder ;
2- use sea_orm:: { ColumnTrait , QuerySelect } ;
3- use sea_orm :: { EntityTrait , QueryFilter } ;
2+ use sea_orm:: { ColumnTrait , QuerySelect , EntityTrait , QueryFilter } ;
3+
44use sea_query:: Cond ;
55use serde_json:: { Value , json} ;
66use std:: io:: Read ;
77use tar:: Archive ;
88use test_context:: test_context;
99use test_log:: test;
10- use trustify_entity:: sbom_package_license:: LicenseCategory ;
11- use trustify_entity:: { license, sbom_package, sbom_package_license} ;
10+ use trustify_entity:: { sbom_package_license:: LicenseCategory , license, sbom_package, sbom_package_license} ;
1211use trustify_module_fundamental:: license:: {
1312 model:: sbom_license:: SbomNameId ,
1413 service:: { LicenseService , license_export:: LicenseExporter } ,
1514} ;
16- use trustify_test_context:: TrustifyContext ;
17- use trustify_test_context:: subset:: ContainsSubset ;
15+ use trustify_test_context:: { TrustifyContext , subset:: ContainsSubset } ;
1816
1917#[ test_context( TrustifyContext ) ]
2018#[ test( tokio:: test) ]
@@ -46,27 +44,21 @@ async fn test_cyclonedx(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
4644#[ test_context( TrustifyContext ) ]
4745#[ test( tokio:: test) ]
4846async fn test_custom_license_refs_spdx ( ctx : & TrustifyContext ) -> Result < ( ) , anyhow:: Error > {
49- let result = ctx
50- . ingest_document ( "spdx/SATELLITE-6.15-RHEL-8.json" )
51- . await ?;
52-
53- assert_eq ! (
54- Some ( "https://access.redhat.com/security/data/sbom/spdx/SATELLITE-6.15-RHEL-8" ) ,
55- result. clone( ) . document_id. as_deref( )
56- ) ;
47+ let _result = ctx. ingest_document ( "spdx/license-sbom.json" ) . await ?;
5748
5849 let license_result = license:: Entity :: find ( )
5950 . filter (
6051 Cond :: any ( )
61- . add ( license:: Column :: Text . eq ( "LicenseRef-2 OR Ruby " ) )
62- . add ( license:: Column :: Text . eq ( "LicenseRef-GPLv3 AND LicenseRef-21 " ) ) ,
52+ . add ( license:: Column :: Text . eq ( "( LicenseRef-1 AND MIT) OR DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-Netscape " ) )
53+ . add ( license:: Column :: Text . eq ( "( LicenseRef-JasPer AND LicenseRef-1) OR DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-MPL " ) ) ,
6354 )
6455 . select_only ( )
6556 . column ( license:: Column :: Id )
6657 . column ( license:: Column :: Text )
6758 . column ( license:: Column :: SpdxLicenses )
6859 . column ( license:: Column :: SpdxLicenseExceptions )
6960 . column ( license:: Column :: CustomLicenseRefs )
61+ . column ( license:: Column :: CustomDocumentLicenseRefs )
7062 . all ( & ctx. db )
7163 . await ?;
7264
@@ -76,20 +68,23 @@ async fn test_custom_license_refs_spdx(ctx: &TrustifyContext) -> Result<(), anyh
7668 ) ;
7769 let expected_result = json ! ( [
7870 {
79- "id" : "107c5a51-d315-56fb-9d4c-dd337f242d2e " ,
80- "text" : "LicenseRef-2 OR Ruby " ,
81- "spdx_licenses" : [ "Ruby " ] ,
71+ "id" : "37551706-5849-5761-ab10-9fd29d317656 " ,
72+ "text" : "( LicenseRef-1 AND MIT) OR DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-Netscape " ,
73+ "spdx_licenses" : [ "MIT " ] ,
8274 "spdx_license_exceptions" : null,
83- "custom_license_refs" : [ "LicenseRef-2:GPLv2+" ]
75+ "custom_license_refs" : [ "LicenseRef-1:MIT/X License, GPL/CDDL, ASL2" ] ,
76+ "custom_document_license_refs" : [ "DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-Netscape" ]
8477 } ,
8578 {
86- "id" : "5bec012e-9891-5715-a550-09287ced2d54 " ,
87- "text" : "LicenseRef-GPLv3 AND LicenseRef-21 " ,
79+ "id" : "119b7505-184b-5557-a729-dce9720718af " ,
80+ "text" : "( LicenseRef-JasPer AND LicenseRef-1) OR DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-MPL " ,
8881 "spdx_licenses" : null,
8982 "spdx_license_exceptions" : null,
90- "custom_license_refs" : [ "LicenseRef-GPLv3:GPLv3" , "LicenseRef-21:Public domain" ]
83+ "custom_license_refs" : [ "LicenseRef-JasPer:JasPer" , "LicenseRef-1:MIT/X License, GPL/CDDL, ASL2" ] ,
84+ "custom_document_license_refs" : [ "DocumentRef-OCP-TOOLS-4.11-RHEL-8:LicenseRef-MPL" ]
9185 }
9286 ] ) ;
87+
9388 let license_result_value: Value =
9489 serde_json:: to_value ( & license_result) . expect ( "Failed to serialize license_result to JSON" ) ;
9590 assert ! ( expected_result. contains_subset( license_result_value) ) ;
0 commit comments