forked from mailpile/Mailpile
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created docker-based blackbox test script for context/grant and remot…
…e access
- Loading branch information
1 parent
b88a051
commit 8594f5f
Showing
4 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM ubuntu:devel | ||
MAINTAINER Bjarni R. Einarsson <[email protected]> | ||
|
||
RUN apt-get update \ | ||
&& apt install -y git curl vim \ | ||
python3-cryptography \ | ||
python3-urwid \ | ||
python3-websockets \ | ||
python3-numpy \ | ||
python3-appdirs \ | ||
python3-setproctitle | ||
|
||
RUN curl 'https://lists.apache.org/api/[email protected]&date=2022-01' \ | ||
>/root/test.mbx | ||
|
||
VOLUME /mnt/code | ||
WORKDIR /root | ||
CMD /mnt/code/tools/docker-internal.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
# | ||
# This script runs inside a Docker container that has Moggie's reuirements | ||
# installed, the git workspace mounted at /mnt/code, and some test e-mails | ||
# downloaded to /root/test.mbx. | ||
# | ||
# It currently tests the following things: | ||
# | ||
# - Launching moggie as a background process | ||
# - Importing mail | ||
# - Creating a context with an isolating namespace | ||
# - Granting HTTP-based remote access | ||
# - Using lots/curl to fetch and count search results | ||
# - Verify that context namespacing and search scoping correctly | ||
# excludes results that should not be exposed. | ||
# | ||
export PATH=$PATH:/mnt/code/tools | ||
|
||
#cd /root | ||
#mkdir -p .local/share/Moggie/default | ||
#cat <<tac >.local/share/Moggie/default/config.rc | ||
#[App] | ||
#port=32025 | ||
#tac | ||
|
||
cd /mnt/code | ||
|
||
python3 -m moggie start | ||
python3 -m moggie import /root/test.mbx | ||
|
||
python3 -m moggie context create Testspace --tag-namespace=Testspace | ||
python3 -m moggie grant create Tester user --context=Testspace | ||
python3 -m moggie grant login Tester --output=urls | ||
TESTER_URL=$(python3 -m moggie grant list Tester --output=urls |grep http: |cut -b40-) | ||
|
||
while [ $(lots count in:incoming) -gt 0 ]; do | ||
echo "Waiting for importer... $(lots count in:incoming) incoming still" | ||
sleep 1 | ||
done | ||
echo | ||
lots search gitbox | ||
echo | ||
|
||
TOTAL=$(lots count gitbox) | ||
[ $TOTAL -gt 0 ] && echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Have $TOTAL hits for gitbox" | ||
|
||
PRETAG=$(curl -s "$TESTER_URL/cli/count/gitbox?format=text") | ||
[ $PRETAG = 0 ] && echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Tester sees $PRETAG hits for gitbox, before tagging." | ||
|
||
lots tag +in:@testspace -- gitbox >/dev/null \ | ||
&& echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Tagged gitbox hits into namespace 'testspace'" | ||
|
||
POSTTAG=$(curl -s "$TESTER_URL/cli/count/gitbox?format=text") | ||
[ $POSTTAG = $TOTAL ] && echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Tester sees $POSTTAG hits for gitbox, after tagging." | ||
|
||
python3 -m moggie context update Testspace --forbid=superusers --output=scope >/dev/null \ | ||
&& echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Forbidding 'superusers' results in Testspace..." | ||
|
||
POSTFB=$(curl -s "$TESTER_URL/cli/count/gitbox?format=text") | ||
[ $POSTFB -lt $POSTTAG ] && echo -ne 'OK\t' || echo -n 'FAIL\t' | ||
echo "Tester sees $POSTFB hits for gitbox, after forbidding." | ||
|
||
echo | ||
python3 -m moggie stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# | ||
# Launch and run `docker-internal.sh` in a pristine test environment. | ||
# See comments in the internal script for details. | ||
# | ||
WORKDIR=$(cd $(dirname $0)/.. && pwd) | ||
docker build -t moggie-test -f $WORKDIR/tools/Dockerfile_tests . | ||
docker run --rm --volume $WORKDIR:/mnt/code moggie-test |