aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-02-23 17:36:29 +0300
committerMuriithi Frederick Muriuki2018-02-23 17:36:29 +0300
commit4d656976eae920066261e26bf22a999d90a0beab (patch)
treebfa1fc7a21b59bbe5a3fe05e2718187a6aae4351
parent4d7c565aac196ba1913b65ed27481c6974f1a0b5 (diff)
downloadgenenetwork2-4d656976eae920066261e26bf22a999d90a0beab.tar.gz
Add new tests for orcid logins
-rw-r--r--test/requests/run-integration-tests.py2
-rw-r--r--test/requests/test_login_orcid.py40
2 files changed, 42 insertions, 0 deletions
diff --git a/test/requests/run-integration-tests.py b/test/requests/run-integration-tests.py
index fc795779..5e816549 100644
--- a/test/requests/run-integration-tests.py
+++ b/test/requests/run-integration-tests.py
@@ -1,5 +1,6 @@
import sys
from test_login_local import TestLoginLocal
+from test_login_orcid import TestLoginOrcid
from test_login_github import TestLoginGithub
from test_registration import TestRegistration
from unittest import TestSuite, TextTestRunner, TestLoader
@@ -8,6 +9,7 @@ test_cases = [
TestRegistration
, TestLoginLocal
, TestLoginGithub
+ , TestLoginOrcid
]
def suite(gn2_url, es_url):
diff --git a/test/requests/test_login_orcid.py b/test/requests/test_login_orcid.py
new file mode 100644
index 00000000..6e40ece5
--- /dev/null
+++ b/test/requests/test_login_orcid.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 TestLoginOrcid(ParametrizedTest):
+
+ def setUp(self):
+ super(TestLoginOrcid, self).setUp()
+ data = {
+ "user_id": uid
+ , "name": "A. T. Est User"
+ , "orcid": 345872
+ , "user_url": "https://fake-orcid.org/atestuser"
+ , "login_type": "orcid"
+ , "organization": ""
+ , "active": 1
+ , "confirmed": 1
+ }
+ self.es.create(index="users", doc_type="local", body=data, id=uid)
+ sleep(1)
+
+ def tearDown(self):
+ super(TestLoginOrcid, 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=orcid&uid="+test_uid
+ result = requests.get(url)
+ index = result.content.find(expected)
+ self.assertTrue(index >= 0, message)