Ejemplo n.º 1
0
 def blackbox_test(self):
     # Make sure no pre-existing campaign with campaign urn:
     # 'urn:campaign:ca:ucla:Mobilize:July:2011:Test'
     HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
     # Complete testing on 241 testing xml
     for x in range(1,242):
         FILE_PATH = XML_PATH + '/xml' + str(x) + '.xml'
         self.arg_pass_in['xml'] = (pycurl.FORM_FILE, FILE_PATH)
         # Use zip(dict.keys(), dict.values())
         # can convert dict into a list of tuples
         self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
         # Need to upload a file, set flag to 1
         # to change the type of HTTP request
         self.http.request(1)
         self.total_case = self.total_case + 1
         # Print status
         print 'Processing Case ID {0}.\n{1}% to finish XML Schema Testing.'.format('XML'+str(self.total_case), self.total_case*100/TOTAL_CASE)
         print self.http.contents
         # check response
         if self.exp_result[x] == 'success':
             if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                 HTTP.write_err_report(self.err_report,\
                                       'XML'+str(self.total_case),\
                                       self.arg_pass_in,\
                                       self.http.contents,\
                                       '{"result": "success"}')
                 # increment the invalid case id list and unexpected case counter
                 self.invalid_case_id_list.append('XML'+str(self.total_case))
                 self.unexpect_case = self.unexpect_case + 1
             else:
                 HTTP.write_succ_report(self.succ_report,\
                                        'XML'+str(self.total_case),\
                                        self.arg_pass_in,\
                                        self.http.contents)
                 # need to delete the campaign after writing the success report
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             # Need to check whether expected string is a substring of result
             print self.http.contents.find(self.exp_result[x])
             if (self.http.http_code != 200) or \
                (self.http.cont_dict['result'] != 'failure') or \
                (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_XML) or \
                (self.http.contents.find(self.exp_result[x]) == -1):
                 HTTP.write_err_report(self.err_report,\
                                       'XML'+str(self.total_case),\
                                       self.arg_pass_in,\
                                       self.http.contents,\
                                       gconst.INVALID_XML+': '+self.exp_result[x])
                 # increment the invalid case id list and unexpected case counter
                 self.invalid_case_id_list.append('XML'+str(self.total_case))
                 self.unexpect_case = self.unexpect_case + 1
                 # Although unexpected success, still need to delete the original campaign
                 if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                     result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                     if result != 'success':
                         print >> sys.stderr, 'Error: Cannot delete existing campaign'
                         sys.exit(1)
             else:
                 HTTP.write_succ_report(self.succ_report,\
                                        'XML'+str(self.total_case),\
                                        self.arg_pass_in,\
                                        self.http.contents)
Ejemplo n.º 2
0
 def err_response_check(self, exp_result):
     # helper function to check invalid cases response
     if exp_result == gconst.AUTH_FAIL:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.CLT_TOO_LONG:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.CLT_TOO_LONG):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.CLT_TOO_LONG+': '+gconst.ERROR[gconst.CLT_TOO_LONG])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_RUN_STATE:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_RUN_STATE):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_RUN_STATE+': '+gconst.ERROR[gconst.INVALID_RUN_STATE])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_PRI_STATE:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_PRI_STATE):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_PRI_STATE+': '+gconst.ERROR[gconst.INVALID_PRI_STATE])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_CLS_URN:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_XML:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_XML):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_XML+': '+gconst.ERROR[gconst.INVALID_XML])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     # this is necessary, since we don't really have an invalid case for "description"
     # TODO: you may delete this condition when "description" has something invalid
     elif exp_result == 'v':
         if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   '{"result": "success"}')
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
             # need to delete the campaign after writing the success report
             result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
             if result != 'success':
                 print >> sys.stderr, 'Error: Cannot delete existing campaign'
                 sys.exit(1)
     else:
         print >> sys.stderr, 'Error: Unexpected invalid test case'
         sys.exit(1)
