Ejemplo n.º 1
0
def test_parse_frame_length0(buf):
    p = parse_frame(buf)
    next(p)
    try:
        p.send(struct.pack('!BB', 0b00000001, 0b00000000))
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'') == (fin, opcode, payload)
def test_parse_frame_length0(buf):
    p = parse_frame(buf)
    next(p)
    try:
        p.send(struct.pack('!BB', 0b00000001, 0b00000000))
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'') == (fin, opcode, payload)
def test_parse_frame_length2(buf):
    p = parse_frame(buf)
    next(p)
    p.send(struct.pack('!BB', 0b00000001, 126))
    p.send(struct.pack('!H', 4))
    try:
        p.send(b'1234')
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'1234') == (fin, opcode, payload)
def test_parse_frame_mask(buf):
    p = parse_frame(buf)
    next(p)
    p.send(struct.pack('!BB', 0b00000001, 0b10000001))
    p.send(b'0001')
    try:
        p.send(b'1')
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'\x01') == (fin, opcode, payload)
Ejemplo n.º 5
0
def test_parse_frame_length2(buf):
    p = parse_frame(buf)
    next(p)
    p.send(struct.pack('!BB', 0b00000001, 126))
    p.send(struct.pack('!H', 4))
    try:
        p.send(b'1234')
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'1234') == (fin, opcode, payload)
Ejemplo n.º 6
0
def test_parse_frame_mask(buf):
    p = parse_frame(buf)
    next(p)
    p.send(struct.pack('!BB', 0b00000001, 0b10000001))
    p.send(b'0001')
    try:
        p.send(b'1')
    except StopIteration as exc:
        fin, opcode, payload = exc.value

    assert (0, 1, b'\x01') == (fin, opcode, payload)
def test_parse_frame_header_payload_size(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b10001000, 0b01111110))
def test_parse_frame_header_new_data_err(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b000000000, 0b00000000))
def test_parse_frame_header_continuation(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b00000000, 0b00000000))
def test_parse_frame_header_reversed_bits(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b01100000, 0b00000000))
Ejemplo n.º 11
0
def test_parse_frame_header_payload_size(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b10001000, 0b01111110))
Ejemplo n.º 12
0
def test_parse_frame_header_new_data_err(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b000000000, 0b00000000))
Ejemplo n.º 13
0
def test_parse_frame_header_continuation(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b00000000, 0b00000000))
Ejemplo n.º 14
0
def test_parse_frame_header_reversed_bits(buf):
    p = parse_frame(buf)
    next(p)
    with pytest.raises(WebSocketError):
        p.send(struct.pack('!BB', 0b01100000, 0b00000000))