Mercurial > prosody-hg
comparison spec/net_websocket_frames_spec.lua @ 11166:51e5149ed0ad
Merge 0.11->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 15 Oct 2020 14:25:09 +0100 |
| parents | 0c464bb7eb03 eae8046d51fc |
| children |
comparison
equal
deleted
inserted
replaced
| 11161:f51ed2652602 | 11166:51e5149ed0ad |
|---|---|
| 30 ["MASK"] = false; | 30 ["MASK"] = false; |
| 31 ["RSV1"] = false; | 31 ["RSV1"] = false; |
| 32 ["RSV2"] = false; | 32 ["RSV2"] = false; |
| 33 ["RSV3"] = false; | 33 ["RSV3"] = false; |
| 34 }; | 34 }; |
| 35 masked_data = { | 35 with_mask = { |
| 36 ["opcode"] = 0; | 36 ["opcode"] = 0; |
| 37 ["length"] = 5; | 37 ["length"] = 5; |
| 38 ["data"] = "hello"; | 38 ["data"] = "hello"; |
| 39 ["key"] = " \0 \0"; | |
| 39 ["FIN"] = true; | 40 ["FIN"] = true; |
| 40 ["MASK"] = true; | 41 ["MASK"] = true; |
| 41 ["RSV1"] = false; | 42 ["RSV1"] = false; |
| 42 ["RSV2"] = false; | 43 ["RSV2"] = false; |
| 43 ["RSV3"] = false; | 44 ["RSV3"] = false; |
| 44 ["key"] = { 0x20, 0x20, 0x20, 0x20, }; | 45 }; |
| 46 empty_with_mask = { | |
| 47 ["opcode"] = 0; | |
| 48 ["key"] = " \0 \0"; | |
| 49 ["FIN"] = true; | |
| 50 ["MASK"] = true; | |
| 51 ["RSV1"] = false; | |
| 52 ["RSV2"] = false; | |
| 53 ["RSV3"] = false; | |
| 45 }; | 54 }; |
| 46 ping = { | 55 ping = { |
| 47 ["opcode"] = 0x9; | 56 ["opcode"] = 0x9; |
| 48 ["length"] = 4; | 57 ["length"] = 4; |
| 49 ["data"] = "ping"; | 58 ["data"] = "ping"; |
| 69 local build = nwf.build; | 78 local build = nwf.build; |
| 70 it("works", function () | 79 it("works", function () |
| 71 assert.equal("\0\0", build(test_frames.simple_empty)); | 80 assert.equal("\0\0", build(test_frames.simple_empty)); |
| 72 assert.equal("\0\5hello", build(test_frames.simple_data)); | 81 assert.equal("\0\5hello", build(test_frames.simple_data)); |
| 73 assert.equal("\128\0", build(test_frames.simple_fin)); | 82 assert.equal("\128\0", build(test_frames.simple_fin)); |
| 74 assert.equal("\128\133 HELLO", build(test_frames.masked_data)); | 83 assert.equal("\128\133 \0 \0HeLlO", build(test_frames.with_mask)) |
| 84 assert.equal("\128\128 \0 \0", build(test_frames.empty_with_mask)) | |
| 75 assert.equal("\137\4ping", build(test_frames.ping)); | 85 assert.equal("\137\4ping", build(test_frames.ping)); |
| 76 assert.equal("\138\4pong", build(test_frames.pong)); | 86 assert.equal("\138\4pong", build(test_frames.pong)); |
| 77 end); | 87 end); |
| 78 end); | 88 end); |
| 79 | 89 |
| 81 local parse = nwf.parse; | 91 local parse = nwf.parse; |
| 82 it("works", function () | 92 it("works", function () |
| 83 assert.same(test_frames.simple_empty, parse("\0\0")); | 93 assert.same(test_frames.simple_empty, parse("\0\0")); |
| 84 assert.same(test_frames.simple_data, parse("\0\5hello")); | 94 assert.same(test_frames.simple_data, parse("\0\5hello")); |
| 85 assert.same(test_frames.simple_fin, parse("\128\0")); | 95 assert.same(test_frames.simple_fin, parse("\128\0")); |
| 86 assert.same(test_frames.masked_data, parse("\128\133 HELLO")); | 96 assert.same(test_frames.with_mask, parse("\128\133 \0 \0HeLlO")); |
| 87 assert.same(test_frames.ping, parse("\137\4ping")); | 97 assert.same(test_frames.ping, parse("\137\4ping")); |
| 88 assert.same(test_frames.pong, parse("\138\4pong")); | 98 assert.same(test_frames.pong, parse("\138\4pong")); |
| 89 end); | 99 end); |
| 90 end); | 100 end); |
| 91 | 101 |
