**Application Name:**OpenMRS Legacy-UI Module
Version Number: Latest Build
Question: I am working on the LUI-45 ticket.
I have made significant progress and actually fixed the issue. However, I have run into a major problem while generating tests for this form. The form in question is
ForgotPasswordFormController.java. Relevant code which I will be referring to is [HERE] (https://github.com/openmrs/openmrs-module-legacyui/pull/24/files) in the pull request I have generated on the request of Wylcif.
Now, I have come to know that we need to create our own dataset and run tests on that and I have done so, but I am not getting the tests to pass.
If you read the Issue carefully, here is what happening:(Please refer to the code in the
Earlier (before my fix), of the user enters his/her username and it is valid, then the secret question is directly shown. This is a vulnerability as it leaks valid usernames unintentionally.
Now, I have fixed that in the following way. If the user is invalid, he is asked a random question to which the answer is always no and he will be locked out eventually after 5 tries. This works great in practice and I have tested it well on my local OpenMRS instance.
Now, when I run the tests (I am new to unit testing), I have created a dataset that stores a user called
bruno and pass this user as a parameter in the Mock HHTP request (refer to
ForgotPasswordFormControllerTest.java in the link). The Secret Question returned by this is always one of the predefined random set of questions. This is the test’s way of telling me that such a user does not exist. Also, when I try to asser such a user exists, I get null. (Also please see my comment on the ‘Conversation’ tab of the linked pull request)
Now, how do I get the tests to recognize and take the testdata into consideration correctly and run my tests so I can fix the issue ASAP? Thanks in advance. Please comment for clarification