test(fixtures): add fixture test for MIME override

This commit is contained in:
Orhun Parmaksız 2022-05-21 19:12:09 +03:00
parent c06fff92ac
commit 5cdca1d9aa
No known key found for this signature in database
GPG Key ID: F83424824B3E4B90
3 changed files with 40 additions and 1 deletions

View File

@ -16,6 +16,6 @@ run_test() {
}
teardown() {
rm file*
rm file.*
rm -r upload
}

View File

@ -0,0 +1,13 @@
[server]
address="127.0.0.1:8000"
max_content_length="10MB"
upload_path="./upload"
[paste]
random_url = { enabled = true, type = "petname", words = 2, separator = "-" }
default_extension = "txt"
duplicate_files = true
mime_override = [
{ mime = "application/x-shockwave-flash", regex = "^.*\\.txt$" },
{ mime = "image/gif", regex = "^.*\\.tar$" },
]

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
content="test"
setup() {
for ext in "txt" "tar" "png"; do
echo "$content" > "file.$ext"
done
}
run_test() {
file_url=$(curl -s -F "file=@file.txt" localhost:8000)
test "application/x-shockwave-flash" = "$(curl -s --write-out %{content_type} $file_url | tail -n 1)"
file_url=$(curl -s -F "file=@file.tar" localhost:8000)
test "image/gif" = "$(curl -s --write-out %{content_type} $file_url | tail -n 1)"
file_url=$(curl -s -F "file=@file.png" localhost:8000)
test "image/png" = "$(curl -s --write-out %{content_type} $file_url | tail -n 1)"
test "$content" = "$(curl -s $file_url)"
}
teardown() {
rm file.*
rm -r upload
}