2020-05-02 12:13:28 +02:00
|
|
|
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
|
|
|
|
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
|
|
|
|
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
|
|
|
|
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
|
|
|
|
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
|
|
|
|
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod passing {
|
2021-10-17 09:16:37 +02:00
|
|
|
use monolith::html;
|
2020-05-02 12:13:28 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_input_sha256() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"".as_bytes(),
|
|
|
|
"sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha256() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha256-9EWAHgy4mSYsm54hmDaIDXPKLRsLnBX7lZyQ6xISNOM="
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha384() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha384-gc9l7omltke8C33bedgh15E12M7RrAQa5t63Yb8APlpe7ZhiqV23+oqiulSJl3Kw"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha512() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha512-zG5B88cYMqcdiMi9gz0XkOFYw2BpjeYdn5V6+oFrMgSNjRpqL7EF8JEwl17ztZbK3N7I/tTwp3kxQbN1RgFBww=="
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ███████╗ █████╗ ██╗██╗ ██╗███╗ ██╗ ██████╗
|
|
|
|
// ██╔════╝██╔══██╗██║██║ ██║████╗ ██║██╔════╝
|
|
|
|
// █████╗ ███████║██║██║ ██║██╔██╗ ██║██║ ███╗
|
|
|
|
// ██╔══╝ ██╔══██║██║██║ ██║██║╚██╗██║██║ ██║
|
|
|
|
// ██║ ██║ ██║██║███████╗██║██║ ╚████║╚██████╔╝
|
|
|
|
// ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod failing {
|
2021-10-17 09:16:37 +02:00
|
|
|
use monolith::html;
|
2020-05-02 12:13:28 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_hash() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(!html::check_integrity("abcdef0123456789".as_bytes(), ""));
|
2020-05-02 12:13:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_input_empty_hash() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(!html::check_integrity("".as_bytes(), ""));
|
2020-05-02 12:13:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha256() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(!html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha256-badhash"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha384() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(!html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha384-badhash"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sha512() {
|
2020-11-23 06:12:26 +01:00
|
|
|
assert!(!html::check_integrity(
|
2020-05-02 12:13:28 +02:00
|
|
|
"abcdef0123456789".as_bytes(),
|
|
|
|
"sha512-badhash"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|