Ejemplo n.º 1
0
 def test_unknownkey_raises(self):
     pd = ProxyData(version=1)
     pd.protocol = PROTO.UNSPEC
     assert pd.valid
     assert pd
     expectre = r"notfound:strange_key"
     with pytest.raises(KeyError, match=expectre):
         pd.same_attribs(_raises=True, strange_key="Unrecognized")
Ejemplo n.º 2
0
 def test_mismatch_raises(self):
     pd = ProxyData(version=1)
     pd.protocol = PROTO.UNSPEC
     assert pd.valid
     assert pd
     expectre = r"mismatch:protocol actual=.* expect=.*"
     with pytest.raises(ValueError, match=expectre):
         pd.same_attribs(_raises=True, protocol=PROTO.STREAM)
Ejemplo n.º 3
0
 def test_tlv_1(self):
     pd = ProxyData(version=2)
     pd.rest = TEST_TLV_DATA_1
     assert pd.tlv is not None
     assert pd.tlv.same_attribs(
         AUTHORITY=b"AUTHORITI",
         CRC32C=b"Z\xfd\xc6\xff",
         UNIQUE_ID=b"UNIKUE_ID",
         SSL=True,
         SSL_VERSION=b"TLSv1.3",
         SSL_CIPHER=b"ECDHE-RSA-AES256-CBC-SHA384",
         SSL_SIG_ALG=b"RSA-SHA256",
         SSL_KEY_ALG=b"RSA4096",
     )
Ejemplo n.º 4
0
 def test_tlv_fake(self):
     pd = ProxyData(version=2)
     pd.rest = b"fake_tlv"  # Must be something that fails parsing in ProxyTLV
     assert pd.tlv is None
Ejemplo n.º 5
0
 def test_tlv_none(self):
     pd = ProxyData(version=2)
     assert pd.tlv is None
Ejemplo n.º 6
0
 def test_unknownkey(self):
     pd = ProxyData(version=1)
     pd.protocol = PROTO.UNSPEC
     assert pd.valid
     assert pd
     assert not pd.same_attribs(strange_key="Unrecognized")
Ejemplo n.º 7
0
 def test_unsetkey(self):
     pd = ProxyData(version=1)
     pd.protocol = PROTO.UNSPEC
     assert pd.valid
     assert pd
     assert not pd.same_attribs(src_addr="Missing")
Ejemplo n.º 8
0
 def test_mismatch(self):
     pd = ProxyData(version=1)
     pd.protocol = PROTO.UNSPEC
     assert pd.valid
     assert pd
     assert not pd.same_attribs(protocol=PROTO.STREAM)
Ejemplo n.º 9
0
 def test_invalid_protocol(self):
     pd = ProxyData(version=1)
     assert not pd.valid
     assert not pd
Ejemplo n.º 10
0
 def test_invalid_error(self):
     pd = ProxyData(version=1)
     pd.error = "SomeError"
     assert not pd.valid
     assert not pd
Ejemplo n.º 11
0
 def test_invalid_version(self):
     pd = ProxyData(version=None)
     assert not pd.valid
     assert not pd