@@ -1679,7 +1679,7 @@ async fn get_cbom(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
16791679
16801680#[ test_context( TrustifyContext ) ]
16811681#[ test( actix_web:: test) ]
1682- async fn get_aibom ( ctx : & TrustifyContext ) -> Result < ( ) , anyhow:: Error > {
1682+ async fn get_aibom_packages ( ctx : & TrustifyContext ) -> Result < ( ) , anyhow:: Error > {
16831683 let app = caller ( ctx) . await ?;
16841684
16851685 // First upload it via the normal SBOM endpoint
@@ -1759,6 +1759,82 @@ async fn get_aibom(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
17591759 Ok ( ( ) )
17601760}
17611761
1762+ #[ test_context( TrustifyContext ) ]
1763+ #[ test( actix_web:: test) ]
1764+ async fn get_aibom_models ( ctx : & TrustifyContext ) -> Result < ( ) , anyhow:: Error > {
1765+ let app = caller ( ctx) . await ?;
1766+
1767+ let id = ctx
1768+ . ingest_document ( "cyclonedx/ai/ibm-granite_granite-docling-258M_aibom.json" )
1769+ . await ?
1770+ . id
1771+ . to_string ( ) ;
1772+
1773+ let uri = format ! ( "/api/v2/sbom/{id}/models" ) ;
1774+ let req = TestRequest :: get ( ) . uri ( & uri) . to_request ( ) ;
1775+ let response: Value = app. call_and_read_body_json ( req) . await ;
1776+ log:: debug!( "response:\n {:#}" , json!( response) ) ;
1777+ let expected = json ! ( {
1778+ "items" : [
1779+ {
1780+ "id" : "pkg:huggingface/ibm-granite/granite-docling-258M@1.0" ,
1781+ "name" : "granite-docling-258M" ,
1782+ "purl" : "pkg:huggingface/ibm-granite/granite-docling-258M@1.0" ,
1783+ "properties" : {
1784+ "version" : "1.0.0" ,
1785+ "licenses" : "apache-2.0" ,
1786+ "bomFormat" : "CycloneDX" ,
1787+ "suppliedBy" : "ibm-granite" ,
1788+ "specVersion" : "1.6" ,
1789+ "typeOfModel" : "idefics3" ,
1790+ "serialNumber" : "urn:uuid:ibm-granite-granite-docling-258M" ,
1791+ "primaryPurpose" : "image-text-to-text" ,
1792+ "downloadLocation" : "https://huggingface.co/ibm-granite/granite-docling-258M/tree/main" ,
1793+ "external_references" : "[{\" type\" : \" website\" , \" url\" : \" https://huggingface.co/ibm-granite/granite-docling-258M\" , \" comment\" : \" Model repository\" }, {\" type\" : \" distribution\" , \" url\" : \" https://huggingface.co/ibm-granite/granite-docling-258M/tree/main\" , \" comment\" : \" Model files\" }]" ,
1794+ "safetyRiskAssessment" : "and fairness, misinformation, and autonomous decision-making, and ethical considerations, including but not limited to: bias and fairness, misinformation, and autonomous decision-making, considerations, the model may in some cases produce inaccurate, biased, offensive or unwanted responses to user prompts, in prompts and responses across key dimensions outlined in the IBM AI Risk Atlas, of triggering unwanted output"
1795+ } ,
1796+ } ,
1797+ ] ,
1798+ "total" : 1
1799+ } ) ;
1800+ assert_eq ! ( expected, response) ;
1801+
1802+ Ok ( ( ) )
1803+ }
1804+
1805+ #[ test_context( TrustifyContext ) ]
1806+ #[ rstest]
1807+ #[ case( "hugging" ) ]
1808+ #[ case( "granite" ) ]
1809+ #[ case( "pkg:huggingface/ibm-granite" ) ]
1810+ #[ case( "pkg:huggingface/ibm-granite/granite-docling-258M" ) ]
1811+ #[ case( "pkg:huggingface/ibm-granite/granite-docling-258M@1.0" ) ]
1812+ #[ case( "purl=pkg:huggingface/ibm-granite/granite-docling-258M@1.0" ) ]
1813+ #[ case( "purl~granite" ) ]
1814+ #[ case( "purl:namespace=ibm-granite&purl:version=1.0&purl:type=huggingface" ) ]
1815+ #[ case( "name~granite" ) ]
1816+ #[ case( "name=granite-docling-258M" ) ]
1817+ #[ case( "properties:typeOfModel=idefics3" ) ]
1818+ #[ case( "properties:typeOfModel=idefics3&properties:primaryPurpose=image-text-to-text" ) ]
1819+ #[ test_log:: test( actix_web:: test) ]
1820+ async fn query_aibom_models ( ctx : & TrustifyContext , #[ case] q : & str ) -> Result < ( ) , anyhow:: Error > {
1821+ let app = caller ( ctx) . await ?;
1822+
1823+ let id = ctx
1824+ . ingest_document ( "cyclonedx/ai/ibm-granite_granite-docling-258M_aibom.json" )
1825+ . await ?
1826+ . id
1827+ . to_string ( ) ;
1828+
1829+ let uri = format ! ( "/api/v2/sbom/{id}/models?q={}" , encode( q) ) ;
1830+ let req = TestRequest :: get ( ) . uri ( & uri) . to_request ( ) ;
1831+ let response: Value = app. call_and_read_body_json ( req) . await ;
1832+
1833+ assert_eq ! ( response[ "total" ] . as_i64( ) , Some ( 1 ) , "q: {q}" ) ;
1834+
1835+ Ok ( ( ) )
1836+ }
1837+
17621838#[ test_context( TrustifyContext ) ]
17631839#[ rstest]
17641840#[ case:: no_filter( [ ] , 3 ) ]
0 commit comments