Commit 012875c9 authored by Barbora Kompišová's avatar Barbora Kompišová
Browse files

mailhog, API continue

parent 547d1d7b
Loading
Loading
Loading
Loading
Loading

docs/mailhog.adoc

0 → 100644
+112 −0
Original line number Diff line number Diff line
= MailHog

MailHog is an email testing tool for developers.


== Installation

Foolow the official guide: link:https://github.com/mailhog/MailHog[Repository page].

The preffered way to configure Mailhog is to use the docker image.


== Use the Mailhog using Docker

In order to run the docker image you need `docker`.


=== Docker installation on Debian

*Guide:* link:https://docs.docker.com/install/linux/docker-ce/debian/ [Docker Installation]

Install required packages in order to add a custom docker repository and key.

[source, bash]
----
sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
----

Add Docker’s official GPG key:
[source, bash]
----
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
----

Add the repository:

[source, bash]
----
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"
----


Install Docker:
[source, bash]
----
sudo apt-get update && sudo apt-get install docker-ce
----

Add current user to the docker group, to be able to run the docker command without sudo.

[source, bash]
----
sudo usermod -aG docker $USER
newgrp docker                   # start new shell with loaded docker group
----



=== Docker image setup

How to download and setup Mailhog using a docker container.

Pull Mailhog from link:https://hub.docker.com/r/mailhog/mailhog/[DockerHub]

[source, bash]
----
docker pull mailhog/mailhog
----

The container will expose 2 ports:
- `1025` - for SMTP
- `8025` - for the web UI

Start the Mailhog container:

[source, bash]
----
docker run -d \ 
           --restart unless-stopped \
           --name mailhog \
           -p 1025:1025 \
           -p 8025:8025 \
           mailhog/mailhog
----


== Integration to the backend

In order to set emails backend for the project you need to modify `portal.local.cfg`.
You need to change these variables:
[source, python]
----
EMAIL_BACKEND = 'emails.backend.SMTPBackend'
EMAIL_HOST = "<hostname>"       # Where your mailhog is running (localhost)
EMAIL_PORT = "1025"             # SMTP port
EMAIL_DEFAULT_FROM = "kontr@example.com" # Default from email address
----






+428 −46

File changed.

Preview size limit exceeded, changes collapsed.

+2 −12
Original line number Diff line number Diff line
@@ -120,14 +120,6 @@ class SubmissionSourceFiles(Resource):
        pass


class SubmissionResultFiles(Resource):
    @error_handler
    @jwt_required
    def get(self, sid):
        client = auth.find_client()
        pass


class SubmissionTestFiles(Resource):
    @error_handler
    @jwt_required
@@ -136,7 +128,7 @@ class SubmissionTestFiles(Resource):
        pass


class SubmissionSources(Resource):
class SubmissionResultFiles(Resource):
    @error_handler
    @jwt_required
    def get(self, sid):
@@ -213,9 +205,7 @@ submissions_api.add_resource(SubmissionResubmit, '/<string:sid>/resubmit')

submissions_api.add_resource(SubmissionFiles, '/<string:sid>/files')
submissions_api.add_resource(SubmissionSourceFiles, '/<string:sid>/files/sources')
submissions_api.add_resource(SubmissionTestFiles, '/<string:sid>/files/test_files')
submissions_api.add_resource(SubmissionResultFiles, '/<string:sid>/files/results')

submissions_api.add_resource(SubmissionTestFiles, '/<string:sid>/test_files')
submissions_api.add_resource(SubmissionSources, '/<string:sid>/sources')

submissions_api.add_resource(SubmissionReview, '/<string:sid>/review')