test(fixtures): add fixture test for MIME blacklist

This commit is contained in:
Orhun Parmaksız 2022-05-21 18:47:41 +03:00
parent d262a3d297
commit c06fff92ac
No known key found for this signature in database
GPG Key ID: F83424824B3E4B90
2 changed files with 34 additions and 0 deletions

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_blacklist = [
"text/html",
"text/xml",
]

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
content="test data"
setup() {
echo "<html></html>" > file.html
echo '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' > file.xml
echo "$content" > file.txt
}
run_test() {
test "this file type is not permitted" = "$(curl -s -F "file=@file.html" localhost:8000)"
test "this file type is not permitted" = "$(curl -s -F "file=@file.xml" localhost:8000)"
file_url=$(curl -s -F "file=@file.txt" localhost:8000)
test "$content" = "$(curl -s $file_url)"
}
teardown() {
rm file*
rm -r upload
}