Ejemplo n.º 3
0
    def blackbox_test(self):
        # Should delete the old campaign first
        HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)

        # Combination of three kinds of test cases defined in README
        # Special cases for 'Missing Argument' of argument 'description'
        # Part I: Valid Case
        for a in self.valid_arg['auth_token']:
            self.arg_pass_in = {}
            self.arg_pass_in_msg = []
            self.arg_pass_in['auth_token'] = a
            self.arg_pass_in_msg.append(self.valid_arg_msg['auth_token'][0])
            for clt in self.valid_arg['client']:
                self.arg_pass_in['client'] = clt
                self.arg_pass_in_msg.append(self.valid_arg_msg['client'][self.valid_arg['client'].index(clt)])
                for run in self.valid_arg['running_state']:
                    self.arg_pass_in['running_state'] = run
                    self.arg_pass_in_msg.append(self.valid_arg_msg['running_state'][self.valid_arg['running_state'].index(run)])
                    for pri in self.valid_arg['privacy_state']:
                        self.arg_pass_in['privacy_state'] = pri
                        self.arg_pass_in_msg.append(self.valid_arg_msg['privacy_state'][self.valid_arg['privacy_state'].index(pri)])
                        for cls in self.valid_arg['class_urn_list']:
                            self.arg_pass_in['class_urn_list'] = cls
                            self.arg_pass_in_msg.append(self.valid_arg_msg['class_urn_list'][self.valid_arg['class_urn_list'].index(cls)])
                            for xml in self.valid_arg['xml']:
                                self.arg_pass_in['xml'] = xml
                                self.arg_pass_in_msg.append(self.valid_arg_msg['xml'][self.valid_arg['xml'].index(xml)])
                                for des in self.valid_arg['description']:
                                    self.update_arg_pass_in('description', des, 0)
                                    self.arg_pass_in_msg.append(self.valid_arg_msg['description'][self.valid_arg['description'].index(des)])
                                    # Determine the expected result
                                    exp_result = self.result_det(self.arg_pass_in_msg)
                                    # Use zip(dict.keys(), dict.values())
                                    # can convert dict into a list of tuples
                                    self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                                    # Need to upload a file, set flag to 1
                                    # to change the type of HTTP request
                                    self.http.request(1)
                                    self.total_case = self.total_case + 1
                                    # Print status
                                    print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                                          self.total_case*100/TOTAL_CASE)
                                    # Check the response
                                    if exp_result == 'v':
                                        if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                                            HTTP.write_err_report(self.err_report,\
                                                                  'CC'+str(self.total_case),\
                                                                  self.arg_pass_in,\
                                                                  self.http.contents,\
                                                                  '{"result": "success"}')
                                            # increment the invalid case id list and unexpected case counter
                                            self.invalid_case_id_list.append('CC'+str(self.total_case))
                                            self.unexpect_case = self.unexpect_case + 1
                                        else:
                                            HTTP.write_succ_report(self.succ_report,\
                                                                   'CC'+str(self.total_case),\
                                                                   self.arg_pass_in,\
                                                                   self.http.contents)
                                            # need to delete the campaign after expected creation
                                            result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                                            if result != 'success':
                                                print >> sys.stderr, 'Error: Cannot delete existing campaign'
                                                sys.exit(1)
                                    else:
                                        print >> sys.stderr, 'Error: Invalid valid test case'
                                        sys.exit(1)
                                    # update arg_pass_in and arg_pass_in_msg
                                    self.update_arg_pass_in('description', des, 1)
                                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                                # update arg_pass_in and arg_pass_in_msg
                                del self.arg_pass_in['xml']
                                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                            # update arg_pass_in and arg_pass_in_msg
                            del self.arg_pass_in['class_urn_list']
                            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                        # update arg_pass_in and arg_pass_in_msg
                        del self.arg_pass_in['privacy_state']
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                    # update arg_pass_in and arg_pass_in_msg
                    del self.arg_pass_in['running_state']
                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                # update arg_pass_in and arg_pass_in_msg
                del self.arg_pass_in['client']
                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)         
            # update arg_pass_in and arg_pass_in_msg
            del self.arg_pass_in['auth_token']
            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)

        ########################################################################
        ########################################################################    
        # Part II: Invalid case with one invalid argument
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        # pick each invalid argument once
        for arg_name in self.para_name_list:
            for arg in self.invalid_arg[arg_name]:
                # first keep all argument valid
                self.form_one_valid_arg()
                self.update_arg_pass_in(arg_name, arg, 0)
                self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name][self.invalid_arg[arg_name].index(arg)])
                # Determine the expected result
                exp_result = self.result_det(self.arg_pass_in_msg)
                # Use zip(dict.keys(), dict.values())
                # can convert dict into a list of tuples
                self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                # Need to upload a file, set flag to 1
                # to change the type of HTTP request
                self.http.request(1)
                self.total_case = self.total_case + 1
                # Print status
                print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                      self.total_case*100/TOTAL_CASE)
                # check the response
                self.err_response_check(exp_result)
        
        ########################################################################
        ########################################################################    
        # Part III: Invalid case with two invalid arguments
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        for arg_name1 in self.para_name_list:
            index1 = self.para_name_list.index(arg_name1)
            for arg_name2 in self.para_name_list[index1+1:]:
                # add those two arguments into arg_pass_in dict
                for arg1 in self.invalid_arg[arg_name1]:
                    self.form_one_valid_arg()
                    self.update_arg_pass_in(arg_name1, arg1, 0)
                    self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name1][self.invalid_arg[arg_name1].index(arg1)])
                    for arg2 in self.invalid_arg[arg_name2]:
                        self.update_arg_pass_in(arg_name2, arg2, 0)
                        self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name2][self.invalid_arg[arg_name2].index(arg2)])
                        # Determine the expected result
                        exp_result = self.result_det(self.arg_pass_in_msg)
                        # Use zip(dict.keys(), dict.values())
                        # can convert dict into a list of tuples
                        self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                        # Need to upload a file, set flag to 1
                        # to change the type of HTTP request
                        self.http.request(1)
                        self.total_case = self.total_case + 1
                        # Print status
                        print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                              self.total_case*100/TOTAL_CASE)
                        # check the response
                        self.err_response_check(exp_result)
                        # update arg_pass_in and arg_pass_in_msg
                        self.update_arg_pass_in(arg_name2, arg2, 1)
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
Ejemplo n.º 4
0
   def blackbox_test(self):
       # Should refresh the server campaign with URN gconst.CAMP_URN
       HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
       HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN_LIST)
       # Combination of three kinds of test cases defined in README
       # Special cases for 'Wrong argument name' and 'Missing Argument'
       # Part I: Valid Case
       for a in self.valid_arg['auth_token']:
           self.arg_pass_in = {}
           self.arg_pass_in_msg = []
           self.arg_pass_in['auth_token'] = a
           self.arg_pass_in_msg.append(self.valid_arg_msg['auth_token'][0])
           for clt in self.valid_arg['client']:
               self.arg_pass_in['client'] = clt
               self.arg_pass_in_msg.append(self.valid_arg_msg['client'][self.valid_arg['client'].index(clt)])
               for camp in self.valid_arg['campaign_urn_list']:
                   self.update_arg_pass_in('campaign_urn_list', camp, 0)
                   self.arg_pass_in_msg.append(self.valid_arg_msg['campaign_urn_list'][self.valid_arg['campaign_urn_list'].index(camp)])
                   for cls in self.valid_arg['class_urn_list']:
                       self.update_arg_pass_in('class_urn_list', cls, 0)
                       self.arg_pass_in_msg.append(self.valid_arg_msg['class_urn_list'][self.valid_arg['class_urn_list'].index(cls)])
                       # Determine the expected result
                       exp_result = self.result_det(self.arg_pass_in_msg)
                       # HTTP request part
                       # Increment the total and invalid cases at the same time
                       self.http.set_pass_in(self.arg_pass_in)
                       self.http.request(0)
                       self.total_case = self.total_case + 1
                       # Print status
                       print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                       # Check the response
                       if exp_result == 'v':
                           if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                               HTTP.write_err_report(self.err_report,\
                                                     'UR'+str(self.total_case),\
                                                     self.arg_pass_in,\
                                                     self.http.contents,\
                                                     '{"result": "success", "data":...}')
                               # increment the invalid case id list and unexpected case counter
                               self.invalid_case_id_list.append('UR'+str(self.total_case))
                               self.unexpect_case = self.unexpect_case + 1
                           else:
                               HTTP.write_succ_report(self.succ_report,\
                                                      'UR'+str(self.total_case),\
                                                      self.arg_pass_in,\
                                                      self.http.contents)
                       else:
                           print >> sys.stderr, 'Error: Invalid valid test case'
                           sys.exit(1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in('class_urn_list', cls, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in('campaign_urn_list', camp, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # update arg_pass_in and arg_pass_in_msg
               del self.arg_pass_in['client']
               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)         
           # update arg_pass_in and arg_pass_in_msg
           del self.arg_pass_in['auth_token']
           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
 
       ########################################################################
       ########################################################################    
       # Part II: Invalid case with one invalid argument
       for para in self.para_name_list:
           index = self.para_name_list.index(para)
           # each turn pick one as invalid argument
           self.para_name_list.remove(para)
           arg1 = para                         # invalid arg
           arg2 = self.para_name_list[0]       # valid arg   
           arg3 = self.para_name_list[1]       # valid arg
           arg4 = self.para_name_list[2]       # valid arg
           # Add arg 1
           for a1 in self.invalid_arg[arg1]:
               self.arg_pass_in = {}
               self.arg_pass_in_msg = []
               self.update_arg_pass_in(arg1, a1, 0)
               self.arg_pass_in_msg.append(self.invalid_arg_msg[arg1][self.invalid_arg[arg1].index(a1)])
               # Add arg 2
               for a2 in self.valid_arg[arg2]:
                   self.update_arg_pass_in(arg2, a2, 0)
                   self.arg_pass_in_msg.append(self.valid_arg_msg[arg2][self.valid_arg[arg2].index(a2)])
                   # Add arg 3
                   for a3 in self.valid_arg[arg3]:
                       self.update_arg_pass_in(arg3, a3, 0)
                       self.arg_pass_in_msg.append(self.valid_arg_msg[arg3][self.valid_arg[arg3].index(a3)])
                       # Add arg 4
                       for a4 in self.valid_arg[arg4]:
                           self.update_arg_pass_in(arg4, a4, 0)
                           self.arg_pass_in_msg.append(self.valid_arg_msg[arg4][self.valid_arg[arg4].index(a4)])
                           # Result determine
                           exp_result = self.result_det(self.arg_pass_in_msg)
                           # HTTP request
                           # Increment the total and invalid cases at the same time
                           self.http.set_pass_in(self.arg_pass_in)
                           self.http.request(0)
                           self.total_case = self.total_case + 1
                           print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                           # result check
                           if exp_result == gconst.AUTH_FAIL:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.CLT_TOO_LONG:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.CLT_TOO_LONG):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.CLT_TOO_LONG+': '+gconst.ERROR[gconst.CLT_TOO_LONG])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.NO_PERM_IN_CAMP:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CAMP):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.NO_PERM_IN_CAMP+': '+gconst.ERROR[gconst.NO_PERM_IN_CAMP])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.INVALID_CAMP_URN:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CAMP_URN):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.INVALID_CAMP_URN+': '+gconst.ERROR[gconst.INVALID_CAMP_URN])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.INVALID_CLS_URN:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.NO_PERM_IN_CLS:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CLS):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.NO_PERM_IN_CLS+': '+gconst.ERROR[gconst.NO_PERM_IN_CLS])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           else:
                               print >> sys.stderr, 'Error: Unexpected single argument invalid test case'
                               sys.exit(1)
                           # update arg_pass_in and arg_pass_in_msg
                           self.update_arg_pass_in(arg4, a4, 1)
                           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in(arg3, a3, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in(arg2, a2, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # update arg_pass_in and arg_pass_in_msg
               self.update_arg_pass_in(arg1, a1, 1)
               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
           # restore the para_name_list
           self.para_name_list.insert(index, para)
           
       ########################################################################
       ########################################################################    
       # Part III: Invalid case with two invalid arguments
       # Get first invalid arg
       for arg1 in self.para_name_list:
           index1 = self.para_name_list.index(arg1)
           # each turn pick one as invalid argument
           self.para_name_list.remove(arg1)
           # Get second invalid arg
           for arg2 in self.para_name_list[index1:]:          # reduce half of the redundency
               index2 = self.para_name_list.index(arg2)
               self.para_name_list.remove(arg2)
               # Get other two arg
               arg3 = self.para_name_list[0]
               arg4 = self.para_name_list[1]
               # Add arg 1
               for a1 in self.invalid_arg[arg1]:
                   self.arg_pass_in = {}
                   self.arg_pass_in_msg = []
                   self.update_arg_pass_in(arg1, a1, 0)
                   self.arg_pass_in_msg.append(self.invalid_arg_msg[arg1][self.invalid_arg[arg1].index(a1)])
                   # Add arg 2
                   for a2 in self.invalid_arg[arg2]:
                       self.update_arg_pass_in(arg2, a2, 0)
                       self.arg_pass_in_msg.append(self.invalid_arg_msg[arg2][self.invalid_arg[arg2].index(a2)])
                       # Add arg 3
                       for a3 in self.valid_arg[arg3]:
                           self.update_arg_pass_in(arg3, a3, 0)
                           self.arg_pass_in_msg.append(self.valid_arg_msg[arg3][self.valid_arg[arg3].index(a3)])
                           # Add arg 4
                           for a4 in self.valid_arg[arg4]:
                               self.update_arg_pass_in(arg4, a4, 0)
                               self.arg_pass_in_msg.append(self.valid_arg_msg[arg4][self.valid_arg[arg4].index(a4)])
                               # Result determine
                               exp_result = self.result_det(self.arg_pass_in_msg)
                               # HTTP request
                               # Increment the total and invalid cases at the same time
                               self.http.set_pass_in(self.arg_pass_in)
                               self.http.request(0)
                               self.total_case = self.total_case + 1
                               print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), \
                                      self.total_case*100/TOTAL_CASE)
                               # Result Check
                               if exp_result == gconst.AUTH_FAIL:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.NO_PERM_IN_CAMP:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CAMP):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.NO_PERM_IN_CAMP+': '+gconst.ERROR[gconst.NO_PERM_IN_CAMP])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.INVALID_CAMP_URN:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CAMP_URN):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.INVALID_CAMP_URN+': '+gconst.ERROR[gconst.INVALID_CAMP_URN])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.INVALID_CLS_URN:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.NO_PERM_IN_CLS:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CLS):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.NO_PERM_IN_CLS+': '+gconst.ERROR[gconst.NO_PERM_IN_CLS])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                               else:
                                   print >> sys.stderr, 'Error: Unexpected single argument invalid test case'
                                   sys.exit(1)
                               # update arg_pass_in and arg_pass_in_msg
                               self.update_arg_pass_in(arg4, a4, 1)
                               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                           # update arg_pass_in and arg_pass_in_msg
                           self.update_arg_pass_in(arg3, a3, 1)
                           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in(arg2, a2, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in(arg1, a1, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # restore the para_name_list
               self.para_name_list.insert(index2, arg2)
           # restore the para_name_list
           self.para_name_list.insert(index1, arg1)