Unfortunately, there were some glaring bugs and annoyances, in particular in the area of automation and general netcat compliance. So, I brushed off my Python skills and I'm happy to report that after the weekend was over, the tool had matured quite a lot and was ready for some test automation.
Hoping to move the project to some QA folks for automation, I decided to whip up a quick recipe that demonstrates how the tool can be used to verify both client and server behaviour with minimal headache:
A simple echo server test
#!/bin/bash
set -e
(echo foo; echo bar; echo baz) > testinput
cat <(cat testinput | while read a; do echo $a; sleep 1; done) | wssh -q 0 ws://echo.websocket.org/ > testoutput
cmp testinput testoutput
rm -f testinput testoutput
This script tests ws://echo.websocket.org under "real-world" usage simulating a 1 second delay between each line of input. This concept can be extended much further with some basic bash-fu, creating some fairly sophisticated unit tests.
No comments:
Post a Comment