def test_search_invalid_tester(self): """ Test with no tester permissions. expect 401 - not authorised """ Test_Start() # We should search for this prn_info = False p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) print p calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] if prn_info!=False: print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/services/search-by-name' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401") else: Test_Msg("Test Failed for 401") Test_End() return
def test_search_by_SSN_with_non_Tester_401(self): """ Failed search with Non Tester Permission Using call to testutils.test_for_401(usrname, passwd, output, post_url,post_parameters ) """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) if prn_info!=False: print p calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] if prn_info!=False: print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/intake/search-by-ssn' post_parameters = {'last_4_ssn':VALID_LAST_4_SSN} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401") else: Test_Msg("Test Failed for 401") Test_End() return
def test_search_invalid_tester(self): """ Test with no tester permissions. expect 401 - not authorised """ Test_Start() # We should search for this prn_info = False p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) print p calling_test_function = inspect.getframeinfo( inspect.currentframe().f_back)[2] if prn_info != False: print "calling:[" + calling_test_function + "]" usrname = USERNAME_NOT_TEST passwd = PASSWORD_NOT_TEST output = [] post_url = '/services/search-by-name' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401") else: Test_Msg("Test Failed for 401") Test_End() return
def test_quick_intake_with_non_tester(self): """ Test quickintake is blocked to non-testers """ Test_Start("Testing Quick Intake - With Non-Tester") prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) if prn_info!=False: print p calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] if prn_info!=False: print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/intake/quickintake' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401") else: Test_Msg("Test Failed for 401") Test_End() return
def test_vgc_invalid_tester(self): """ Use Non-Tester permission - to return a 401 - not authorised """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) print p # print HIVGroupedConsent.objects.all() calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] # print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/hivtest/view/grouped-consent/'+VALID_PATIENT_ID post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401") else: Test_Msg("Test Failed for 401") Test_End() return
def test_inprocess_list_with_nontester(self): """ Use Non-Tester permission - we should get a 401 - not authorised """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) ip_patient = p print p print ip_patient.creation_date print date.today() print date.today() ip_patient.creation_date=date.today() print ip_patient.creation_date ip_patient.save() print ip_patient.creation_date calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/today' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) Test_End() return
def test_smsreminders_non_testers(self): """ Test with non-tester permission for 401 not authorised """ Test_Start() # We should search for this prn_info = False p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) print p calling_test_function = inspect.getframeinfo( inspect.currentframe().f_back)[2] if prn_info != False: print "calling:[" + calling_test_function + "]" usrname = USERNAME_NOT_TEST passwd = PASSWORD_NOT_TEST output = [] post_url = '/sms-reminders/appointment/search-by-name' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/appointment/create/' + VALID_PATIENT_ID Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/appointment/view/1' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/adherence/create/' + VALID_PATIENT_ID Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/adherence/search-by-name' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/adherence/view/1' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/send/' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/messages/' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) Test_End() return
def test_sms_reminders_cron_bad_cron_key(self): """ Test transactions for not authorized - bad or missing cron key """ Test_Start() # We should search for this prn_info = False bad_cron_key = '123456789' empty_cron_key = '' calling_test_function = inspect.getframeinfo( inspect.currentframe().f_back)[2] if prn_info != False: print "calling:[" + calling_test_function + "]" usrname = USERNAME_NOT_TEST passwd = PASSWORD_NOT_TEST output = [] post_parameters = {} post_url = '/sms-reminders/cron/insert/' + bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/cron/insert/' + empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 404:" + post_url) else: Test_Msg("Test Failed for 404:" + post_url) post_url = '/sms-reminders/cron/adherence-send/' + bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/cron/adherence-send/' + empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 404:" + post_url) else: Test_Msg("Test Failed for 404:" + post_url) post_url = '/sms-reminders/cron/appointment-send/' + bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/cron/appointment-send/' + empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 404:" + post_url) else: Test_Msg("Test Failed for 404:" + post_url) post_url = '/sms-reminders/cron/adherence-response/' + bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 401:" + post_url) else: Test_Msg("Test Failed for 401:" + post_url) post_url = '/sms-reminders/cron/adherence-response/' + empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url, post_parameters, calling_test_function, prn_info) if Access_Authorised == None: Test_Msg("Successful Test for 404:" + post_url) else: Test_Msg("Test Failed for 404:" + post_url) Test_End() return
def test_smsreminders_non_testers(self): """ Test with non-tester permission for 401 not authorised """ Test_Start() # We should search for this prn_info = False p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) print p calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] if prn_info!=False: print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_url = '/sms-reminders/appointment/search-by-name' post_parameters = {} Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/appointment/create/'+VALID_PATIENT_ID Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/appointment/view/1' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/adherence/create/'+VALID_PATIENT_ID Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/adherence/search-by-name' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/adherence/view/1' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/send/' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/messages/' Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) Test_End() return
def test_sms_reminders_cron_bad_cron_key(self): """ Test transactions for not authorized - bad or missing cron key """ Test_Start() # We should search for this prn_info = False bad_cron_key = '123456789' empty_cron_key = '' calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] if prn_info!=False: print "calling:["+calling_test_function+"]" usrname = USERNAME_NOT_TEST passwd=PASSWORD_NOT_TEST output = [] post_parameters = {} post_url = '/sms-reminders/cron/insert/'+bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/cron/insert/'+empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 404:"+post_url) else: Test_Msg("Test Failed for 404:"+post_url) post_url = '/sms-reminders/cron/adherence-send/'+bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/cron/adherence-send/'+empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 404:"+post_url) else: Test_Msg("Test Failed for 404:"+post_url) post_url = '/sms-reminders/cron/appointment-send/'+bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/cron/appointment-send/'+empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 404:"+post_url) else: Test_Msg("Test Failed for 404:"+post_url) post_url = '/sms-reminders/cron/adherence-response/'+bad_cron_key Access_Authorised = test_for_401(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 401:"+post_url) else: Test_Msg("Test Failed for 401:"+post_url) post_url = '/sms-reminders/cron/adherence-response/'+empty_cron_key Access_Authorised = test_for_404_with_get(self, usrname, passwd, output, post_url,post_parameters, calling_test_function, prn_info ) if Access_Authorised == None: Test_Msg("Successful Test for 404:"+post_url) else: Test_Msg("Test Failed for 404:"+post_url) Test_End() return