Compare commits
No commits in common. "da581f452df9d14b59f1b52ecd9ce5477da020ea" and "734602244d272ba2bb8dd97a6882d7145e3d701f" have entirely different histories.
da581f452d
...
734602244d
|
@ -1,8 +1,8 @@
|
|||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||
# TODO: https://stackoverflow.com/questions/57389547/how-to-define-the-context-for-a-docker-build-as-a-specific-commit-on-one-of-the
|
||||
|
||||
# rust:1.60-slim-buster
|
||||
FROM rust@sha256:c0f26a0b299a8a74cd87be0b4bd291d55aa292198bab1bafd906edd8665edb82 as build
|
||||
# rust:1.50-slim-buster
|
||||
FROM rust@sha256:5dd85eb0c60bbdea14a6ecba1f6fe4a0f5c878bcf06d2cdfae0aff3a19ed4b10 as build
|
||||
|
||||
WORKDIR /
|
||||
ENV USER root
|
||||
|
|
|
@ -143,7 +143,6 @@ pub mod file {
|
|||
pub scraper_keys: Option <Vec <ScraperKey>>,
|
||||
|
||||
pub news_url: Option <String>,
|
||||
pub hide_audit_log: Option <bool>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +156,6 @@ pub struct Config {
|
|||
pub servers: HashMap <String, file::Server>,
|
||||
pub scraper_keys: HashMap <String, ScraperKey>,
|
||||
pub news_url: Option <String>,
|
||||
pub hide_audit_log: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
|
@ -169,7 +167,6 @@ impl Default for Config {
|
|||
servers: Default::default (),
|
||||
scraper_keys: Default::default (),
|
||||
news_url: None,
|
||||
hide_audit_log: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +195,6 @@ impl TryFrom <file::Config> for Config {
|
|||
servers,
|
||||
scraper_keys,
|
||||
news_url: f.news_url,
|
||||
hide_audit_log: f.hide_audit_log.unwrap_or (false),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -433,13 +433,6 @@ async fn handle_audit_log (
|
|||
handlebars: Arc <Handlebars <'static>>
|
||||
) -> Result <Response <Body>, RequestError>
|
||||
{
|
||||
{
|
||||
let cfg = state.config.read ().await;
|
||||
if cfg.hide_audit_log {
|
||||
return Ok (error_reply (StatusCode::FORBIDDEN, "Forbidden")?);
|
||||
}
|
||||
}
|
||||
|
||||
let page = handle_audit_log_internal (state).await;
|
||||
|
||||
let s = handlebars.render ("audit_log", &page)?;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -67,25 +67,29 @@ fn file_server () {
|
|||
let rt = Runtime::new ().expect ("Can't create runtime");
|
||||
|
||||
rt.block_on (async {
|
||||
let files_root = PathBuf::from ("./");
|
||||
let dirs_roots = Default::default ();
|
||||
|
||||
let file_server_root = internal::FileRoots {
|
||||
files: &files_root,
|
||||
dirs: &dirs_roots,
|
||||
};
|
||||
let file_server_root = PathBuf::from ("./");
|
||||
let headers = Default::default ();
|
||||
|
||||
{
|
||||
use internal::Response::*;
|
||||
use crate::file_server::FileServerError;
|
||||
|
||||
let bad_passwords_path = "/files/src/bad_passwords.txt";
|
||||
|
||||
for (uri_path, expected) in vec! [
|
||||
("/", Root),
|
||||
("/files", NotFound),
|
||||
("/files/?", InvalidQuery),
|
||||
("/files/src", Redirect ("src/".to_string ())),
|
||||
("/files/src/?", InvalidQuery),
|
||||
(bad_passwords_path, ServeFile (internal::ServeFileParams {
|
||||
send_body: true,
|
||||
range: range::ValidParsed {
|
||||
range: 0..1_048_576,
|
||||
range_requested: false,
|
||||
},
|
||||
file: AlwaysEqual::testing_blank (),
|
||||
})),
|
||||
("/files/test/test.md", ServeFile (internal::ServeFileParams {
|
||||
send_body: true,
|
||||
range: range::ValidParsed {
|
||||
|
@ -96,7 +100,7 @@ fn file_server () {
|
|||
})),
|
||||
] {
|
||||
let resp = internal::serve_all (
|
||||
file_server_root,
|
||||
&file_server_root,
|
||||
Method::Get,
|
||||
uri_path,
|
||||
&headers,
|
||||
|
@ -113,7 +117,7 @@ fn file_server () {
|
|||
}),
|
||||
] {
|
||||
let resp = internal::serve_all (
|
||||
file_server_root,
|
||||
&file_server_root,
|
||||
Method::Get,
|
||||
uri_path,
|
||||
&headers,
|
||||
|
@ -122,6 +126,35 @@ fn file_server () {
|
|||
|
||||
checker (resp.unwrap_err ());
|
||||
}
|
||||
|
||||
let resp = internal::serve_all (
|
||||
&file_server_root,
|
||||
Method::Get,
|
||||
bad_passwords_path,
|
||||
&hashmap! {
|
||||
"range".into () => b"bytes=0-2000000".to_vec (),
|
||||
},
|
||||
None
|
||||
).await;
|
||||
|
||||
assert_eq! (resp.expect ("Should be Ok (_)"), RangeNotSatisfiable (1_048_576));
|
||||
|
||||
let resp = internal::serve_all (
|
||||
&file_server_root,
|
||||
Method::Head,
|
||||
bad_passwords_path,
|
||||
&headers,
|
||||
None
|
||||
).await;
|
||||
|
||||
assert_eq! (resp.expect ("Should be Ok (_)"), ServeFile (internal::ServeFileParams {
|
||||
send_body: false,
|
||||
range: range::ValidParsed {
|
||||
range: 0..1_048_576,
|
||||
range_requested: false,
|
||||
},
|
||||
file: AlwaysEqual::testing_blank (),
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ impl TestingServer {
|
|||
let (stop_tx, stop_rx) = oneshot::channel ();
|
||||
let task = {
|
||||
spawn (async move {
|
||||
ptth_server::run_server (config_file, stop_rx, None, None, None).await
|
||||
ptth_server::run_server (config_file, stop_rx, None, None).await
|
||||
})
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue