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")
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)
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", )
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
def test_tlv_none(self): pd = ProxyData(version=2) assert pd.tlv is None
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")
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")
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)
def test_invalid_protocol(self): pd = ProxyData(version=1) assert not pd.valid assert not pd
def test_invalid_error(self): pd = ProxyData(version=1) pd.error = "SomeError" assert not pd.valid assert not pd
def test_invalid_version(self): pd = ProxyData(version=None) assert not pd.valid assert not pd