Comparison

spec/net_websocket_frames_spec.lua @ 10583:624ad69dbaf7

net.websocket.frames: Add test case for masked data ASCI is pretty neat in how lower case alphabet XOR space is upper case
author Kim Alvefur <zash@zash.se>
date Thu, 02 Jan 2020 13:17:03 +0100
parent 9660:7e75c348095b
child 10584:0c464bb7eb03
comparison
equal deleted inserted replaced
10582:6d4562acef81 10583:624ad69dbaf7
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 = {
36 ["opcode"] = 0;
37 ["length"] = 5;
38 ["data"] = "hello";
39 ["FIN"] = true;
40 ["MASK"] = true;
41 ["RSV1"] = false;
42 ["RSV2"] = false;
43 ["RSV3"] = false;
44 ["key"] = { 0x20, 0x20, 0x20, 0x20, };
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 HELLO", build(test_frames.masked_data));
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.masked_data, parse("\128\133 HELLO"));
52 end); 65 end);
53 end); 66 end);
54 67
55 end); 68 end);
56 69