45 lines
1.5 KiB
Rust
45 lines
1.5 KiB
Rust
|
|
#[allow(dead_code)]
|
||
|
|
mod support;
|
||
|
|
|
||
|
|
use remora_contracts::JobResourceDto;
|
||
|
|
use reqwest::StatusCode;
|
||
|
|
use serde_json::{Value, json};
|
||
|
|
|
||
|
|
use support::{mint_provider_token, required_env};
|
||
|
|
|
||
|
|
#[tokio::test]
|
||
|
|
async fn deployed_api_accepts_an_authorized_job_for_coordination_rebuild() {
|
||
|
|
if std::env::var("REMORA_DEPLOYMENT_REQUIRE").is_err() {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let base = required_env("REMORA_DEPLOYMENT_API_URL")
|
||
|
|
.trim_end_matches('/')
|
||
|
|
.to_owned();
|
||
|
|
let client = reqwest::Client::builder()
|
||
|
|
.redirect(reqwest::redirect::Policy::none())
|
||
|
|
.build()
|
||
|
|
.unwrap();
|
||
|
|
let unauthenticated = client.get(format!("{base}/jobs")).send().await.unwrap();
|
||
|
|
assert_eq!(unauthenticated.status(), StatusCode::UNAUTHORIZED);
|
||
|
|
|
||
|
|
let token = mint_provider_token().await.unwrap();
|
||
|
|
let submitted = client
|
||
|
|
.post(format!("{base}/jobs"))
|
||
|
|
.bearer_auth(token)
|
||
|
|
.header("Idempotency-Key", "deployment-coordination-rebuild")
|
||
|
|
.json(&json!({
|
||
|
|
"source": {
|
||
|
|
"kind": "http",
|
||
|
|
"url": "https://example.com/deployment-smoke",
|
||
|
|
"result_path": "artifact.bin"
|
||
|
|
},
|
||
|
|
"label": "deployment-coordination-rebuild"
|
||
|
|
}))
|
||
|
|
.send()
|
||
|
|
.await
|
||
|
|
.unwrap();
|
||
|
|
assert_eq!(submitted.status(), StatusCode::ACCEPTED);
|
||
|
|
let body: Value = submitted.json().await.unwrap();
|
||
|
|
serde_json::from_value::<JobResourceDto>(body.clone()).unwrap();
|
||
|
|
assert_eq!(body["phase"], "Queued");
|
||
|
|
}
|