From 6e821c6ee987728b28a6734a66e32ebed9e61279 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Thu, 14 Jan 2021 00:27:26 +0100 Subject: [PATCH] test env seems to work --- adminer/index.js | 8 +------- server/main.py | 12 +++++++++--- test/docker-compose.yml | 9 +++++---- test/{test.html => index.html} | 7 +++++-- test/nginx.conf | 8 ++------ test/test_env.sh | 5 ----- 6 files changed, 22 insertions(+), 27 deletions(-) rename test/{test.html => index.html} (81%) delete mode 100755 test/test_env.sh diff --git a/adminer/index.js b/adminer/index.js index bb0686d..fa70d9f 100644 --- a/adminer/index.js +++ b/adminer/index.js @@ -46,10 +46,7 @@ var app = new Vue({ }) .then(response => response.json()) .then(data => { - if (data.status != 'success') - console.error('getForms error: '+data.msg) - else - this.forms = data.data + this.forms = data.data }) .catch((error) => { console.error(error) @@ -62,9 +59,6 @@ var app = new Vue({ }) .then(response => response.json()) .then(data => { - if (data.status != 'success') - console.error('getForms error: '+data.msg) - else this.users = data.data }) .catch((error) => { diff --git a/server/main.py b/server/main.py index da2e42f..3d0583c 100755 --- a/server/main.py +++ b/server/main.py @@ -75,6 +75,9 @@ mongodb_dbname = get_env('MONGODB_DBNAME', 'contact_mailer') # Security admin_password = get_env('ADMIN_PASSWORD') +# Test purpose, do not send mail +do_not_send = get_env('do_not_send', 'false') == 'true' + if 'SMTP_SSL' in os.environ and os.environ['SMTP_SSL'] == 'true': security = 'ssl' elif 'SMTP_STARTTLS' in os.environ and os.onviron['SMTP_STARTTLS'] == 'true': @@ -189,6 +192,11 @@ def send_mail (from_address, to, subject, content): msg.set_content(MIMEText(content, 'plain', "utf-8")) #or #msg.set_content(content) + if do_not_send: + print('------------------------------------ Following message wont be sent ------------------------------------') + print(msg.as_string()) + print('--------------------------------------------------------------------------------------------------------') + return True # SMTP preambles if security == 'ssl': @@ -254,11 +262,9 @@ def create_form (): if 'mail' in request.forms: mail = request.forms.getunicode('mail') else: - return resp(4000, 'Le champs « adresse » est requis') + return resp(400, 'Le champs « adresse » est requis') user = login(request) - print('post form') - print(user) if user['_privilege'] > 1: return resp(400, 'Privilèges insufisants') diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 7923003..e1900f5 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -12,15 +12,16 @@ services: - db environment: MONGODB_HOST: db - SMTP_SERVER_ADDRESS: 'lol' + SMTP_SERVER_ADDRESS: toto.mail SMTP_SERVER_PORT: 994 - SMTP_SERVER_USERNAME: toto - SMTP_SERVER_PASSWORD: lol - SMTP_SERVER_SENDER: moi + SMTP_SERVER_USERNAME: toto@toto.mail + SMTP_SERVER_PASSWORD: password + SMTP_SERVER_SENDER: toto@toto.mail ADMIN_PASSWORD: test SMTP_SSL: 'true' UID: 101 MOUNT: /api + do_not_send: 'true' proxy: diff --git a/test/test.html b/test/index.html similarity index 81% rename from test/test.html rename to test/index.html index 7d98958..dfea6c3 100644 --- a/test/test.html +++ b/test/index.html @@ -8,7 +8,10 @@
- +
+ + +
@@ -31,6 +34,6 @@
- + diff --git a/test/nginx.conf b/test/nginx.conf index 77972fe..306d684 100644 --- a/test/nginx.conf +++ b/test/nginx.conf @@ -23,13 +23,9 @@ http { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, OPTIONS'; listen 8080; - location /admin { - alias /usr/app/adminer; - index index.html; - } location / { - root /usr/app/test; - index test.html; + root /usr/app/; + index index.html; } location /api/ { include uwsgi_params; diff --git a/test/test_env.sh b/test/test_env.sh deleted file mode 100755 index 4c524a6..0000000 --- a/test/test_env.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# docker run -it --rm --network host mongo -# nginx -c "$(pwd)"/nginx.conf -g "pid '$(pwd)/nginx.pid';" -# . venv/bin/activate ; python3 main.py