summaryrefslogtreecommitdiff
path: root/tests/functional/features/steps/vpn.py
diff options
context:
space:
mode:
authorVarac <varac@leap.se>2017-07-21 17:54:39 +0200
committerVarac <varac@leap.se>2017-07-21 17:54:39 +0200
commitffec1c990aa5517d517179f721d77f800023a6bd (patch)
treeb0c67cb2ccffff80b30950fe0f7a842623cf7a6d /tests/functional/features/steps/vpn.py
parentc56cdc970110ab8a4f6394fb213cdeee483c3e0f (diff)
[tests] Check egress IP for VPN stepsextend_vpn_tests
Diffstat (limited to 'tests/functional/features/steps/vpn.py')
-rw-r--r--tests/functional/features/steps/vpn.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/functional/features/steps/vpn.py b/tests/functional/features/steps/vpn.py
index 056b2cdf..05ed2b54 100644
--- a/tests/functional/features/steps/vpn.py
+++ b/tests/functional/features/steps/vpn.py
@@ -1,10 +1,28 @@
-from behave import when, then
+from behave import given, when, then
from common import (
click_button,
wait_until_button_is_visible,
find_element_containing_text
)
from selenium.common.exceptions import TimeoutException
+# For checking IP
+import requests
+
+
+@given('An initial network configuration')
+def record_ip(context):
+ context.initial_ip = _current_ip()
+
+
+def _current_ip():
+ url = 'https://wtfismyip.com/json'
+
+ r = requests.get(url)
+ data = r.json()
+
+ current_ip = data['YourFuckingIPAddress']
+ print("Current IP: %s\n\n" % current_ip)
+ return current_ip
@when('I activate VPN')
@@ -19,4 +37,16 @@ def activate_vpn(context):
@then('I should have my ass covered')
def assert_vpn(context):
wait_until_button_is_visible(context, 'Turn OFF')
- assert find_element_containing_text(context, 'Turn OFF', 'button')
+ assert _current_ip() != context.initial_ip
+
+
+@when('I deactivate VPN')
+def deactivate_vpn(context):
+ click_button(context, 'Turn OFF')
+ wait_until_button_is_visible(context, 'Turn ON')
+
+
+@then('My network should be configured as before')
+def network_as_before(context):
+ ip = _current_ip()
+ assert ip == context.initial_ip