当前位置: 首页>>代码示例>>Python>>正文


Python mocking.get_bridge_server_descriptor函数代码示例

本文整理汇总了Python中test.mocking.get_bridge_server_descriptor函数的典型用法代码示例。如果您正苦于以下问题:Python get_bridge_server_descriptor函数的具体用法?Python get_bridge_server_descriptor怎么用?Python get_bridge_server_descriptor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_bridge_server_descriptor函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_router_digest

 def test_router_digest(self):
   """
   Constructs with a router-digest line with both valid and invalid contents.
   """
   
   # checks with valid content
   
   router_digest = "068A2E28D4C934D9490303B7A645BA068DCA0504"
   desc = get_bridge_server_descriptor({"router-digest": router_digest})
   self.assertEquals(router_digest, desc.digest())
   
   # checks when missing
   
   desc_text = get_bridge_server_descriptor(exclude = ["router-digest"], content = True)
   self.assertRaises(ValueError, BridgeDescriptor, desc_text)
   
   # check that we can still construct it without validation
   desc = BridgeDescriptor(desc_text, validate = False)
   self.assertEquals(None, desc.digest())
   
   # checks with invalid content
   
   test_values = (
     "",
     "006FD96BA35E7785A6A3B8B75FE2E2435A13BDB44",
     "006FD96BA35E7785A6A3B8B75FE2E2435A13BDB",
     "006FD96BA35E7785A6A3B8B75FE2E2435A13BDBH",
   )
   
   for value in test_values:
     desc_text = get_bridge_server_descriptor({"router-digest": value}, content = True)
     self.assertRaises(ValueError, BridgeDescriptor, desc_text)
     
     desc = BridgeDescriptor(desc_text, validate = False)
     self.assertEquals(value, desc.digest())
开发者ID:abcdef123,项目名称:stem,代码行数:35,代码来源:server_descriptor.py

示例2: test_or_address_v6

 def test_or_address_v6(self):
   """
   Constructs a bridge descriptor with a sanatized IPv6 or-address entry.
   """
   
   desc = get_bridge_server_descriptor({"or-address": "[fd9f:2e19:3bcf::02:9970]:9001"})
   self.assertEquals([("fd9f:2e19:3bcf::02:9970", 9001, True)], desc.address_alt)
开发者ID:abcdef123,项目名称:stem,代码行数:7,代码来源:server_descriptor.py

示例3: test_or_address_v4

 def test_or_address_v4(self):
   """
   Constructs a bridge descriptor with a sanatized IPv4 or-address entry.
   """
   
   desc = get_bridge_server_descriptor({"or-address": "10.45.227.253:9001"})
   self.assertEquals([("10.45.227.253", 9001, False)], desc.address_alt)
开发者ID:abcdef123,项目名称:stem,代码行数:7,代码来源:server_descriptor.py

示例4: test_or_address_v6

  def test_or_address_v6(self):
    """
    Constructs a bridge descriptor with a sanatized IPv6 or-address entry.
    """

    desc = get_bridge_server_descriptor({'or-address': '[fd9f:2e19:3bcf::02:9970]:9001'})
    self.assertEqual([('fd9f:2e19:3bcf::02:9970', 9001, True)], desc.or_addresses)
开发者ID:sammyshj,项目名称:stem,代码行数:7,代码来源:server_descriptor.py

示例5: test_or_address_v4

  def test_or_address_v4(self):
    """
    Constructs a bridge descriptor with a sanatized IPv4 or-address entry.
    """

    desc = get_bridge_server_descriptor({'or-address': '10.45.227.253:9001'})
    self.assertEqual([('10.45.227.253', 9001, False)], desc.or_addresses)
开发者ID:sammyshj,项目名称:stem,代码行数:7,代码来源:server_descriptor.py

示例6: test_multiple_descriptor_types

 def test_multiple_descriptor_types(self):
   """
   Attempts to make a csv with multiple descriptor types.
   """
   
   server_desc = get_relay_server_descriptor()
   bridge_desc = get_bridge_server_descriptor()
   self.assertRaises(ValueError, export_csv, (server_desc, bridge_desc))
开发者ID:abcdef123,项目名称:stem,代码行数:8,代码来源:export.py

