From 524f22f781da2b36a033f6ff329b17ca7695196b Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Tue, 5 Jun 2012 00:50:24 +0100 Subject: [PATCH] Added tests for invalid and edge case server names. --- test.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 824cc39..40c614c 100644 --- a/test.sh +++ b/test.sh @@ -50,15 +50,37 @@ stdall() { # Manager Tests # ------------- -test_invalid_server_names() { +test_reserved_server_names() { local result local expected_regex="^Invalid\ name" - local condition + source "$MSM_CONF" for name in "start" "stop" "restart" "server" "version" "jargroup" "all"; do result="$(stdall $SCRIPT server create $name)" assertTrue "Server name \"$name\" was accepted but should be invalid." "[[ '$result' =~ $expected_regex ]]" - assertFalse "Server directory was created when it should not have been." "[ -d \"$SERVER_STORAGE_PATH/$name\" ]" + assertFalse "Server \"$name\" directory was created when it should not have been." "[ -d \"$SERVER_STORAGE_PATH/$name\" ]" + done +} + +test_common_invalid_server_names() { + local result + local expected_regex="^Invalid\ name" + source "$MSM_CONF" + + for name in "name with spaces"; do + result="$(stdall $SCRIPT server create $name)" + assertFalse "Server \"$name\" directory was created when it should not have been." "[ -d \"$SERVER_STORAGE_PATH/$name\" ]" + done +} + +test_valid_edge_case_server_names() { + local result + local expected_regex="^Invalid\ name" + source "$MSM_CONF" + + for name in "serverstart" "CapitalLetters" "0987654321" "name-with-dashes" "name_with_underscores" "Combination-of_different1Things2"; do + result="$(stdall $SCRIPT server create $name)" + assertTrue "Server \"$name\" directory was NOT created when it should not have been." "[ -d \"$SERVER_STORAGE_PATH/$name\" ]" done }