From c06fff92aca43ca0a6ba12106bcae938e9c94947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 21 May 2022 18:47:41 +0300 Subject: [PATCH] test(fixtures): add fixture test for MIME blacklist --- .../test-server-mime-blacklist/config.toml | 13 ++++++++++++ fixtures/test-server-mime-blacklist/test.sh | 21 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 fixtures/test-server-mime-blacklist/config.toml create mode 100755 fixtures/test-server-mime-blacklist/test.sh diff --git a/fixtures/test-server-mime-blacklist/config.toml b/fixtures/test-server-mime-blacklist/config.toml new file mode 100644 index 0000000..44a5297 --- /dev/null +++ b/fixtures/test-server-mime-blacklist/config.toml @@ -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", +] diff --git a/fixtures/test-server-mime-blacklist/test.sh b/fixtures/test-server-mime-blacklist/test.sh new file mode 100755 index 0000000..2c616ab --- /dev/null +++ b/fixtures/test-server-mime-blacklist/test.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +content="test data" + +setup() { + echo "" > file.html + echo '' > 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 +}