use super::*;
fn realm(prefix: &str) -> Arc<Realm> {
Arc::new(Realm {
prefix: prefix.to_owned(),
auth: crate::Auth::disabled().into_config(),
login_hint: None,
time_zone: jiff::tz::TimeZone::UTC,
catalog: std::sync::Arc::new(
crate::i18n::Catalog::new(std::slice::from_ref(&crate::i18n::ENGLISH), &[])
.expect("`en` builds"),
),
notifications: false,
serves_tenants: false,
pages: SettingsPaths::under(prefix),
audit_log: false,
})
}
#[test]
fn panel_prefix_prefers_the_realm_over_the_request_path() {
use topcoat::context::Cx;
let parts = || {
http::Request::builder()
.uri("/admin/users/42/edit")
.body(())
.unwrap()
.into_parts()
.0
};
let cx = Cx::default()
.with(parts())
.with(CurrentRealm(realm("/backoffice")));
assert_eq!(panel_prefix(&cx), "/backoffice");
let cx = Cx::default().with(parts());
assert_eq!(panel_prefix(&cx), "/admin");
}