Skip to content

Commit

Permalink
feat(other): add mailpit for email testing (local and e2e) (#949)
Browse files Browse the repository at this point in the history
* add mailserver to docker.compose.yml

* move mailserver service entry to authentik docker.compose.yml

* add email configuration to .env

* move mailserver service to separate docker-compose.test.yml

* restore authentik .env

* remove redundant version element from docker compose files

* update authentik readme

* fix typo

* linting

* refactor: make use of docker-compose local DNS

---------

Co-authored-by: Robert Schäfer <[email protected]>
  • Loading branch information
mahula and roschaefer authored Jul 2, 2024
1 parent e9d9a99 commit 3002d71
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
23 changes: 23 additions & 0 deletions authentik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@ If you want to publish changes to the database you can use the following command

(Note: this assumes you are not root and sets the permissions of the database files via sudo)
(Note: make sure to shut down the database first before you run the script)

## E-Mail testing

Authentik e-mails can be checked locally via [Mailpit mailserver](https://mailpit.axllent.org/).

### Prepare and start

In the `authentik/` directory start authentik and mailserver:

```bash
docker-compose -f docker-compose.yml -f docker-compose.test.yml up
```

### Example

The given setup can be tested via [Authentik's e-mail testing tool](https://github.com/goauthentik/authentik/blob/main/authentik/stages/email/management/commands/test_email.py)

Send a test email with:
```bash
docker compose exec worker ak test_email [email protected]
```

Visit [Mailpit](http://localhost:8025) and see your test email.
22 changes: 22 additions & 0 deletions authentik/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
x-mail-settings: &x-mail-settings
environment:
- AUTHENTIK_EMAIL__HOST=mailserver
- AUTHENTIK_EMAIL__PORT=1025
- AUTHENTIK_EMAIL__USE_TLS=false
- AUTHENTIK_EMAIL__USE_SSL=false
- AUTHENTIK_EMAIL__TIMEOUT=10
- [email protected]

services:
mailserver:
image: axllent/mailpit
container_name: mailpit
restart: unless-stopped
ports:
- 8025:8025
- 1025:1025

server:
<<: *x-mail-settings
worker:
<<: *x-mail-settings
2 changes: 0 additions & 2 deletions authentik/docker-compose.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.4"

services:
postgresql:
image: docker.io/library/postgres:12-alpine
Expand Down

0 comments on commit 3002d71

Please sign in to comment.