def test(self, init): # Setup server = SCIONDnsServer("srvid", "conf_dir") srv_domain = self.DOMAIN.add(BEACON_SERVICE) server.services = {srv_domain: ["addr0"]} # Call server._parse_srv_inst("name\0port\0addr1\0addr2", srv_domain) # Tests ntools.eq_(server.services[srv_domain], ["addr0", "addr1", "addr2"])
def test_success(self, init): # Setup services = { BEACON_SERVICE: ["bs1", "bs2", "bs3"], CERTIFICATE_SERVICE: ["cs1"], DNS_SERVICE: ["ds1", "ds2"], PATH_SERVICE: [], SIBRA_SERVICE: ["sb1"], } server = SCIONDnsServer("srvid", "conf_dir") server.zk = create_mock(['wait_connected']) server.domain = self.DOMAIN server._parties = {} for i in SCIONDnsServer.SRV_TYPES: party = create_mock(["list"]) party.list.return_value = services[i] server._parties[i] = party server._parse_srv_inst = create_mock() server.lock = create_mock(['__enter__', '__exit__']) server.resolver = create_mock(["services"]) domain_set = set( [self.DOMAIN.add(srv) for srv in SCIONDnsServer.SRV_TYPES]) # Call server._sync_zk_state() # Tests server.zk.wait_connected.assert_called_once_with(timeout=10.0) ntools.eq_(domain_set, set(server.services)) for type_, insts in services.items(): for inst in insts: server._parse_srv_inst.assert_any_call(inst, self.DOMAIN.add(type_)) ntools.ok_(server.lock.mock_calls) ntools.eq_(server.resolver.services, server.services)