Commit Graph

7 Commits

Author SHA1 Message Date
e1da535dc2 meilisearch: Trim whitespace from token
When reading the Meilisearch token from the file specified in the
configuration, we need to ensure any whitespace are trimmed from the
string.  If the token file was created with a text editor, or even a
shell pipeline, it's likely to have a trailing newline character.  If we
do not remove this, authenticated requests to Meilisearch will fail.
2025-04-05 17:08:51 -05:00
c227bec62d run-tests: Add harness for integration tests
The `run-tests.sh` script sets up a full environment for the integration
tests.  This includes starting Meilisearch (with a master key to enable
authentication) and generating an ephemeral JWT secret.  After the tests
are run, the environment is cleaned up.

```sh
just test

just unit-tests

just integration-tests
```
2025-04-05 17:08:49 -05:00
76cf57ebe0 Begin integration tests
Refactoring the code a bit here to make the `Rocket` instance available
to the integration tests.  To do this, we have to convert to a library
crate (`lib.rs`) with an executable entry point (`main.rs`).  This
allows the tests, which are separate crates, to import types and
functions from the library.

Besides splitting the `rocket` function into two parts (one in `lib.rs`
that creates the `Rocket<Build>` and another in `main.rs` that becomes
the process entry point), I have reworked the initialization process to
make better use of Rocket's "fairings" feature.  We don't want to call
`process::exit()` in a test, so if there is a problem reading the
configuration or initializing the context, we need to report it to
Rocket instead.
2025-04-05 17:07:39 -05:00
720bb690ea auth: Initial JWT implementation
We'll use a JWT in the `Authorization` request header to identify the
user saving a page.  The token will need to be set in the _authorization
token_ field in the SingleFile configuration so it will be included when
uploading.
2025-04-05 17:07:39 -05:00
a1308507af main: Add better config/init error messages
The default messages printed when the process panics because the
configuration could not be loaded or the application context could not
be initialized are somewhat difficult to read.  Instead of calling
`unwrap` in these cases, we need to explicitly handle the errors and
print more appropriate messages.
2025-04-05 17:07:19 -05:00
df560b18f2 page: Instrument save_page function
Adding a span and event to track indexing time.
2025-04-05 17:07:19 -05:00
03fe19aa9b Initial commit 2025-04-05 17:07:19 -05:00