def test_stream_dont(stream_parser): events = stream_parser.stream_updates( [Tokenizer.Option(B.DONT, OPTIONS.TM, OPTIONS.TM.value)] ) assert events == [ StreamParser.OptionNegotiation( OPTIONS.TM, OPTIONS.TM.value, StreamParser.Host.LOCAL, False ) ]
def test_stream_sb(stream_parser): events = stream_parser.stream_updates( [ Tokenizer.Option(B.SB, None, 42), Tokenizer.StreamData(b"1234"), Tokenizer.Command(B.SE, B.SE.value), ] ) assert events == [StreamParser.OptionSubnegotiation(None, 42)]
def test_split_option(tokenizer): toks = tokenizer.tokens(b"abc" + B.IAC.byte + B.WONT.byte) assert toks == [Tokenizer.StreamData(b"abc")] toks = tokenizer.tokens(bytes([42]) + b"def") assert toks == [Tokenizer.Option(B.WONT, None, 42), Tokenizer.StreamData(b"def")]
def test_tokenizer_option_unrecognized(tokenizer): toks = tokenizer.tokens(B.IAC.byte + B.WILL.byte + bytes([42])) assert toks == [Tokenizer.Option(B.WILL.value, None, 42)]
def test_tokenizer_option_recognized(tokenizer): toks = tokenizer.tokens(B.IAC.byte + B.WILL.byte + OPTIONS.TM.byte) assert toks == [Tokenizer.Option(B.WILL.value, OPTIONS.TM, OPTIONS.TM.value)]
def test_stream_wont(stream_parser): events = stream_parser.stream_updates([Tokenizer.Option(B.WONT, None, 42)]) assert events == [ StreamParser.OptionNegotiation(None, 42, StreamParser.Host.PEER, False) ]
def test_stream_will(stream_parser): events = stream_parser.stream_updates([Tokenizer.Option(B.WILL, None, 42)]) assert events == [ StreamParser.OptionNegotiation(None, 42, StreamParser.Host.PEER, True) ]