mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 20:09:48 -05:00
test(fixtures): add fixture test for MIME override
This commit is contained in:
parent
c06fff92ac
commit
5cdca1d9aa
3 changed files with 40 additions and 1 deletions
|
@ -16,6 +16,6 @@ run_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
rm file*
|
rm file.*
|
||||||
rm -r upload
|
rm -r upload
|
||||||
}
|
}
|
||||||
|
|
13
fixtures/test-server-mime-override/config.toml
Normal file
13
fixtures/test-server-mime-override/config.toml
Normal 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$" },
|
||||||
|
]
|
26
fixtures/test-server-mime-override/test.sh
Executable file
26
fixtures/test-server-mime-override/test.sh
Executable 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
|
||||||
|
}
|
Loading…
Reference in a new issue