Skip to content

Commit

Permalink
test: this will break the ci same as trustification#999
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed Nov 15, 2024
1 parent b47e588 commit 40c35fe
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion modules/fundamental/src/advisory/endpoints/test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use crate::{
advisory::model::{AdvisoryDetails, AdvisorySummary},
test::caller,
Expand All @@ -8,7 +10,7 @@ use hex::ToHex;
use jsonpath_rust::JsonPathQuery;
use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use test_context::test_context;
use test_context::{futures, test_context};
use test_log::test;
use time::OffsetDateTime;
use trustify_common::{db::Transactional, hashing::Digests, id::Id, model::PaginatedResults};
Expand Down Expand Up @@ -387,6 +389,55 @@ async fn upload_default_csaf_format_multiple(ctx: &TrustifyContext) -> Result<()
Ok(())
}

#[test_context(TrustifyContext)]
#[test(actix_web::test)]
async fn upload_default_csaf_format_multiple_parallel(
ctx: &TrustifyContext,
) -> Result<(), anyhow::Error> {
let app = Arc::new(caller(ctx).await?);
let files = vec![
"csaf/cve-2023-0044.json",
"csaf/rhsa-2023_5835.json",
"csaf/rhsa-2024_2776.json",
"csaf/CVE-2023-20862.json",
"csaf/rhsa-2024_2049.json",
"csaf/cve-2023-33201.json",
"csaf/rhsa-2024_2784.json",
"csaf/rhsa-2024_2054.json",
"csaf/rhsa-2024_3351.json",
"csaf/CVE-2024-5154.json",
"csaf/rhsa-2024_2071.json",
"csaf/rhsa-2024_3666.json",
"csaf/RHBA-2024_1440.json",
"csaf/rhsa-2024-2705.json",
];

let uri = "/api/v1/advisory";

let tasks = files.into_iter().map(|file| {
let app = app.clone();
async move {
let payload = document_bytes(file).await?;
let request = TestRequest::post()
.uri(uri)
.set_payload(payload)
.to_request();

let result: IngestResult = app.call_and_read_body_json(request).await;
log::debug!("{result:?}");
assert!(matches!(result.id, Id::Uuid(_)));
Ok::<(), anyhow::Error>(())
}
});

let results = futures::future::join_all(tasks).await;
for result in results {
result?;
}

Ok(())
}

#[test_context(TrustifyContext)]
#[test(actix_web::test)]
async fn upload_osv_format(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
Expand Down

0 comments on commit 40c35fe

Please sign in to comment.