def test_good_test_add_rule(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        valid_rule = UserPolicyStandin(True, True)

        #FIXME
        man.test_add_rule(valid_rule)
    def test_good_add_rule(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        valid_rule = UserPolicyStandin(True, True)

        #        print man.add_rule(valid_rule)
        self.failUnless(isinstance(man.add_rule(valid_rule), int))
    def test_get_rules(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        valid_rule = UserPolicyStandin(True, True)

        hash = man.add_rule(valid_rule)
        self.failUnless(man.get_rules() != [])
    def test_singleton(self, restapi, cxm):
        part = ParticipantManager(PART_CONFIG_FILE)
        topo = TopologyManager(TOPO_CONFIG_FILE)
        lc = LocalControllerManager(TOPO_CONFIG_FILE)
        firstManager = SDXController()
        secondManager = SDXController()

        self.failUnless(firstManager is secondManager)
    def test_good_remove_rule(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        valid_rule = UserPolicyStandin(True, True)

        #FIXME
        hash = man.add_rule(valid_rule)
        man.get_rule_details(hash)
        self.failUnless(man.get_rule_details(hash) != None)

        man.remove_rule(hash, "dummy_user")
        self.failUnless(man.get_rule_details(hash) == None)
    def test_remove_all_rules(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        valid_rule = UserPolicyStandin(True, True)

        # Add a rule.
        man.add_rule(valid_rule)

        self.failUnless(man.get_rules() != [])

        man.remove_all_rules("dummy_user")

        rules = man.get_rules()
        self.failUnless(man.get_rules() == [])
    def test_add_and_remove_no_exception(self, restapi, cxm):

        part = ParticipantManager(PART_CONFIG_FILE)
        topo = TopologyManager(TOPO_CONFIG_FILE)
        lc = LocalControllerManager(TOPO_CONFIG_FILE)
        sdxctlr = SDXController()

        man = RuleManager()
        valid_rule = UserPolicyStandin(True, True)

        sdxctlr._send_breakdown_rule = mock.MagicMock()

        rule_num = man.add_rule(valid_rule)

        man.remove_rule(rule_num, 'sdonovan')
示例#8
0
    def setUpClass(cls, restapi):
        # Lovingly stolen from the the Local Controller tests.

        print "Set up virtual switch"
        subprocess.check_call(['mn', '-c'],
                              stdout=FNULL,
                              stderr=subprocess.STDOUT)
        subprocess.call(['fuser', '-k', '55767/tcp'],
                        stdout=FNULL,
                        stderr=subprocess.STDOUT)
        subprocess.call(['fuser', '-k', '55767/tcp'],
                        stdout=FNULL,
                        stderr=subprocess.STDOUT)
        subprocess.call(['fuser', '-k', '5555/tcp'],
                        stdout=FNULL,
                        stderr=subprocess.STDOUT)
        subprocess.call(['fuser', '-k', '5555/tcp'],
                        stdout=FNULL,
                        stderr=subprocess.STDOUT)
        subprocess.check_call(['ovs-vsctl', 'add-br', 'br_ovs'])
        subprocess.check_call([
            'ovs-vsctl', 'add-port', 'br_ovs', 'vi0', '--', 'set', 'Interface',
            'vi0', 'type=internal'
        ])
        subprocess.check_call([
            'ovs-vsctl', 'set', 'bridge', 'br_ovs',
            'other-config:datapath-id=0000000000000001'
        ])
        subprocess.check_call(
            ['ovs-vsctl', 'set-controller', 'br_ovs', 'tcp:127.0.0.1:6633'])
        print "Virtual switch is setup\n"

        # Setup RyuControllerInterface, which sets up RyuTranslateInterface
        # Only returns once RyuTranslateInterface has a datapath.
        part = ParticipantManager(PART_CONFIG_FILE)
        topo = TopologyManager(TOPO_CONFIG_FILE)
        lc = LocalControllerManager(TOPO_CONFIG_FILE)
        cls.sdxctlr = SDXController()
        cls.ctlrint = LocalController()

        #        cls.ctlrint.start_sdx_controller_connection()
        while len(cls.sdxctlr.connections) == 0:
            print "Waiting for harness connection"
            sleep(1)
    def test_add_json_upload(self, restapi, cxm):

        part = ParticipantManager(PART_CONFIG_FILE)
        topo = TopologyManager(TOPO_CONFIG_FILE)
        lc = LocalControllerManager(TOPO_CONFIG_FILE)
        sdxctlr = SDXController()

        man = RuleManager()
        sdxctlr._send_breakdown_rule = mock.MagicMock()

        # Get a JSON policy from a file
        with open(JSON_POLICY_FILE) as datafile:
            # Based on: https://stackoverflow.com/questions/8369219/how-do-i-read-a-text-file-into-a-string-variable-in-python
            data = json.load(datafile)
            #data = datafile.read().replace('\n', '')
        valid_rule = JsonUploadPolicy('sdonovan', data)

        rule_num = man.add_rule(valid_rule)
        man.remove_rule(rule_num, 'sdonovan')
 def test_bad_valid(self):
     invalid_rule = UserPolicyStandin(False, "")
     topo = TopologyManager(TOPO_CONFIG_FILE)
     engine = BreakdownEngine()
     self.failUnlessRaises(Exception, engine.get_breakdown, invalid_rule)
 def test_good_valid(self):
     valid_rule = UserPolicyStandin(True, "")
     topo = TopologyManager(TOPO_CONFIG_FILE)
     engine = BreakdownEngine()
     self.failUnless(engine.get_breakdown(valid_rule))
    def test_singleton(self):
        topo = TopologyManager(TOPO_CONFIG_FILE)
        first = BreakdownEngine()
        second = BreakdownEngine()

        self.failUnless(first is second)
    def test_invalid_add_rule(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        man = RuleManager.instance(db, rmhappy, rmhappy)
        invalid_rule = UserPolicyStandin(False, True)

        self.failUnlessRaises(Exception, man.add_rule, invalid_rule)
    def test_singleton(self):
        topo = TopologyManager.instance(TOPO_CONFIG_FILE)
        firstManager = RuleManager.instance(db, rmhappy, rmhappy)
        secondManager = RuleManager.instance(db, rmhappy, rmhappy)

        self.failUnless(firstManager is secondManager)
    def test_singleton(self):
        topo = TopologyManager(TOPO_CONFIG_FILE)
        firstInspector = ValidityInspector()
        secondInspector = ValidityInspector()

        self.failUnless(firstInspector is secondInspector)