summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rwxr-xr-xtests/e2e/check_ip45
-rwxr-xr-xtests/e2e/e2e-test-mail.sh (renamed from tests/e2e/e2e-test.sh)0
-rwxr-xr-xtests/e2e/e2e-test-vpn.sh50
4 files changed, 100 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 323dcc52..1ee8b1f6 100644
--- a/Makefile
+++ b/Makefile
@@ -38,8 +38,12 @@ dev-latest-all: dev-all
uninstall:
pip uninstall leap.bitmask
+test:
+ tox
+
test_e2e:
- tests/e2e/e2e-test.sh
+ tests/e2e/e2e-test-mail.sh
+ tests/e2e/e2e-test-vpn.sh
qt-resources:
pyrcc5 pkg/branding/icons.qrc -o src/leap/bitmask/gui/app_rc.py
diff --git a/tests/e2e/check_ip b/tests/e2e/check_ip
new file mode 100755
index 00000000..8c12f250
--- /dev/null
+++ b/tests/e2e/check_ip
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+
+import urllib.request
+import json
+import sys
+
+DEMO_ISP = 'Riseup Networks'
+
+url = 'https://wtfismyip.com/json'
+
+with urllib.request.urlopen(url) as _url:
+ data = json.loads(_url.read().decode())
+
+isp = data['YourFuckingISP']
+ip = data['YourFuckingIPAddress']
+
+print('ISP >> %s' % isp)
+print('IP >> %s' % ip)
+
+
+class BadCmd(Exception):
+ pass
+
+
+try:
+ cmd = sys.argv[1]
+
+ if cmd == 'vpn_on':
+ assert isp == DEMO_ISP
+ elif cmd == 'vpn_off':
+ assert isp != DEMO_ISP
+ else:
+ raise BadCmd()
+
+except BadCmd:
+ print("Cannot parse that command. Valid commands: vpn_on, vpn_off")
+ sys.exit(1)
+
+except Exception:
+ print("IP *NOT* as expected")
+ sys.exit(1)
+
+else:
+ print("OK :)")
+ sys.exit(0)
diff --git a/tests/e2e/e2e-test.sh b/tests/e2e/e2e-test-mail.sh
index 8818147a..8818147a 100755
--- a/tests/e2e/e2e-test.sh
+++ b/tests/e2e/e2e-test-mail.sh
diff --git a/tests/e2e/e2e-test-vpn.sh b/tests/e2e/e2e-test-vpn.sh
new file mode 100755
index 00000000..90193bec
--- /dev/null
+++ b/tests/e2e/e2e-test-vpn.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Usage
+
+set -e
+
+PROVIDER='demo.bitmask.net'
+BCTL='bitmaskctl'
+LEAP_HOME="$HOME/.config/leap"
+
+username="tmp_user_$(date +%Y%m%d%H%M%S)"
+user="${username}@${PROVIDER}"
+pw="$(head -c 10 < /dev/urandom | base64)"
+
+# Stop any previously started bitmaskd
+# and start a new instance
+"$BCTL" stop
+
+[ -d "$LEAP_HOME" ] && rm -rf "$LEAP_HOME"
+
+"$BCTL" start
+
+
+# Register a new user
+"$BCTL" user create "$user" --pass "$pw"
+
+# Authenticate
+"$BCTL" user auth "$user" --pass "$pw" > /dev/null
+
+# Enable VPN
+"$BCTL" vpn enable
+
+# Get VPN cert
+"$BCTL" vpn get_cert "$user"
+
+"$BCTL" vpn start
+
+sleep 10
+
+"$BCTL" vpn status
+
+tests/e2e/check_ip vpn_on
+
+"$BCTL" vpn stop
+
+sleep 5
+
+tests/e2e/check_ip vpn_off
+
+echo "Succeeded - the vpn routed you through the expected address"