style: rustfmt the signed-catalog serving
This commit is contained in:
@@ -150,7 +150,9 @@ impl ApiHandler {
|
|||||||
// appears immediately, without a frontend release. The old external UI
|
// appears immediately, without a frontend release. The old external UI
|
||||||
// catalog below is emergency compatibility only; it must never override
|
// catalog below is emergency compatibility only; it must never override
|
||||||
// a healthy signed catalog (Cuprate was invisible for exactly that reason).
|
// a healthy signed catalog (Cuprate was invisible for exactly that reason).
|
||||||
if let Ok(body) = crate::container::app_catalog::verified_catalog_body(&self.config.data_dir).await {
|
if let Ok(body) =
|
||||||
|
crate::container::app_catalog::verified_catalog_body(&self.config.data_dir).await
|
||||||
|
{
|
||||||
return Ok(Response::builder()
|
return Ok(Response::builder()
|
||||||
.status(hyper::StatusCode::OK)
|
.status(hyper::StatusCode::OK)
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
|
|||||||
@@ -207,7 +207,9 @@ pub async fn verified_catalog_body(data_dir: &Path) -> anyhow::Result<String> {
|
|||||||
let raw: serde_json::Value = serde_json::from_str(&body)?;
|
let raw: serde_json::Value = serde_json::from_str(&body)?;
|
||||||
match crate::trust::verify_detached(&raw)? {
|
match crate::trust::verify_detached(&raw)? {
|
||||||
crate::trust::SignatureStatus::Verified { anchored: true, .. } => Ok(body),
|
crate::trust::SignatureStatus::Verified { anchored: true, .. } => Ok(body),
|
||||||
crate::trust::SignatureStatus::Verified { anchored: false, .. } => {
|
crate::trust::SignatureStatus::Verified {
|
||||||
|
anchored: false, ..
|
||||||
|
} => {
|
||||||
anyhow::bail!("app catalog signer is not anchored to the release root")
|
anyhow::bail!("app catalog signer is not anchored to the release root")
|
||||||
}
|
}
|
||||||
crate::trust::SignatureStatus::Unsigned => anyhow::bail!("app catalog is unsigned"),
|
crate::trust::SignatureStatus::Unsigned => anyhow::bail!("app catalog is unsigned"),
|
||||||
@@ -670,7 +672,11 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn verified_catalog_body_rejects_unsigned_cache() {
|
async fn verified_catalog_body_rejects_unsigned_cache() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
write_cache(dir.path(), r#"{"schema":1,"apps":{"demo":{"version":"1"}}}"#).unwrap();
|
write_cache(
|
||||||
|
dir.path(),
|
||||||
|
r#"{"schema":1,"apps":{"demo":{"version":"1"}}}"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
let err = verified_catalog_body(dir.path()).await.unwrap_err();
|
let err = verified_catalog_body(dir.path()).await.unwrap_err();
|
||||||
assert!(err.to_string().contains("unsigned"));
|
assert!(err.to_string().contains("unsigned"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user