From 341113502dc2e9e0a7d623130d325035b36cbc7b Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 23 Apr 2020 08:31:57 +0200 Subject: [PATCH] refactor integration test files --- .dockerignore | 2 +- .github/workflows/docker.yml | 2 +- .github/workflows/integration-test.yml | 2 +- .gitignore | 1 - src/api/login.js | 3 +- src/api/minetest/channel.js | 3 ++ test/.gitignore | 1 + .../integration-test.sh | 35 ++++++------------ test/minetest.conf | 3 ++ test/players.sqlite | Bin 0 -> 36864 bytes test/players.txt | 4 ++ {test_mod => test/test_mod}/init.lua | 2 +- {test_mod => test/test_mod}/mod.conf | 0 13 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 test/.gitignore rename integration-test.sh => test/integration-test.sh (50%) create mode 100644 test/minetest.conf create mode 100644 test/players.sqlite create mode 100644 test/players.txt rename {test_mod => test/test_mod}/init.lua (77%) rename {test_mod => test/test_mod}/mod.conf (100%) diff --git a/.dockerignore b/.dockerignore index be8f172..82b6bcc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ node_modules test_mod mail_mod -integration-test.sh +test diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2504f93..f947446 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@master - name: integration-test - run: ./integration-test.sh + run: ./test/integration-test.sh - name: docker publish uses: elgohr/Publish-Docker-Github-Action@master diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index dc9085f..c9dd6f5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -12,4 +12,4 @@ jobs: - uses: actions/checkout@master - name: integration-test - run: ./integration-test.sh + run: ./test/integration-test.sh diff --git a/.gitignore b/.gitignore index d3ab352..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules -mail_mod diff --git a/src/api/login.js b/src/api/login.js index 29bd36c..f2434cb 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -31,7 +31,8 @@ app.post('/api/login', jsonParser, function(req, res){ token: t }); }) - .catch(() => { + .catch(e => { + console.error(e); res.status(500).end(); }); diff --git a/src/api/minetest/channel.js b/src/api/minetest/channel.js index f6165f3..cfd2148 100644 --- a/src/api/minetest/channel.js +++ b/src/api/minetest/channel.js @@ -21,6 +21,9 @@ app.get('/api/minetest/channel', function(req, res){ return; } + if (debug) + console.log("[tx-channel-entry]"); + function trySend(){ if (tx_queue.length > 0){ var obj = tx_queue.shift(); diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..9bdff19 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +mail_mod diff --git a/integration-test.sh b/test/integration-test.sh similarity index 50% rename from integration-test.sh rename to test/integration-test.sh index e4f941f..8a7f9de 100755 --- a/integration-test.sh +++ b/test/integration-test.sh @@ -1,5 +1,8 @@ #!/bin/bash +CWD=$(dirname $0) +cd ${CWD} + # setup unset use_proxy unset http_proxy @@ -8,7 +11,7 @@ unset HTTP_PROXY unset HTTPS_PROXY # build -docker build . -t mail +docker build .. -t mail # run mail-server docker run --name mail --rm \ @@ -23,26 +26,13 @@ bash -c 'while ! ${CFG} - secure.http_mods = mail - webmail.url = 127.0.0.1:8080 - webmail.key = myserverkey -EOF - -mkdir -p ${WORLDDIR} -chmod 777 ${MTDIR} -R - # start minetest with mail mod docker run --rm --name minetest \ - -v ${CFG}:/etc/minetest/minetest.conf:ro \ - -v ${MTDIR}:/var/lib/minetest/.minetest \ - -v $(pwd)/mail_mod:/var/lib/minetest/.minetest/worlds/world/worldmods/mail \ - -v $(pwd)/test_mod:/var/lib/minetest/.minetest/worlds/world/worldmods/mail_test \ + -u root:root \ + -v $(pwd)/minetest.conf:/etc/minetest/minetest.conf:ro \ + -v $(pwd)/players.sqlite:/root/.minetest/worlds/world/players.sqlite \ + -v $(pwd)/mail_mod:/root/.minetest/worlds/world/worldmods/mail \ + -v $(pwd)/test_mod:/root/.minetest/worlds/world/worldmods/mail_test \ -e use_proxy=false \ -e http_proxy= \ -e HTTP_PROXY= \ @@ -59,12 +49,11 @@ function cleanup { trap cleanup EXIT # wait for startup -sleep 10 +sleep 2 # Execute calls agains mail-server -# https://jwt.io/ -TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiJkc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.7ik564LuatEhOFapNWIqSlYcST41cgmHGAuTnAowTu8" -curl -v -H "Authorization: ${TOKEN}" "http://127.0.0.1:8080/api/inbox" +LOGIN_DATA='{"username":"test","password":"enter"}' +curl -v --data "${LOGIN_DATA}" -H "Content-Type: application/json" "http://127.0.0.1:8080/api/login" echo "Test complete!" diff --git a/test/minetest.conf b/test/minetest.conf new file mode 100644 index 0000000..b6f114d --- /dev/null +++ b/test/minetest.conf @@ -0,0 +1,3 @@ +secure.http_mods = mail +webmail.url = 127.0.0.1:8080 +webmail.key = myserverkey diff --git a/test/players.sqlite b/test/players.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..6a5ffabb416858c134db4fda37d3e0d7fc431ace GIT binary patch literal 36864 zcmeI4d2Ae49mjWPc4lYZ>1(}SpVKBz?AS@Yb}pxJoXuvFIKGng+HKN5yqjdxuJDDu zNgBjal7d7L?SHLk|D%Y4kT}zSKoqq|ATN{(Rq?Yd^m?lg!L|XO2&l%0=hw^6Fxt>|zvF~LAxpe$@v2S{0q(0h zg{!d6Z!5ITI6(Q^AvdcrSrw5^787%dGQ~*#kJb4RyvzW+J0pyLD(fn;APi<<95y z_-`QJ>tr*BGTF>jIy2*VON-8>!eUW$O;3ppO=QHoPN!zlse>7(cib}L^TXj#Y3WSy z;kEZJh@G1+oGUL^@_cP8^U2!n_N6f+8c!y}kB-zTN2z#oDMX98ZW+W3|5XWGZ5K*s z$`9RA9Ji-pWt~D)3cFT%U-9Op|8<4ly~3nTGk#z4-z<#qbW2f0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ow{?Sp-nKyS0i zF=GDs=t5lqccRXKJ5Wc!?WjHAHq;hyD{2imff50?pq7B+C?0S#Y7RJtVgWayrhpq! zW55llA>evcA8;M23z#DwFheY0ifF(Dk$^G60V9M0wvipMg{*+1C>pSd%zzDK1T3!i z1J;oqux4w5efwd7zI}1ln8UAx_*?up{OA0K{5$;X{EPfq{uKW>{}5l}5Ap~2G*9zg zypMPBMjmB-o>>9huzRAAIo@39jC)j27Fk55=Hp|A?2ureVmSB{H>6`R*`YQcC zeThC#KTDsXkJAs+GJTMqq?2?%9ip3Pf)er%@(1!u@)L5Eyg^%~ zN5;uMk|Y~RoFM!+{5$-b*jbps02lxRU;qq&0WbgtzyKIf3=sE{-+x*-rvzat&*esKlr4;8&nvbIIA zKTxb*$yMDTUG#S0E-{BcKDr#qon4YUIwiMvNN#JF z+}b8N(JHwmAvxY6xj8O5)-1UxCb_Xmazmr!`Uc5$^^$p=WX2^^CYeylm`FxgvhCd$ ms2od{E!(4(WHTz+FeOI}$$CVxrn~nS{Kx<9?FH}o|33lOjbB{= literal 0 HcmV?d00001 diff --git a/test/players.txt b/test/players.txt new file mode 100644 index 0000000..9c8c6d1 --- /dev/null +++ b/test/players.txt @@ -0,0 +1,4 @@ +User,Password +----------------- +test,enter +test2,enter diff --git a/test_mod/init.lua b/test/test_mod/init.lua similarity index 77% rename from test_mod/init.lua rename to test/test_mod/init.lua index 6fa34a3..9b32eed 100644 --- a/test_mod/init.lua +++ b/test/test_mod/init.lua @@ -3,5 +3,5 @@ minetest.log("warning", "[TEST] integration-test enabled!") minetest.register_on_mods_loaded(function() minetest.log("warning", "[TEST] starting tests") - mail.send("src", "dst", "subject", "body"); + -- mail.send("src", "dst", "subject", "body"); end) diff --git a/test_mod/mod.conf b/test/test_mod/mod.conf similarity index 100% rename from test_mod/mod.conf rename to test/test_mod/mod.conf