Mercurial > prosody-hg
comparison spec/net_websocket_frames_spec.lua @ 11162:ee399a0522cc 0.11
net.websocket.frames: Add small test covering xor-masking
This is basically a recording of current behavior, to detect changes.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 14 Oct 2020 19:02:48 +0200 |
| parents | 7e75c348095b |
| children | 4e5a2af9dd19 |
comparison
equal
deleted
inserted
replaced
| 11159:de76f566159e | 11162:ee399a0522cc |
|---|---|
| 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 with_mask = { | |
| 36 ["opcode"] = 0; | |
| 37 ["length"] = 5; | |
| 38 ["data"] = "hello"; | |
| 39 ["key"] = { 32, 0, 32, 0, }; | |
| 40 ["FIN"] = true; | |
| 41 ["MASK"] = true; | |
| 42 ["RSV1"] = false; | |
| 43 ["RSV2"] = false; | |
| 44 ["RSV3"] = false; | |
| 45 }; | |
| 35 } | 46 } |
| 36 | 47 |
| 37 describe("build", function () | 48 describe("build", function () |
| 38 local build = nwf.build; | 49 local build = nwf.build; |
| 39 it("works", function () | 50 it("works", function () |
| 40 assert.equal("\0\0", build(test_frames.simple_empty)); | 51 assert.equal("\0\0", build(test_frames.simple_empty)); |
| 41 assert.equal("\0\5hello", build(test_frames.simple_data)); | 52 assert.equal("\0\5hello", build(test_frames.simple_data)); |
| 42 assert.equal("\128\0", build(test_frames.simple_fin)); | 53 assert.equal("\128\0", build(test_frames.simple_fin)); |
| 54 assert.equal("\128\133 \0 \0HeLlO", build(test_frames.with_mask)) | |
| 43 end); | 55 end); |
| 44 end); | 56 end); |
| 45 | 57 |
| 46 describe("parse", function () | 58 describe("parse", function () |
| 47 local parse = nwf.parse; | 59 local parse = nwf.parse; |
| 48 it("works", function () | 60 it("works", function () |
| 49 assert.same(test_frames.simple_empty, parse("\0\0")); | 61 assert.same(test_frames.simple_empty, parse("\0\0")); |
| 50 assert.same(test_frames.simple_data, parse("\0\5hello")); | 62 assert.same(test_frames.simple_data, parse("\0\5hello")); |
| 51 assert.same(test_frames.simple_fin, parse("\128\0")); | 63 assert.same(test_frames.simple_fin, parse("\128\0")); |
| 64 assert.same(test_frames.with_mask, parse("\128\133 \0 \0HeLlO")); | |
| 52 end); | 65 end); |
| 53 end); | 66 end); |
| 54 | 67 |
| 55 end); | 68 end); |
| 56 | 69 |
