diff options
Diffstat (limited to 'tests/test-whiteboard.cpp')
-rw-r--r-- | tests/test-whiteboard.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test-whiteboard.cpp b/tests/test-whiteboard.cpp index b6fe9c5..3f70bcf 100644 --- a/tests/test-whiteboard.cpp +++ b/tests/test-whiteboard.cpp @@ -222,3 +222,34 @@ TEST_F(WhiteboardTest, max_connections) ASSERT_THROW(WebsocketClient wc4, std::exception); } + +TEST_F(WhiteboardTest, id) +{ + WebsocketClient wc; + + wc.write("<request><command>getfile</command><id>1</id></request>"); + std::string result {wc.read()}; + + EXPECT_EQ(result, "<serverinfo><type>getfile</type><data/><revision>0</revision><pos>0</pos></serverinfo>"); + + wc.write("<request><command>getfile</command><id></id></request>"); + result = wc.read(); + EXPECT_EQ(result, "<serverinfo><type>error</type><message>Message handling error: Invalid id (empty)</message></serverinfo>"); + + wc.write("<request><command>getfile</command><id>01234567890123456789</id></request>"); + result = wc.read(); + EXPECT_EQ(result, "<serverinfo><type>error</type><message>Message handling error: Invalid id (size > 16)</message></serverinfo>"); + + wc.write("<request><command>getfile</command><id>X</id></request>"); + result = wc.read(); + EXPECT_EQ(result, "<serverinfo><type>error</type><message>Message handling error: Invalid id char: X</message></serverinfo>"); + + wc.write("<request><command>getfile</command><id>a.</id></request>"); + result = wc.read(); + EXPECT_EQ(result, "<serverinfo><type>error</type><message>Message handling error: Invalid id char: .</message></serverinfo>"); + + wc.write("<request><command>getfile</command><id>a$b</id></request>"); + result = wc.read(); + EXPECT_EQ(result, "<serverinfo><type>error</type><message>Message handling error: Invalid id char: $</message></serverinfo>"); +} + |