Exemplo n.º 1
0
 def test_eq(self):
     data1 = b"\x03\x00\x04Z\xfd\xc6\xff\x02\x00\tAUTHORITI"
     ptlv1 = ProxyTLV.from_raw(data1)
     data2 = b"\x02\x00\tAUTHORITI\x03\x00\x04Z\xfd\xc6\xff"
     ptlv2 = ProxyTLV.from_raw(data2)
     assert ptlv1 is not ptlv2
     assert ptlv1 == ptlv2
Exemplo n.º 2
0
 def test_1_ne_raises(self):
     ptlv = ProxyTLV.from_raw(TEST_TLV_DATA_1)
     expectre = r"mismatch:AUTHORITY actual=.* expect=.*"
     with pytest.raises(ValueError, match=expectre):
         ptlv.same_attribs(_raises=True, AUTHORITY=b"whut")
     expectre = r"notfound:i_dont_even"
     with pytest.raises(KeyError, match=expectre):
         ptlv.same_attribs(_raises=True, i_dont_even=b"what is this")
Exemplo n.º 3
0
 def test_1(self):
     ptlv = ProxyTLV.from_raw(TEST_TLV_DATA_1)
     assert "ALPN" not in ptlv
     assert "NOOP" not in ptlv
     assert "SSL_CN" not in ptlv
     assert "NETNS" not in ptlv
     assert ptlv.ALPN is None
     assert ptlv.AUTHORITY == b"AUTHORITI"
     assert ptlv.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",
     )
Exemplo n.º 4
0
 def test_2(self):
     ptlv = ProxyTLV.from_raw(TEST_TLV_DATA_2)
     assert "ALPN" not in ptlv
     assert "NOOP" not in ptlv
     assert "SSL_CN" not in ptlv
     assert "NETNS" in ptlv
     assert ptlv.ALPN is None
     assert ptlv.AUTHORITY == b"AUTHORIT2"
     assert ptlv.UNIQUE_ID == b"UNIQUEID2"
     assert ptlv.same_attribs(
         CRC32C=b"Z\xfd\xc6\xff",
         UNIQUE_ID=b"UNIQUEID2",
         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",
         NETNS=b"something",
     )
     assert not ptlv.same_attribs(false_attrib=None)
     with pytest.raises(ValueError, match=r"mismatch:SSL"):
         ptlv.same_attribs(SSL=False, _raises=True)
Exemplo n.º 5
0
 def test_1_ne(self):
     ptlv = ProxyTLV.from_raw(TEST_TLV_DATA_1)
     assert not ptlv.same_attribs(SSL=False)
     assert not ptlv.same_attribs(false_attrib=None)