Exemple #1
0
    def test_def(self, log):
        #print(str(log))
        if log.level is not None:
            #print(log.level[:-2])
            if log.level[:-2] == "mail":
                if log.level in self.holder:
                    pass
                else:
                    self.holder.add(log.level)
                    self.counter += 1
                    if self.counter < 10:
                        self.state = do_state_change("under_10", log,
                                                     self.dyn_classes,
                                                     self.get_test_result)
                    elif self.counter == 10:
                        self.state = do_state_change("at_10", log,
                                                     self.dyn_classes,
                                                     self.get_test_result)
                    elif self.counter > 10:
                        self.state = do_state_change("over_10", log,
                                                     self.dyn_classes,
                                                     self.get_test_result)
                    else:
                        self.state = do_state_change(log.level, log,
                                                     self.dyn_classes,
                                                     self.get_test_result)
            elif log.level == "b" and log.rec_queried == "MX":
                self.state = do_state_change("b_mx", log, self.dyn_classes,
                                             self.get_test_result)

        elif isinstance(
                self.state,
                StartState) and log.rec_queried == "TXT" and log.level == None:
            self.state = BaseState(log, self.get_test_result)
Exemple #2
0
    def test_def(self, log):
        #print(str(log))
        if isinstance(self.state, StartState) and log.rec_queried == "TXT":
            self.queries_types = {"b", "c", "d", "e", "f"}  # restore the queries
            self.state = BaseState(log, self.get_test_result)

        elif isinstance(self.state, BaseState) and log.level in self.queries_types and check_a(log.rec_queried):
            self.queries_types.remove(log.level)
            self.state = do_state_change("lookup_1", log, self.dyn_classes, self.get_test_result)

        elif self.state.name == "lookup_1" and log.level in self.queries_types and check_a(log.rec_queried):
            self.queries_types.remove(log.level)
            self.state = do_state_change("lookup_2", log, self.dyn_classes, self.get_test_result)

        elif self.state.name == "lookup_2" and log.level in self.queries_types and check_a(log.rec_queried):
            self.state = FailureState(log, self.get_test_result)
Exemple #3
0
 def test_def(self, log):
     #print(str(log))
     if isinstance(self.state, StartState) and "." in self.sent_to:
         self.state = do_state_change("to_ipv4", log, self.dyn_classes,
                                      self.get_test_result)
         self.sent_to = "to_ipv4"
         # get the ip address associated with the generated name with an ip address in new_true_domains.txt
     elif isinstance(self.state, StartState) and ":" in self.sent_to:
         self.state = do_state_change("to_ipv6", log, self.dyn_classes,
                                      self.get_test_result)
         self.sent_to = "to_ipv6"
     elif self.state.name == "to_ipv6" or self.state.name == "to_ipv4" or isinstance(
             self.state, FailureState):
         # ipv_protocol is the label "ipv4" or "ipv6" that was in the query
         if log.rec_queried == s.States.TXT.value and log.ipv_protocol is not None:
             self.state = SuccessState(log, self.get_test_result)
         else:
             self.state = FailureState(log, self.get_test_result)
Exemple #4
0
 def test_def(self, log):
     #print(str(log))
     if isinstance(
             self.state,
             StartState) and log.rec_queried == "TXT" and log.level is None:
         self.state = BaseState(log, self.get_test_result)
     elif check_a(log.rec_queried):
         if log.level == "b":
             if log.level in self.holder:
                 self.holder.remove(log.level)
             self.state = do_state_change("b_A", log, self.dyn_classes,
                                          self.get_test_result)
         elif log.level == "c":
             if log.level in self.holder:
                 self.holder.remove(log.level)
             self.state = do_state_change("c_A", log, self.dyn_classes,
                                          self.get_test_result)
     if len(self.holder) == 0:
         self.state = do_state_change("both", log, self.dyn_classes,
                                      self.get_test_result)
Exemple #5
0
 def test_def(self, log):
     #print(str(log))
     # we will check for "." for ipv4 addresses and ":" for ipv6 addresses
     if isinstance(self.state, StartState) and "." in self.sent_to:
         self.state = do_state_change("to_ipv4", log, self.dyn_classes, self.get_test_result)
         #get the ip address associated with the generated name with an ip address in new_true_domains.txt
         self.sent_to = "to_ipv4"
     elif isinstance(self.state, StartState) and ":" in self.sent_to:
         self.state = do_state_change("to_ipv6", log, self.dyn_classes, self.get_test_result)
         self.sent_to = "to_ipv6"
     if check_a(log.rec_queried) and log.level != None and log.level == "b":
         if log.rec_queried == "A": #ipv4
             if self.state.name == "queried_AAAA":
                 self.state = do_state_change("queried_both", log, self.dyn_classes, self.get_test_result)
                 self.queried = "queried_both"
             else:
                 self.state = do_state_change("queried_A", log, self.dyn_classes, self.get_test_result)
                 self.queried = "queried_A"
         elif log.rec_queried == "AAAA": #ipv6
             if self.state.name == "queried_A":
                 self.state = do_state_change("queried_both", log, self.dyn_classes, self.get_test_result)
                 self.queried = "queried_both"
             else:
                 self.state = do_state_change("queried_AAAA", log, self.dyn_classes, self.get_test_result)
                 self.queried = "queried_AAAA"
