Example #1
0
 def get_path(self, dst_isd_as):
     lib_sciond.init(get_sciond_api_addr(self.addr))
     replies = lib_sciond.get_paths(dst_isd_as)
     if not replies:
         return None
     # TODO(PSz): Very hacky to avoid changing scion_elem and/or giving topo files for
     # every element.
     path = replies[0].path().fwd_path()
     ifid = path.get_fwd_if()
     if ifid not in self.ifid2br:
         br = Element()
         br.addr = replies[0].first_hop().ipv4()
         br.port = replies[0].first_hop().p.port
         self.ifid2br[ifid] = br
     return path
Example #2
0
 def test_name(self):
     name = create_mock(["__str__"])
     name.__str__.return_value = "hostname"
     # Call
     inst = Element(name=name)
     # Tests
     ntools.assert_equal(inst.name, "hostname")
Example #3
0
 def test_bind(self, parse):
     bind = {'IPv4': {'Bind': {'Addr': 'pub_addr', 'L4Port': 'port'},
                      'Public': {'Addr': 'bind_addr', 'L4Port': 'port'}}}
     inst = Element(bind)
     parse.assert_has_calls([call('bind_addr'), call('pub_addr')])
     ntools.eq_(inst.bind[0], parse.return_value)
     ntools.eq_(inst.public[1], 'port')
Example #4
0
 def test_public(self, parse):
     public = {'IPv4': {'Public': {'Addr': 'addr', 'L4Port': 'port'}}}
     inst = Element(public)
     parse.assert_called_with("addr")
     ntools.eq_(inst.public[0], parse.return_value)
     ntools.eq_(inst.public[1], 'port')
Example #5
0
 def test_basic(self):
     inst = Element()
     ntools.assert_equal(inst.public, None)
     ntools.assert_is_none(inst.name)
Example #6
0
 def test_bind(self, parse):
     bind = {'Addr': 'addr', 'L4Port': 'port'}
     inst = Element(bind=bind)
     parse.assert_called_with("addr")
     ntools.eq_(inst.bind[0][0], parse.return_value)
Example #7
0
 def test_addr(self, parse):
     inst = Element("addr")
     parse.assert_called_with("addr")
     ntools.eq_(inst.addr, parse.return_value)
Example #8
0
 def test_basic(self):
     inst = Element()
     ntools.assert_is_none(inst.addr)
     ntools.assert_is_none(inst.name)