commit d4d161ca3611621333c26511097a1893880a7ed1
parent 513870209f43ae90a329bf539887dd5140e33ff0
Author: kyle <kyle@getaddrinfo.net>
Date: Wed, 30 Dec 2015 13:51:38 -0700
tests: fold new_list_missing_name into new_list
Diffstat:
5 files changed, 17 insertions(+), 39 deletions(-)
diff --git a/tests/new_list/server.log.good b/tests/new_list/server.log.good
@@ -5,4 +5,5 @@ new_device: success, <digits>:<base64> os <base64>
new_list: <string>
new_list: adding first member devid = <base64>
new_list: fingerprint = <base64>
+new_list: error, no name
disconnected!
diff --git a/tests/new_list/test.pl b/tests/new_list/test.pl
@@ -3,23 +3,22 @@ use strict;
use warnings;
use test;
-# this test:
-# - gets a new device id
-# - creates a new list
-# - receives new list response
-# - verifies received information is congruent with what was sent
+# this test sanity checks the new_list message. it checks that
+# - a new list can be created, and has the correct fields
+# - a list with no name is rejected
my $sock = new_socket();
my $phnum = "4038675309";
+my $list_name = "this is a new list";
+
send_msg($sock, 'new_device', "$phnum\0unix");
-my ($payload, $length) = recv_msg($sock, 'new_device');
+my ($payload) = recv_msg($sock, 'new_device');
my $device_id = check_status($payload, 'ok');
-fail "expected response length of 46, got $length" if ($length != 46);
-my $list_name = "this is a new list";
+# verify a normal new_list request succeeds and returns good information
send_msg($sock, 'new_list', "$device_id\0$list_name");
-($payload, $length) = recv_msg($sock, 'new_list');
+($payload) = recv_msg($sock, 'new_list');
my $list_data = check_status($payload, 'ok');
my ($id, $name, @members) = split("\0", $list_data);
@@ -29,3 +28,11 @@ fail "bad id length $id_length != 43" if ($id_length != 43);
fail "recv'd name '$name' not equal to '$list_name'" if ($name ne $list_name);
fail "list does not have exactly 1 member" if (@members != 1);
fail "got list member '$members[0]', expected '$phnum'" if ($members[0] ne $phnum);
+
+# verify a new_list request with an empty list name fails
+send_msg($sock, 'new_list', "$device_id\0");
+($payload) = recv_msg($sock, 'new_list');
+
+my $msg = check_status($payload, 'err');
+my $msg_good = 'no list name was given';
+fail "unexpected error response '$msg', expecting '$msg_good'" if ($msg ne $msg_good);
diff --git a/tests/new_list_missing_name/Makefile b/tests/new_list_missing_name/Makefile
@@ -1 +0,0 @@
-include ../test.mk
diff --git a/tests/new_list_missing_name/server.log.good b/tests/new_list_missing_name/server.log.good
@@ -1,6 +0,0 @@
-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> os <base64>
-new_list: error, no name
-disconnected!
diff --git a/tests/new_list_missing_name/test.pl b/tests/new_list_missing_name/test.pl
@@ -1,23 +0,0 @@
-#!/usr/bin/perl -I../
-use strict;
-use warnings;
-use test;
-
-# this test:
-# - gets a new device id
-# - tries to create a new list without a name
-
-my $sock = new_socket();
-
-send_msg($sock, 'new_device', "4038675309\0unix");
-my ($msg_data, $length) = recv_msg($sock, 'new_device');
-
-my $device_id = check_status($msg_data, 'ok');
-fail "expected response length of 46, got $length" if ($length != 46);
-
-send_msg($sock, 'new_list', "$device_id\0");
-($msg_data, $length) = recv_msg($sock, 'new_list');
-
-my $msg = check_status($msg_data, 'err');
-my $msg_good = 'no list name was given';
-fail "unexpected error response '$msg', expecting '$msg_good'" if ($msg ne $msg_good);