Exemple #6
0
 def test_def(self, log):
     #print(str(log))
     # b means we have succeeded, all other queries are fine, no need to check
     if isinstance(
             self.state,
             StartState) and log.rec_queried == "TXT" and log.level == None:
         self.state = BaseState(log, self.get_test_result)
     elif isinstance(
             self.state,
             BaseState) and log.level == "l1" and log.rec_queried == "TXT":
         self.state = do_state_change("l1", log, self.dyn_classes,
                                      self.get_test_result)
     elif self.state.name == "l1" and log.level == "b" and check_a(
             log.rec_queried):
         self.state = SuccessState(log, self.get_test_result)
Exemple #7
0
 def test_def(self, log):
     try:
         #print(str(log))
         if isinstance(self.state, StartState
                       ) and log.level is None and log.rec_queried == "TXT":
             self.state = BaseState(log, self.get_test_result)
         elif log.level == "b" and check_a(
                 log.rec_queried) and self.last_level != "b":
             self.counter += 1
         elif log.level is None or log.level == "b":
             pass
         else:
             self.state = do_state_change(log.level, log, self.dyn_classes,
                                          self.get_test_result)
         self.last_level = log.level
     except Exception as e:
         print("----Error: %s" % str(e))
Exemple #8
0
 def test_def(self, log):
     #print(str(log))
     if log.level is not None:
         if log.level[:1] == "l":
             level_num = int(log.level[1:])
             if level_num > self.highest_level:
                 self.highest_level = level_num
     #print(self.highest_level)
     class_level = self.switch_method(self.highest_level)
     #print("upper class levels: %s" % class_level)
     if class_level == None:
         if isinstance(self.state, StartState
                       ) and log.rec_queried == "TXT" and log.level == None:
             self.state = BaseState(log, self.get_test_result)
         else:
             pass
     else:
         self.state = do_state_change(class_level, log, self.dyn_classes,
                                      self.get_test_result)
Exemple #9
0
    def test_def(self, log):
        #print(str(log))
        if isinstance(
                self.state,
                StartState) and log.rec_queried == "TXT" and log.level is None:
            self.state = BaseState(log, self.get_test_result)

        # check branches from base state
        if isinstance(self.state, BaseState) or isinstance(
                self.state, StartState):
            if log.level == "l1" and log.rec_queried == "TXT":
                self.state = do_state_change("l1", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "b" and check_a(log.rec_queried):
                self.state = do_state_change("b_t04_a", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "l2" and log.rec_queried == "TXT":
                self.state = do_state_change("l2", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "l3" and log.rec_queried == "TXT":
                self.state = do_state_change("l3", log, self.dyn_classes,
                                             self.get_test_result)

        # check branches from l1
        elif self.state.name == "l1":
            if log.rec_queried == "TXT":
                if log.level == "l2":
                    self.state = do_state_change("l2", log, self.dyn_classes,
                                                 self.get_test_result)
                elif log.level == "l3":
                    self.state = do_state_change("l3", log, self.dyn_classes,
                                                 self.get_test_result)
            elif check_a(log.rec_queried) and log.level == "b":
                self.state = do_state_change("b_t04_a", log, self.dyn_classes,
                                             self.get_test_result)

        # check branch from l3
        elif self.state.name == "l3" and log.level == "b" and check_a(
                log.rec_queried):
            self.state = do_state_change("serial", log, self.dyn_classes,
                                         self.get_test_result)  # Success
            self.is_serial[log.generated_name] = True

        # check branches from l2
        elif self.state.name == "l2":
            if log.level == "l3" and log.rec_queried == "TXT":
                self.state = do_state_change("l3", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "b" and check_a(log.rec_queried):
                self.state = do_state_change("maybe_serial", log,
                                             self.dyn_classes,
                                             self.get_test_result)  # Success

        # check branch from maybe_Serial
        elif self.state.name == "maybe_serial" and log.level == "l3" and log.rec_queried == "TXT":
            self.state = do_state_change("delayed_parallel", log,
                                         self.dyn_classes,
                                         self.get_test_result)  # Success

        # check branch from b_t04_a
        elif self.state.name == "b_t04_a" and log.rec_queried == "TXT":
            if log.level == "l1":
                self.state = do_state_change("p_l1", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "l2":
                self.state = do_state_change("p_l2", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "l3":
                self.state = do_state_change("parallel", log, self.dyn_classes,
                                             self.get_test_result)  # Success

        # check branch from p_l1
        elif self.state.name == "p_l1" and log.rec_queried == "TXT":
            if log.rec_queried == "l2":
                self.state = do_state_change("p_l2", log, self.dyn_classes,
                                             self.get_test_result)
            elif log.level == "l3":
                self.state = do_state_change("parallel", log, self.dyn_classes,
                                             self.get_test_result)  # Success
        elif self.state.name == "p_l2" and log.level == "l3" and log.rec_queried == "TXT":
            self.state = do_state_change("parallel", log, self.dyn_classes,
                                         self.get_test_result)  # Success