summaryrefslogtreecommitdiff
path: root/tests/e2e/check_ip
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-05-04 19:05:26 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-06-07 12:31:19 +0200
commitdd1e5083d99637d4118d12fa72605096d7b5e587 (patch)
treeb984e6fce19bd24a068a4c3ad1f36de051b0b23e /tests/e2e/check_ip
parent4da0958a7c87d9e68a5e9a9acf4bcbcc3a9d6ac2 (diff)
[tests] simple e2e vpn test
- Resolves: #8874
Diffstat (limited to 'tests/e2e/check_ip')
-rwxr-xr-xtests/e2e/check_ip45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/e2e/check_ip b/tests/e2e/check_ip
new file mode 100755
index 0000000..8c12f25
--- /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)