示例7: test_minimal_bridge_descriptor

 def test_minimal_bridge_descriptor(self):
   """
   Basic sanity check that we can parse a descriptor with minimal attributes.
   """
   
   desc = get_bridge_server_descriptor()
   
   self.assertEquals("Unnamed", desc.nickname)
   self.assertEquals("10.45.227.253", desc.address)
   self.assertEquals(None, desc.fingerprint)
   self.assertEquals("006FD96BA35E7785A6A3B8B75FE2E2435A13BDB4", desc.digest())
   
   # check that we don't have crypto fields
   self.assertRaises(AttributeError, getattr, desc, "onion_key")
   self.assertRaises(AttributeError, getattr, desc, "signing_key")
   self.assertRaises(AttributeError, getattr, desc, "signature")
开发者ID:abcdef123,项目名称:stem,代码行数:16,代码来源:server_descriptor.py

示例8: test_or_address_multiple

  def test_or_address_multiple(self):
    """
    Constructs a bridge descriptor with multiple or-address entries and multiple ports.
    """

    desc_text = b'\n'.join((get_bridge_server_descriptor(content = True),
                            b'or-address 10.45.227.253:9001',
                            b'or-address [fd9f:2e19:3bcf::02:9970]:443'))

    expected_or_addresses = [
      ('10.45.227.253', 9001, False),
      ('fd9f:2e19:3bcf::02:9970', 443, True),
    ]

    desc = BridgeDescriptor(desc_text)
    self.assertEqual(expected_or_addresses, desc.or_addresses)
开发者ID:sammyshj,项目名称:stem,代码行数:16,代码来源:server_descriptor.py

示例9: test_or_address_multiple

 def test_or_address_multiple(self):
   """
   Constructs a bridge descriptor with multiple or-address entries and multiple ports.
   """
   
   desc_text = "\n".join((get_bridge_server_descriptor(content = True),
                         "or-address 10.45.227.253:9001,9005,80",
                         "or-address [fd9f:2e19:3bcf::02:9970]:443"))
   
   expected_address_alt = [
     ("10.45.227.253", 9001, False),
     ("10.45.227.253", 9005, False),
     ("10.45.227.253", 80, False),
     ("fd9f:2e19:3bcf::02:9970", 443, True),
   ]
   
   desc = BridgeDescriptor(desc_text)
   self.assertEquals(expected_address_alt, desc.address_alt)
开发者ID:abcdef123,项目名称:stem,代码行数:18,代码来源:server_descriptor.py

示例10: test_bridge_unsanitized

 def test_bridge_unsanitized(self):
   """
   Targeted check that individual unsanitized attributes will be detected.
   """
   
   unsanitized_attr = [
     {"router": "Unnamed 75.45.227.253 9001 0 0"},
     {"contact": "Damian"},
     {"or-address": "71.35.133.197:9001"},
     {"or-address": "[12ab:2e19:3bcf::02:9970]:9001"},
     {"onion-key": "\n-----BEGIN RSA PUBLIC KEY-----%s-----END RSA PUBLIC KEY-----" % CRYPTO_BLOB},
     {"signing-key": "\n-----BEGIN RSA PUBLIC KEY-----%s-----END RSA PUBLIC KEY-----" % CRYPTO_BLOB},
     {"router-signature": "\n-----BEGIN SIGNATURE-----%s-----END SIGNATURE-----" % CRYPTO_BLOB},
   ]
   
   for attr in unsanitized_attr:
     desc = get_bridge_server_descriptor(attr)
     self.assertFalse(desc.is_scrubbed())
开发者ID:abcdef123,项目名称:stem,代码行数:18,代码来源:server_descriptor.py

示例11: test_bridge_unsanitized

  def test_bridge_unsanitized(self):
    """
    Targeted check that individual unsanitized attributes will be detected.
    """

    unsanitized_attr = [
      {'router': 'Unnamed 75.45.227.253 9001 0 0'},
      {'contact': 'Damian'},
      {'or-address': '71.35.133.197:9001'},
      {'or-address': '[12ab:2e19:3bcf::02:9970]:9001'},
      {'onion-key': '\n-----BEGIN RSA PUBLIC KEY-----%s-----END RSA PUBLIC KEY-----' % CRYPTO_BLOB},
      {'signing-key': '\n-----BEGIN RSA PUBLIC KEY-----%s-----END RSA PUBLIC KEY-----' % CRYPTO_BLOB},
      {'router-signature': '\n-----BEGIN SIGNATURE-----%s-----END SIGNATURE-----' % CRYPTO_BLOB},
    ]

    for attr in unsanitized_attr:
      desc = get_bridge_server_descriptor(attr)
      self.assertFalse(desc.is_scrubbed())
开发者ID:sammyshj,项目名称:stem,代码行数:18,代码来源:server_descriptor.py


注:本文中的test.mocking.get_bridge_server_descriptor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。