shlist

share and manage lists between multiple people
Log | Files | Refs

commit c8c06141be731bcf274f5d79a730da30c929f412
parent 9dbf7ee862c1ff5059f07b6c705428db199bd0fa
Author: kyle <kyle@0x30.net>
Date:   Sun, 27 Dec 2015 23:21:50 -0700

tests: add new joining friends lists test

Diffstat:
Atests/join_friends_list/Makefile | 1+
Atests/join_friends_list/server.log.good | 27+++++++++++++++++++++++++++
Atests/join_friends_list/test.pl | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/tests/join_friends_list/Makefile b/tests/join_friends_list/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/tests/join_friends_list/server.log.good b/tests/join_friends_list/server.log.good @@ -0,0 +1,27 @@ +accepting connections on <ip>:<port> (pid = <digits>) +new connection (pid = <digits>) +ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256' +new_device: success <digits> <base64> +add_friend: <base64> adding <digits> +add_friend: added friend is a member +add_friend: friends device id is <base64> +add_friend: found mutual friendship +join_list: device <base64> +join_list: list <base64> +join_list: device <base64> has been added to list <base64> +list_request: gathering lists for <base64> +list_request: found list <string> <base64> +list_request: direct list: found member <base64> +list_request: direct list: found member <base64> +list_request: found mutual friend <base64> +disconnected! +new connection (pid = <digits>) +ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256' +new_device: success <digits> <base64> +add_friend: <base64> adding <digits> +add_friend: added friend is a member +add_friend: friends device id is <base64> +new_list: <string> +new_list: adding first member devid = <base64> +new_list: fingerprint = <base64> +disconnected! diff --git a/tests/join_friends_list/test.pl b/tests/join_friends_list/test.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl -I../ +use strict; +use warnings; +use test; + +my ($sock_1, $sock_2) = (new_socket(), new_socket()); +my ($phnum_1, $phnum_2) = ("4038675309", "4037082094"); + +# create device 1 and 2 +send_msg($sock_1, 'new_device', $phnum_1); +my ($msg_data1) = recv_msg($sock_1, 'new_device'); + +send_msg($sock_2, 'new_device', $phnum_2); +my ($msg_data2) = recv_msg($sock_2, 'new_device'); + +my $device_id1 = check_status($msg_data1, 'ok'); +my $device_id2 = check_status($msg_data2, 'ok'); + +# make device 1 and 2 mutual friends +send_msg($sock_1, 'add_friend', "$device_id1\0$phnum_2"); +recv_msg($sock_1, 'add_friend'); +send_msg($sock_2, 'add_friend', "$device_id2\0$phnum_1"); +recv_msg($sock_2, 'add_friend'); + +my $list_name = "this is a new list"; + +# device 1 creates new list +send_msg($sock_1, 'new_list', "$device_id1\0$list_name"); +my ($msg_data) = recv_msg($sock_1, 'new_list'); + +my $msg = check_status($msg_data, 'ok'); +my ($list_id) = unpack('Z*', $msg); + +# device 2 joins the list +send_msg($sock_2, 'join_list', "$device_id2\0$list_id"); +($msg_data) = recv_msg($sock_2, 'join_list'); + +check_status($msg_data, 'ok'); + +# device 2 requests its lists to make sure its committed to the list +send_msg($sock_2, 'list_request', $device_id2); +($msg_data) = recv_msg($sock_2, 'list_request'); + +my $request_data = check_status($msg_data, 'ok'); +my ($mine, $other) = split("\0\0", $request_data); + +fail "unexpected other list '$other'" if ($other ne ''); +my ($name, $request_id, @members) = split(":", $mine); + +fail "request list id mismatch: '$request_id' ne '$list_id'" if ($request_id ne $list_id); +fail "unexpected name '$name', expected '$list_name'" if ($name ne $list_name); +fail "expected 2 list members, got ". @members if (@members != 2);