aboutsummaryrefslogtreecommitdiff
path: root/test/requests
diff options
context:
space:
mode:
Diffstat (limited to 'test/requests')
-rw-r--r--test/requests/test_login_local.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/requests/test_login_local.py b/test/requests/test_login_local.py
new file mode 100644
index 00000000..bced1ee9
--- /dev/null
+++ b/test/requests/test_login_local.py
@@ -0,0 +1,56 @@
+import requests
+from wqflask import user_manager
+from parametrized_test import ParametrizedTest
+
+class TestLoginLocal(ParametrizedTest):
+
+ def setUp(self):
+ super(TestLoginLocal, self).setUp()
+ self.login_url = self.gn2_url +"/n/login"
+ data = {
+ "es_connection": self.es,
+ "email_address": "test@user.com",
+ "full_name": "Test User",
+ "organization": "Test Organisation",
+ "password": "test_password",
+ "password_confirm": "test_password"
+ }
+ user_manager.basic_info = lambda : { "basic_info": "basic" }
+ user_manager.RegisterUser(data)
+
+ def testLoginNonRegisteredUser(self):
+ data = {
+ "email_address": "non@existent.email",
+ "password": "doesitmatter?"
+ }
+ result = requests.post(self.login_url, data=data)
+ self.assertEqual(result.url, self.login_url, "")
+
+ def testLoginWithRegisteredUserBothRememberMeAndImportCollectionsFalse(self):
+ data = {
+ "email_address": "test@user.com",
+ "password": "test_password"
+ }
+ result = requests.post(self.login_url, data=data)
+ print("THE COOKIES? ", result.cookies)
+ self.assertEqual(
+ result.url
+ , self.gn2_url+"/?import_collections=false"
+ , "Login should have been successful")
+
+
+
+def main(gn2, es):
+ import unittest
+ suite = unittest.TestSuite()
+ suite.addTest(TestLoginLocal(methodName="testLoginNonRegisteredUser", gn2_url=gn2, es_url=es))
+ suite.addTest(TestLoginLocal(methodName="testLoginWithRegisteredUserBothRememberMeAndImportCollectionsFalse", gn2_url=gn2, es_url=es))
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
+if __name__ == "__main__":
+ import sys
+ if len(sys.argv) < 3:
+ raise Exception("Required arguments missing")
+ else:
+ main(sys.argv[1], sys.argv[2])