-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(other): add mailpit for email testing (local and e2e) #949
Conversation
3f1d4cf
to
1f172f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authentik/README.md
Outdated
echo -e "\n\nAUTHENTIK_EMAIL__HOST=$(hostname) | ||
AUTHENTIK_EMAIL__PORT=1025 | ||
AUTHENTIK_EMAIL__USE_TLS=false | ||
AUTHENTIK_EMAIL__USE_SSL=false | ||
AUTHENTIK_EMAIL__TIMEOUT=10 | ||
[email protected]" >> .env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authentic/.env
is not .gitignored. So I would suggest to check this directly into .env.
. Or specify it in docker-compose.test.yml
.
authentik/README.md
Outdated
```bash | ||
# in the authentik directory | ||
# get hostname and write e-mail environment variables to .env | ||
echo -e "\n\nAUTHENTIK_EMAIL__HOST=$(hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the motivation for the echo [...] >>
was to call hostname
I think it's fine to assume localhost
or to add a hint to change the hostname.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need to set the host machine's name instead of localhost
is required since both Authentik and Mailpit run in separate Docker containers (see goauthentik/authentik#9921 (comment))
|
||
```bash | ||
# in the authentik directory execute the email test | ||
docker compose exec worker ak test_email [email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get:
{"app_name": "authentik.enterprise.providers.microsoft_entra", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.microsoft_entra.signals", "pid": 245, "schema_name": "public", "timestamp": "2024-07-02T17:02:24.870470"}
{"app_name": "authentik.enterprise.providers.rac", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.rac.signals", "pid": 245, "schema_name": "public", "timestamp": "2024-07-02T17:02:24.874639"}
{"app_name": "authentik.events", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.events.tasks", "pid": 245, "schema_name": "public", "timestamp": "2024-07-02T17:02:24.874890"}
{"app_name": "authentik.events", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.events.signals", "pid": 245, "schema_name": "public", "timestamp": "2024-07-02T17:02:24.874966"}
Switching to schema 'public'
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/manage.py", line 52, in <module>
execute_from_command_line(sys.argv)
File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/authentik/tenants/management/__init__.py", line 38, in handle
self.handle_per_tenant(*args, **options)
File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/authentik/stages/email/management/commands/test_email.py", line 38, in handle_per_tenant
send_mail(message.__dict__, stage.pk)
File "/ak-root/venv/lib/python3.12/site-packages/celery/local.py", line 182, in __call__
return self._get_current_object()(*a, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/task.py", line 411, in __call__
return self.run(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/autoretry.py", line 60, in run
ret = task.retry(exc=exc, **retry_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/task.py", line 720, in retry
raise_with_context(exc or Retry('Task can be retried', None))
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/autoretry.py", line 38, in run
return task._orig_run(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/authentik/stages/email/tasks.py", line 105, in send_mail
raise exc
File "/authentik/stages/email/tasks.py", line 73, in send_mail
backend.open()
File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/backends/smtp.py", line 86, in open
self.connection = self.connection_class(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/smtplib.py", line 341, in connect
self.sock = self._get_socket(host, port, self.timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/smtplib.py", line 312, in _get_socket
return socket.create_connection((host, port), timeout,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/socket.py", line 852, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.12/socket.py", line 837, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you use localhost or your machine's name for the environment variable?
There is a reason the host machine's name is required.
authentik/README.md
Outdated
# in the browser see the Mailpit inbox | ||
<your_machine_name>:8025 | ||
# or | ||
localhost:8025 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# in the browser see the Mailpit inbox | |
<your_machine_name>:8025 | |
# or | |
localhost:8025 | |
\`\`\` | |
See Mailpit Inbox at <http://localhost:8025>. |
@@ -0,0 +1,8 @@ | |||
services: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about calling it docker-compose.override.yml
? This can be used by default in development
, no?
6bbe081
to
f1cfabf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍰 Pullrequest
Mailpit is added to test Authentik e-mails locally and in end-to-end tests.
How to test
Issues
Todo