@@ -32,7 +32,7 @@ pub fn configure(config: &mut utoipa_actix_web::service_config::ServiceConfig, d
32
32
( status = 200 , description = "Analysis status." , body = AnalysisStatus ) ,
33
33
) ,
34
34
) ]
35
- #[ get( "/v1 /analysis/status" ) ]
35
+ #[ get( "/v2 /analysis/status" ) ]
36
36
pub async fn analysis_status (
37
37
service : web:: Data < AnalysisService > ,
38
38
db : web:: Data < Database > ,
@@ -55,7 +55,7 @@ pub async fn analysis_status(
55
55
( status = 200 , description = "Search component(s) and return their root components." , body = AncestorSummary ) ,
56
56
) ,
57
57
) ]
58
- #[ get( "/v1 /analysis/root-component" ) ]
58
+ #[ get( "/v2 /analysis/root-component" ) ]
59
59
pub async fn search_component_root_components (
60
60
service : web:: Data < AnalysisService > ,
61
61
db : web:: Data < Database > ,
@@ -80,7 +80,7 @@ pub async fn search_component_root_components(
80
80
( status = 200 , description = "Retrieve component(s) root components by name or pURL." , body = AncestorSummary ) ,
81
81
) ,
82
82
) ]
83
- #[ get( "/v1 /analysis/root-component/{key}" ) ]
83
+ #[ get( "/v2 /analysis/root-component/{key}" ) ]
84
84
pub async fn get_component_root_components (
85
85
service : web:: Data < AnalysisService > ,
86
86
db : web:: Data < Database > ,
@@ -115,7 +115,7 @@ pub async fn get_component_root_components(
115
115
( status = 200 , description = "Search component(s) and return their deps." , body = DepSummary ) ,
116
116
) ,
117
117
) ]
118
- #[ get( "/v1 /analysis/dep" ) ]
118
+ #[ get( "/v2 /analysis/dep" ) ]
119
119
pub async fn search_component_deps (
120
120
service : web:: Data < AnalysisService > ,
121
121
db : web:: Data < Database > ,
@@ -140,7 +140,7 @@ pub async fn search_component_deps(
140
140
( status = 200 , description = "Retrieve component(s) dep components by name or pURL." , body = DepSummary ) ,
141
141
) ,
142
142
) ]
143
- #[ get( "/v1 /analysis/dep/{key}" ) ]
143
+ #[ get( "/v2 /analysis/dep/{key}" ) ]
144
144
pub async fn get_component_deps (
145
145
service : web:: Data < AnalysisService > ,
146
146
db : web:: Data < Database > ,
@@ -183,7 +183,7 @@ mod test {
183
183
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
184
184
185
185
//should match multiple components
186
- let uri = "/api/v1 /analysis/root-component?q=B" ;
186
+ let uri = "/api/v2 /analysis/root-component?q=B" ;
187
187
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
188
188
let response: Value = app. call_and_read_body_json ( request) . await ;
189
189
@@ -197,7 +197,7 @@ mod test {
197
197
log:: info!( "{:?}" , response) ;
198
198
199
199
//should match a single component
200
- let uri = "/api/v1 /analysis/root-component?q=BB" ;
200
+ let uri = "/api/v2 /analysis/root-component?q=BB" ;
201
201
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
202
202
let response: Value = app. call_and_read_body_json ( request) . await ;
203
203
assert_eq ! ( response
[ "items" ] [ 0 ] [ "purl" ] , "pkg:rpm/redhat/[email protected] " ) ;
@@ -218,7 +218,7 @@ mod test {
218
218
let app = caller ( ctx) . await ?;
219
219
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
220
220
221
- let uri = "/api/v1 /analysis/root-component/B" ;
221
+ let uri = "/api/v2 /analysis/root-component/B" ;
222
222
223
223
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
224
224
@@ -241,7 +241,7 @@ mod test {
241
241
let app = caller ( ctx) . await ?;
242
242
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
243
243
244
- let uri = "/api/v1 /analysis/root-component/pkg%3A%2F%2Frpm%2Fredhat%2FB%400.0.0" ;
244
+ let uri = "/api/v2 /analysis/root-component/pkg%3A%2F%2Frpm%2Fredhat%2FB%400.0.0" ;
245
245
246
246
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
247
247
@@ -268,7 +268,7 @@ mod test {
268
268
] )
269
269
. await ?;
270
270
271
- let uri = "/api/v1 /analysis/root-component?q=spymemcached" ;
271
+ let uri = "/api/v2 /analysis/root-component?q=spymemcached" ;
272
272
273
273
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
274
274
@@ -300,11 +300,11 @@ mod test {
300
300
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
301
301
302
302
//prime the graph hashmap
303
- let uri = "/api/v1 /analysis/root-component?q=BB" ;
303
+ let uri = "/api/v2 /analysis/root-component?q=BB" ;
304
304
let load1 = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
305
305
let _response: Value = app. call_and_read_body_json ( load1) . await ;
306
306
307
- let uri = "/api/v1 /analysis/status" ;
307
+ let uri = "/api/v2 /analysis/status" ;
308
308
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
309
309
let response: Value = app. call_and_read_body_json ( request) . await ;
310
310
@@ -314,7 +314,7 @@ mod test {
314
314
// ingest duplicate sbom which has different date
315
315
ctx. ingest_documents ( [ "spdx/simple-dup.json" ] ) . await ?;
316
316
317
- let uri = "/api/v1 /analysis/status" ;
317
+ let uri = "/api/v2 /analysis/status" ;
318
318
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
319
319
let response: Value = app. call_and_read_body_json ( request) . await ;
320
320
@@ -330,7 +330,7 @@ mod test {
330
330
let app = caller ( ctx) . await ?;
331
331
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
332
332
333
- let uri = "/api/v1 /analysis/dep?q=A" ;
333
+ let uri = "/api/v2 /analysis/dep?q=A" ;
334
334
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
335
335
let response: Value = app. call_and_read_body_json ( request) . await ;
336
336
@@ -357,7 +357,7 @@ mod test {
357
357
let app = caller ( ctx) . await ?;
358
358
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
359
359
360
- let uri = "/api/v1 /analysis/dep/A" ;
360
+ let uri = "/api/v2 /analysis/dep/A" ;
361
361
362
362
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
363
363
let response: Value = app. call_and_read_body_json ( request) . await ;
@@ -385,7 +385,7 @@ mod test {
385
385
let app = caller ( ctx) . await ?;
386
386
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
387
387
388
- let uri = "/api/v1 /analysis/dep/pkg%3A%2F%2Frpm%2Fredhat%2FAA%400.0.0%3Farch%3Dsrc" ;
388
+ let uri = "/api/v2 /analysis/dep/pkg%3A%2F%2Frpm%2Fredhat%2FAA%400.0.0%3Farch%3Dsrc" ;
389
389
390
390
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
391
391
let response: Value = app. call_and_read_body_json ( request) . await ;
@@ -412,7 +412,7 @@ mod test {
412
412
] )
413
413
. await ?;
414
414
415
- let uri = "/api/v1 /analysis/dep?q=spymemcached" ;
415
+ let uri = "/api/v2 /analysis/dep?q=spymemcached" ;
416
416
417
417
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
418
418
@@ -435,41 +435,41 @@ mod test {
435
435
ctx. ingest_documents ( [ "spdx/simple.json" ] ) . await ?;
436
436
437
437
// filter on node_id
438
- let uri = "/api/v1 /analysis/dep?q=node_id%3DSPDXRef-A" ;
438
+ let uri = "/api/v2 /analysis/dep?q=node_id%3DSPDXRef-A" ;
439
439
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
440
440
let response: Value = app. call_and_read_body_json ( request) . await ;
441
441
assert_eq ! ( response[ "items" ] [ 0 ] [ "name" ] , "A" ) ;
442
442
assert_eq ! ( & response[ "total" ] , 1 ) ;
443
443
444
444
// filter on node_id
445
- let uri = "/api/v1 /analysis/root-component?q=node_id%3DSPDXRef-B" ;
445
+ let uri = "/api/v2 /analysis/root-component?q=node_id%3DSPDXRef-B" ;
446
446
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
447
447
let response: Value = app. call_and_read_body_json ( request) . await ;
448
448
assert_eq ! ( response[ "items" ] [ 0 ] [ "name" ] , "B" ) ;
449
449
assert_eq ! ( & response[ "total" ] , 1 ) ;
450
450
451
451
// filter on node_id & name
452
- let uri = "/api/v1 /analysis/root-component?q=node_id%3DSPDXRef-B%26name%3DB" ;
452
+ let uri = "/api/v2 /analysis/root-component?q=node_id%3DSPDXRef-B%26name%3DB" ;
453
453
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
454
454
let response: Value = app. call_and_read_body_json ( request) . await ;
455
455
assert_eq ! ( response[ "items" ] [ 0 ] [ "name" ] , "B" ) ;
456
456
assert_eq ! ( & response[ "total" ] , 1 ) ;
457
457
458
458
// filter on sbom_id (which has urn:uuid: prefix)
459
459
let sbom_id = response[ "items" ] [ 0 ] [ "sbom_id" ] . as_str ( ) . unwrap ( ) ;
460
- let uri = format ! ( "/api/v1 /analysis/root-component?q=sbom_id={}" , sbom_id) ;
460
+ let uri = format ! ( "/api/v2 /analysis/root-component?q=sbom_id={}" , sbom_id) ;
461
461
let request: Request = TestRequest :: get ( ) . uri ( uri. clone ( ) . as_str ( ) ) . to_request ( ) ;
462
462
let response: Value = app. call_and_read_body_json ( request) . await ;
463
463
assert_eq ! ( & response[ "total" ] , 8 ) ;
464
464
465
465
// negative test
466
- let uri = "/api/v1 /analysis/root-component?q=sbom_id=urn:uuid:99999999-9999-9999-9999-999999999999" ;
466
+ let uri = "/api/v2 /analysis/root-component?q=sbom_id=urn:uuid:99999999-9999-9999-9999-999999999999" ;
467
467
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
468
468
let response: Value = app. call_and_read_body_json ( request) . await ;
469
469
assert_eq ! ( & response[ "total" ] , 0 ) ;
470
470
471
471
// negative test
472
- let uri = "/api/v1 /analysis/root-component?q=node_id%3DSPDXRef-B%26name%3DA" ;
472
+ let uri = "/api/v2 /analysis/root-component?q=node_id%3DSPDXRef-B%26name%3DA" ;
473
473
let request: Request = TestRequest :: get ( ) . uri ( uri) . to_request ( ) ;
474
474
let response: Value = app. call_and_read_body_json ( request) . await ;
475
475
@@ -486,7 +486,7 @@ mod test {
486
486
487
487
// Find all deps of src rpm
488
488
let src =
"pkg:rpm/redhat/[email protected] _2?arch=src" ;
489
- let uri = format ! ( "/api/v1 /analysis/dep/{}" , urlencoding:: encode( src) ) ;
489
+ let uri = format ! ( "/api/v2 /analysis/dep/{}" , urlencoding:: encode( src) ) ;
490
490
let request: Request = TestRequest :: get ( ) . uri ( & uri) . to_request ( ) ;
491
491
let response: Value = app. call_and_read_body_json ( request) . await ;
492
492
log:: debug!( "{response:#?}" ) ;
@@ -495,7 +495,7 @@ mod test {
495
495
// Ensure binary rpm GeneratedFrom src rpm
496
496
let x86 =
"pkg:rpm/redhat/[email protected] _2?arch=x86_64" ;
497
497
let uri = format ! (
498
- "/api/v1 /analysis/root-component/{}" ,
498
+ "/api/v2 /analysis/root-component/{}" ,
499
499
urlencoding:: encode( x86)
500
500
) ;
501
501
let request: Request = TestRequest :: get ( ) . uri ( & uri) . to_request ( ) ;
0 commit comments