test: add shared api client tests and remove dead backend code

This commit is contained in:
2026-09-06 22:46:40 +02:00
parent c78845ca7a
commit 4f5f829c81
5 changed files with 77 additions and 25 deletions
-16
View File
@@ -1,16 +0,0 @@
use axum::{body::Body, extract::Request, http::HeaderValue, middleware::Next, response::Response};
const CUSTOM_HEADER_NAME: &str = "Content-Security-Policy";
const CUSTOM_HEADER_VALUE: &str = "default-src 'self'; script-src 'report-sample' 'self'; style-src 'report-sample' 'self'; object-src 'none'; base-uri 'self'; connect-src 'self' data:; font-src 'self'; frame-src 'self'; img-src 'self'; manifest-src 'self'; media-src 'self'; worker-src 'none';";
lazy_static! {
static ref HEADER_VALUE: HeaderValue = HeaderValue::from_static(CUSTOM_HEADER_VALUE);
}
pub async fn add_csp_header(request: Request<Body>, next: Next) -> Response {
let mut response = next.run(request).await;
response
.headers_mut()
.append(CUSTOM_HEADER_NAME, HEADER_VALUE.clone());
response
}
-1
View File
@@ -15,7 +15,6 @@ use tower_http::{
extern crate lazy_static;
mod config;
mod csp;
mod health;
mod note;
mod status;
-7
View File
@@ -68,13 +68,6 @@ pub fn get_data(id: &str) -> Result<Option<Vec<u8>>, &'static str> {
Ok(data)
}
pub fn has_views(id: &str) -> Result<bool, &'static str> {
let key = prefixed(id);
let mut c = conn()?;
let has: bool = c.hexists::<_, _, bool>(&key, "views").map_err(|_| "Cache error")?;
Ok(has)
}
pub fn decrement_views(id: &str) -> Result<i64, &'static str> {
let key = prefixed(id);
let mut c = conn()?;