aboutsummaryrefslogtreecommitdiff
path: root/test/requests
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-04-15 11:56:00 +0300
committerMuriithi Frederick Muriuki2018-04-15 11:56:00 +0300
commit9ac9f94f3b1409ae3a47c8a9e890f578a69b020f (patch)
treed604717ad9094dd9b298cb8313d8bfb25550eb5c /test/requests
parente3e98b0533460837c4ea2eac67c4281eb0ba0012 (diff)
downloadgenenetwork2-9ac9f94f3b1409ae3a47c8a9e890f578a69b020f.tar.gz
Add tests for Forgot Password feature
* Add tests to ensure the "Forgot Password" feature works appropriately.
Diffstat (limited to 'test/requests')
-rw-r--r--test/requests/test_forgot_password.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/requests/test_forgot_password.py b/test/requests/test_forgot_password.py
new file mode 100644
index 00000000..2bf34c5c
--- /dev/null
+++ b/test/requests/test_forgot_password.py
@@ -0,0 +1,52 @@
+import requests
+from wqflask import user_manager
+from utility.elasticsearch_tools import get_user_by_unique_column
+from parameterized import parameterized
+from parametrized_test import ParametrizedTest
+
+passwork_reset_link = ''
+forgot_password_page = None
+
+class TestForgotPassword(ParametrizedTest):
+
+ def setUp(self):
+ super(TestForgotPassword, self).setUp()
+ self.forgot_password_url = self.gn2_url+"/n/forgot_password_submit"
+ def send_email(to_addr, msg, fromaddr="no-reply@genenetwork.org"):
+ print("CALLING: send_email_mock()")
+ email_data = {
+ "to_addr": to_addr
+ , "msg": msg
+ , "fromaddr": from_addr}
+
+ 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 testWithoutEmail(self):
+ data = {"email_address": ""}
+ error_notification = '<div class="alert alert-danger">You MUST provide an email</div>'
+ result = requests.post(self.forgot_password_url, data=data)
+ self.assertEqual(result.url, self.gn2_url+"/n/forgot_password")
+ self.assertTrue(
+ result.content.find(error_notification) >= 0
+ , "Error message should be displayed but was not")
+
+ def testWithNonExistingEmail(self):
+ # Monkey patching doesn't work, so simply test that getting by email
+ # returns the correct data
+ user = get_user_by_unique_column(self.es, "email_address", "non-existent@domain.com")
+ self.assertTrue(user is None, "Should not find non-existent user")
+
+ def testWithExistingEmail(self):
+ # Monkey patching doesn't work, so simply test that getting by email
+ # returns the correct data
+ user = get_user_by_unique_column(self.es, "email_address", "test@user.com")
+ self.assertTrue(user is not None, "Should find user")