exporting ECB

This commit is contained in:
Priec
2026-08-13 09:11:41 +02:00
parent f8e483efa8
commit fe8ea680e3
24 changed files with 895 additions and 1 deletions

View File

@@ -70,6 +70,13 @@ mod definitions {
}
}
pub(crate) mod ecb {
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../common/src/proto/komp_ac.ecb.rs"
));
}
use auth::auth_service_client::AuthServiceClient;
use definitions::{
table_definition::table_definition_client::TableDefinitionClient,
@@ -81,6 +88,7 @@ use definitions::{
use tonic::transport::Channel;
use analytics::analytics_service_client::AnalyticsServiceClient;
use ecb::ecb_service_client::EcbServiceClient;
const APP_CSS: &str = include_str!("../static/app.css");
@@ -95,6 +103,7 @@ pub(crate) struct AppState {
structures: TableStructureServiceClient<Channel>,
validations: TableValidationServiceClient<Channel>,
tables_data: TablesDataClient<Channel>,
ecb: EcbServiceClient<Channel>,
}
/// Starts the web UI as a detached task on the current Tokio runtime.
@@ -126,6 +135,7 @@ pub async fn serve() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
scripts: TableScriptClient::new(channel.clone()),
validations: TableValidationServiceClient::new(channel.clone()),
tables_data: TablesDataClient::new(channel.clone()),
ecb: EcbServiceClient::new(channel.clone()),
structures: TableStructureServiceClient::new(channel),
};
@@ -147,6 +157,7 @@ fn router(state: AppState) -> Router {
.merge(pages::admin::admin::router())
.merge(pages::permissions::router())
.merge(pages::admin::table_definition::router())
.merge(pages::admin::ecb::router())
.merge(pages::add_table::router())
.merge(pages::add_logic::router())
.merge(pages::add_validation::router())
@@ -189,6 +200,7 @@ mod tests {
scripts: TableScriptClient::new(channel.clone()),
validations: TableValidationServiceClient::new(channel.clone()),
tables_data: TablesDataClient::new(channel.clone()),
ecb: EcbServiceClient::new(channel.clone()),
structures: TableStructureServiceClient::new(channel),
})
}
@@ -334,6 +346,21 @@ mod tests {
}
}
/// The exchange-rate page is read-only and behind a session like every
/// other page, so an anonymous visitor is sent to the login page rather
/// than to the backend.
#[tokio::test]
async fn the_exchange_rate_pages_are_mounted_and_need_a_session() {
for path in ["/admin/ecb", "/admin/ecb/status"] {
let (status, _) = get(path).await;
assert_eq!(
status,
axum::http::StatusCode::SEE_OTHER,
"{path} did not send an anonymous visitor to the login page"
);
}
}
/// Permissions is a nav section of its own, so its three pages are mounted
/// at the top level rather than under /admin — and each of them, like every
/// other page behind a session, sends an anonymous visitor to the login