Skip to content

Commit

Permalink
test: add fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
DDtKey committed Dec 9, 2023
1 parent 9ec0593 commit e1f3ed3
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fixtures/test-list-files-not-exposed/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[server]
address = "127.0.0.1:8000"
max_content_length = "10MB"
upload_path = "./upload"
expose_list = false

[paste]
random_url = { type = "petname", words = 2, separator = "-" }
default_extension = "txt"
duplicate_files = true
15 changes: 15 additions & 0 deletions fixtures/test-list-files-not-exposed/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

setup() {
echo "$content" > file
}

run_test() {
result=$(curl -s --write-out "%{http_code}" http://localhost:8000/list)
test "404" = "$result"
}

teardown() {
rm file
rm -r upload
}
8 changes: 8 additions & 0 deletions fixtures/test-server-auth-tokens-unset/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[server]
address = "127.0.0.1:8000"
max_content_length = "10MB"
upload_path = "./upload"

[paste]
default_extension = "txt"
duplicate_files = false
20 changes: 20 additions & 0 deletions fixtures/test-server-auth-tokens-unset/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

content="test data"

setup() {
echo "$content" > file
}

run_test() {
file_url=$(curl -s -F "file=@file" localhost:8000)
test "$file_url" = "http://localhost:8000/file.txt"

result=$(curl -s --write-out "%{http_code}" -X DELETE http://localhost:8000/file.txt)
test "404" = "$result"
}

teardown() {
rm file
rm -r upload
}
8 changes: 8 additions & 0 deletions fixtures/test-server-delete-tokens-unset/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[server]
address = "127.0.0.1:8000"
max_content_length = "10MB"
upload_path = "./upload"

[paste]
default_extension = "txt"
duplicate_files = false
19 changes: 19 additions & 0 deletions fixtures/test-server-delete-tokens-unset/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

content="topsecret"

setup() {
echo "$content" > file
}

run_test() {
result=$(curl -s -F "file=@file" localhost:8000)
test "unauthorized" != "$result"
test "$content" = "$(cat upload/file.txt)"
test "$content" = "$(curl -s $result)"
}

teardown() {
rm file
rm -r upload
}
10 changes: 10 additions & 0 deletions fixtures/test-version-not-exposed/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[server]
address = "127.0.0.1:8000"
max_content_length = "10MB"
upload_path = "./upload"
expose_version = false

[paste]
random_url = { type = "petname", words = 2, separator = "-" }
default_extension = "txt"
duplicate_files = true
15 changes: 15 additions & 0 deletions fixtures/test-version-not-exposed/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

setup() {
echo "$content" > file
}

run_test() {
result=$(curl -s --write-out "%{http_code}" http://localhost:8000/version)
test "404" = "$result"
}

teardown() {
rm file
rm -r upload
}

0 comments on commit e1f3ed3

Please sign in to comment.