aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-02-23 17:26:42 +0300
committerPjotr Prins2018-03-26 09:29:29 +0000
commit7ea87a27735242889ac369dcbd5aec83a1e1caff (patch)
treea7b954715672c9006b4b456acf9870f6f058d5bf /test
parente982d7223141d247954ab5b5c1ff9bbed907c603 (diff)
downloadgenenetwork2-7ea87a27735242889ac369dcbd5aec83a1e1caff.tar.gz
Add new test for github logins
Diffstat (limited to 'test')
-rw-r--r--test/requests/run-integration-tests.py4
-rw-r--r--test/requests/test_login_github.py40
2 files changed, 43 insertions, 1 deletions
diff --git a/test/requests/run-integration-tests.py b/test/requests/run-integration-tests.py
index 0fd7bb20..fc795779 100644
--- a/test/requests/run-integration-tests.py
+++ b/test/requests/run-integration-tests.py
@@ -1,11 +1,13 @@
import sys
from test_login_local import TestLoginLocal
+from test_login_github import TestLoginGithub
from test_registration import TestRegistration
from unittest import TestSuite, TextTestRunner, TestLoader
test_cases = [
- TestLoginLocal,
TestRegistration
+ , TestLoginLocal
+ , TestLoginGithub
]
def suite(gn2_url, es_url):
diff --git a/test/requests/test_login_github.py b/test/requests/test_login_github.py
new file mode 100644
index 00000000..15bf18ae
--- /dev/null
+++ b/test/requests/test_login_github.py
@@ -0,0 +1,40 @@
+import uuid
+import requests
+from time import sleep
+from parameterized import parameterized
+from parametrized_test import ParametrizedTest
+
+login_link_text = '<a id="login_in" href="/n/login">Sign in</a>'
+logout_link_text = '<a id="login_out" title="Signed in as ." href="/n/logout">Sign out</a>'
+uid = str(uuid.uuid4())
+
+class TestLoginGithub(ParametrizedTest):
+
+ def setUp(self):
+ super(TestLoginGithub, self).setUp()
+ data = {
+ "user_id": uid
+ , "name": "A. T. Est User"
+ , "github_id": 693024
+ , "user_url": "https://fake-github.com/atestuser"
+ , "login_type": "github"
+ , "organization": ""
+ , "active": 1
+ , "confirmed": 1
+ }
+ self.es.create(index="users", doc_type="local", body=data, id=uid)
+ sleep(1)
+
+ def tearDown(self):
+ super(TestLoginGithub, self).tearDown()
+ self.es.delete(index="users", doc_type="local", id=uid)
+
+ @parameterized.expand([
+ ("1234", login_link_text, "Login should have failed with non-existing user")
+ , (uid, logout_link_text, "Login should have been successful with existing user")
+ ])
+ def testLogin(self, test_uid, expected, message):
+ url = self.gn2_url+"/n/login?type=github&uid="+test_uid
+ result = requests.get(url)
+ index = result.content.find(expected)
+ self.assertTrue(index >= 0, message)