def test_non_setup(self, super_addhop): inst = SibraExtSteady() inst.setup = False # Call inst._add_hop("key") # Tests super_addhop.assert_called_once_with(inst, "key")
def _check_setup(self, cons_dir): inst = SibraExtSteady() inst._get_prev_raw = create_mock() inst.setup = True inst.path_ids = "path ids" iof = create_mock(["cons_dir_flag"]) iof.cons_dir_flag = cons_dir hof = create_mock(["egress_if", "ingress_if"]) path = create_mock(["get_hof", "get_iof"]) path.get_iof.return_value = iof path.get_hof.return_value = hof spkt = create_mock(["path"]) spkt.path = path req = create_mock(["add_hop"]) inst.req_block = req # Call inst._add_hop("key", spkt) # Tests if cons_dir: req.add_hop.assert_called_once_with( hof.ingress_if, hof.egress_if, inst._get_prev_raw.return_value, "key", "path ids") else: req.add_hop.assert_called_once_with( hof.egress_if, hof.ingress_if, inst._get_prev_raw.return_value, "key", "path ids")
def __init__(self, addr, port, sendq, signing_key, link_type, state, seg, bwsnap): """ :param ScionAddr addr: the address of this sibra server :param queue.Queue sendq: packets written to this queue will be sent by the sibra server thread. :param bytes signing_key: AS signing key. :param str link_type: Type of link (PARENT/ROUTING/etc) :param SibraState state: SibraState object for the local interface. :param PathSegment seg: path segment to use. :param BWSnapshot bwsnap: initial bandwidth to request. """ self.addr = addr self._port = port self.sendq = sendq self.signing_key = signing_key self.link_type = link_type self.state = state self.seg = seg self.bw = bwsnap.to_classes().ceil() self.id = SibraExtSteady.mk_path_id(self.addr.isd_as) self.idx = 0 self.blocks = [] self.remote = self.seg.first_ia() self._lock = threading.RLock() self._stamp = None
def _create_ext_setup(self): """ Create a SIBRA extension for path setup """ info = self._create_info() return SibraExtSteady.setup_from_values(info, self.seg.get_n_hops(), self.id)
def test(self): inst = SibraExtSteady() inst._parse_start = create_mock() inst._parse_start.return_value = "data", "req" inst._parse_path_id = create_mock() inst._parse_block = create_mock() inst._parse_end = create_mock() inst.path_lens = [5, 0, 0] # Call inst._parse("raw") # Tests inst._parse_start.assert_called_once_with("raw") inst._parse_path_id.assert_called_once_with("data") ntools.eq_(inst.path_ids, [inst._parse_path_id.return_value]) inst._parse_block.assert_called_once_with("data", 5) ntools.eq_(inst.active_blocks, [inst._parse_block.return_value]) inst._parse_end.assert_called_once_with("data", "req")
def _create_ext_use(self): """ Create a SIBRA extension for path use """ return SibraExtSteady.use_from_values(self.id, self.blocks[0])
def parse_sibra_ext(raw): # pragma: no cover flag = raw[0] if flag & FLAG_STEADY: return SibraExtSteady(raw) else: return SibraExtEphemeral(raw)