kellnr_web_ui/
lib.rs

1pub mod crate_access;
2pub mod error;
3pub mod group;
4pub mod session;
5pub mod ui;
6pub mod user;
7
8#[cfg(test)]
9mod test_helper {
10    use std::borrow::Cow;
11
12    use cookie::{Cookie, CookieJar};
13
14    pub(crate) const TEST_KEY: &[u8] = &[1; 64];
15
16    // there has to be a better way to set cookies, i really don't like importing cookie crate just to do this
17    pub(crate) fn encode_cookies<
18        const N: usize,
19        K: Into<Cow<'static, str>>,
20        V: Into<Cow<'static, str>>,
21    >(
22        cookies: [(K, V); N],
23    ) -> String {
24        let mut clear = CookieJar::new();
25        let mut jar = clear.private_mut(&TEST_KEY.try_into().unwrap());
26        for (k, v) in cookies {
27            jar.add(Cookie::new(k, v));
28        }
29        clear
30            .iter()
31            .map(|c| c.encoded().to_string())
32            .collect::<Vec<_>>()
33            .join("; ")
34    }
35}