rustypaste/fixtures
Andy Baird d0a67751dc
feat(server): add an endpoint for retrieving a list of files (#94)
* Start

* Wip

* Implement path based JSON index

* Remove json_index_path

* Return datetime stamp instead of relative time

* Add file size to list item

* Add auth check when retrieving JSON index

* Make json index path hardcoded

* Test (currently failing)

* Fix test for test_json_list

* Clippy fix

* Revert cargo to original versions with only needed changes

* Add detail about auth guard affecting list route

* Change json_index_path to expose_list

* Remove unneeded linebreak

* Remove unnecessary import

* Remove unnecessary space at end of line

* Move config check after auth check

* Use new auth check syntax, add docs to struct, rename test_json_list to test_list

* Replace chrono usage with uts2ts

* Check list result in test

* Add example to README

* Upgrade serde_json to 1.0.103

* Add linebreak

* Remove unneeded clone

* Remove extra nl

* Update README.md

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Remove serde_json

* Set default config to false for expose_list

* Apply suggestions from code review

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Check that option is value in test_list

* Update Cargo.toml

Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>

* Update cargo.lock

* Use expect() to check file name

* Remove underscore from list item struct

* Keep comma after last line

* refactor(server): rename ListItem fields

* test(fixtures): add fixture test for listing files

* test push

* remove file again

* chop off ts from filename and minor refactor

* update README

* docs(readme): fix capitalization

* refactor(server): clean up list implementation

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
2023-08-07 12:55:13 +02:00
..
test-duplicate-file-upload fix(fixtures): enable random URLs for duplicate file fixture 2022-05-21 17:52:14 +03:00
test-expiring-file-upload refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-file-upload feat(server): add random suffix mode (#69) 2023-07-01 00:11:16 +02:00
test-list-files feat(server): add an endpoint for retrieving a list of files (#94) 2023-08-07 12:55:13 +02:00
test-oneshot-upload refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-oneshot-url feat(server): support one shot URLs (#46) 2023-05-28 22:09:14 +02:00
test-path-traversal refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-random-suffix feat(server): add random suffix mode (#69) 2023-07-01 00:11:16 +02:00
test-random-url test(fixtures): add fixture test for random URL 2022-05-21 19:31:43 +03:00
test-remote-file-upload refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-server-auth refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-server-auth-multiple-tokens feat(server): support multiple auth tokens (#84) 2023-07-21 12:28:17 +02:00
test-server-auto-deletion test(fixtures): add fixture test for auto deletion 2022-05-21 18:23:21 +03:00
test-server-default-extension test(fixtures): add fixture test for default extension 2022-05-21 19:23:59 +03:00
test-server-landing-page refactor(config): use a separate section for the landing page (#65) 2023-06-23 17:20:24 +02:00
test-server-landing-page-file refactor(config): use a separate section for the landing page (#65) 2023-06-23 17:20:24 +02:00
test-server-mime-blacklist test(fixtures): add fixture test for MIME override 2022-05-21 19:12:09 +03:00
test-server-mime-override test(fixtures): add fixture test for MIME override 2022-05-21 19:12:09 +03:00
test-server-payload-limit feat(server): implement middleware for limiting the content length (#53) 2023-06-05 22:49:26 +03:00
test-url-upload refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
.env test(fixtures): add a test framework along with test fixtures 2022-05-21 15:27:38 +03:00
README.md refactor(fixtures): use subshell for running fixture methods 2022-05-21 16:51:06 +03:00
test-fixtures.sh refactor(fixtures): merge test steps in a single subshell 2022-05-21 17:52:47 +03:00

README.md

Fixtures

This directory contains the test fixtures and a simple testing framework for rustypaste.

Running fixtures

  1. Build the project in debug mode: cargo build
  2. Execute the runner script in this directory: ./test-fixtures.sh

Adding new fixtures

Create an appropriately named directory for the test fixture you want to add. e.g. test-file-upload

Each fixture directory should contain the following files:

test-file-upload/
├── config.toml
└── test.sh
  • config.toml: Contains the rustypaste configuration. See the default configuration.
  • test.sh: Contains the helper functions for testing. The file format is the following:
#!/usr/bin/env bash

setup() {
  # preparation
}

run_test() {
  # assertions
}

teardown() {
  # cleanup
}

These functions are executed in the order defined above.

See the test-file-upload fixture for an example.

Debugging

Set the DEBUG environment variable to true while executing the runner script:

$ DEBUG=true ./test-fixtures.sh