Beispiel #1
0
    def test_masker(self, input, expected):
        m = websockets.Masker(b"abcd")
        data = b"".join([m(t) for t in input])
        assert data == codecs.decode(expected, 'hex')

        data = websockets.Masker(b"abcd")(data)
        assert data == b"".join(input)
def test_masker():
    tests = [
        [b"a"],
        [b"four"],
        [b"fourf"],
        [b"fourfive"],
        [b"a", b"aasdfasdfa", b"asdf"],
        [b"a" * 50, b"aasdfasdfa", b"asdf"],
    ]
    for i in tests:
        m = websockets.Masker(b"abcd")
        data = b"".join([m(t) for t in i])
        data2 = websockets.Masker(b"abcd")(data)
        assert data2 == b"".join(i)