commit ced3d5c9ec154a78133fffc968fe7d47f969058d
parent 4f1553028ca3c7d5e56923021fad8c12e407f852
Author: kyle <kyle@0x30.net>
Date: Fri, 8 Jan 2016 22:30:53 -0700
tests: add friend delete test
- checks that friend deletion has an effect when viewing other friends lists
Diffstat:
3 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/server/tests/friend_delete/Makefile b/server/tests/friend_delete/Makefile
@@ -0,0 +1,3 @@
+DIFF_MOD=sort
+
+include ../test.mk
diff --git a/server/tests/friend_delete/server.log.good b/server/tests/friend_delete/server.log.good
@@ -0,0 +1,46 @@
+accepting connections on <ip>:<port> (pid = <digits>)
+device_add: success, <digits>:<base64> os <base64>
+device_add: success, <digits>:<base64> os <base64>
+disconnected!
+disconnected!
+friend_add: <base64> adding <digits>
+friend_add: <base64> adding <digits>
+friend_add: added friend is a member
+friend_add: added friend is a member
+friend_add: found mutual friendship
+friend_add: friends device id is <base64>
+friend_add: friends device id is <base64>
+friend_delete: friend <digits> was registered as <base64>
+friend_delete: removing <digits> from friends list
+list_add: <string>s first list'
+list_add: <string>s first list'
+list_add: <string>s second list'
+list_add: adding first member devid = <base64>
+list_add: adding first member devid = <base64>
+list_add: adding first member devid = <base64>
+list_add: fingerprint = <base64>
+list_add: fingerprint = <base64>
+list_add: fingerprint = <base64>
+list_join: device <base64>
+list_join: device <base64> has been added to list <base64>
+list_join: list <base64>
+lists_get: found list <string>s first list' <base64>
+lists_get: found list <string>s first list' <base64>
+lists_get: found list <string>s first list' <base64>
+lists_get: found list <string>s second list' <base64>
+lists_get: gathering lists for <base64>
+lists_get: gathering lists for <base64>
+lists_get: list has 0 items
+lists_get: list has 0 items
+lists_get: list has 0 items
+lists_get: list has 0 items
+lists_get: list has 1 members
+lists_get: list has 1 members
+lists_get: list has 2 members
+lists_get: list has 2 members
+lists_get_other: gathering lists for <base64>
+lists_get_other: gathering lists for <base64>
+new connection (pid = <digits>)
+new connection (pid = <digits>)
+ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256'
+ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256'
diff --git a/server/tests/friend_delete/test.pl b/server/tests/friend_delete/test.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -I../
+use strict;
+use warnings;
+
+use client;
+use test;
+
+# create A and B
+my $A = client->new();
+my $B = client->new();
+
+$A->device_add(rand_phnum());
+$B->device_add(rand_phnum());
+
+# A friends B, B friends A
+$A->friend_add($B->phnum());
+$B->friend_add($A->phnum());
+
+# A creates 2 lists
+$A->list_add("this is a's first list");
+$A->list_add("this is a's second list");
+# B creates 1 list
+$B->list_add("this is b's first list");
+
+# B joins one of A's list
+$B->list_join($A->lists(0)->{'id'});
+
+# A deletes B's friendship
+$A->friend_delete($B->phnum());
+
+# check that:
+# - A and B are both in A's first list
+# - B can't see A's other list
+# - A can't see B's other list
+fail "expected A to have 0 other lists" if ($A->lists_get_other() != 0);
+fail "expected B to have 0 other lists" if ($B->lists_get_other() != 0);
+
+fail "expected A to have 2 lists" if ($A->lists_get() != 2);
+fail "expected B to have 2 lists" if ($B->lists_get() != 2);