added test for deleting plans
This commit is contained in:
parent
cf347ad065
commit
aef00ab24d
|
@ -359,7 +359,7 @@ EOF
|
||||||
my $token = $body->{'auth'};
|
my $token = $body->{'auth'};
|
||||||
if (!defined $user->{'token'} || !defined $user->{'token_expires'} || !defined $token || $token ne $user->{'token'} || $user->{'token_expires'} < time) {
|
if (!defined $user->{'token'} || !defined $user->{'token_expires'} || !defined $token || $token ne $user->{'token'} || $user->{'token_expires'} < time) {
|
||||||
print_response($cgi, 401, $not_authorized);
|
print_response($cgi, 401, $not_authorized);
|
||||||
} elsif (length($plan) > $maximum_plan_length) {
|
} elsif (defined $plan && length($plan) > $maximum_plan_length) {
|
||||||
print_json_response($cgi, 400, {error => "Plan exceeds maximum length of $maximum_plan_length."});
|
print_json_response($cgi, 400, {error => "Plan exceeds maximum length of $maximum_plan_length."});
|
||||||
} elsif (defined $signature && length($signature) > $maximum_signature_length) {
|
} elsif (defined $signature && length($signature) > $maximum_signature_length) {
|
||||||
print_json_response($cgi, 400, {error => "Signature exceeds maximum length of $maximum_signature_length."});
|
print_json_response($cgi, 400, {error => "Signature exceeds maximum length of $maximum_signature_length."});
|
||||||
|
|
|
@ -214,6 +214,14 @@ curl_test 'Get updated plan text' 200 'text/plain' localhost:$PORT/plan/$TEST_US
|
||||||
&& assert_equal 'text content' "$TEST_CONTENT" 'some&thing
|
&& assert_equal 'text content' "$TEST_CONTENT" 'some&thing
|
||||||
else'
|
else'
|
||||||
|
|
||||||
|
curl_test 'Delete a plan' 200 'application/json' -XPUT -d "{\"auth\":\"$token\"}" localhost:$PORT/plan/$TEST_USER \
|
||||||
|
&& assert_equal_jq '.success' 1
|
||||||
|
|
||||||
|
curl_test 'Verify deleted plan' 404 '' localhost:$PORT/plan/$TEST_USER
|
||||||
|
|
||||||
|
curl_test 'Create another plan for future tests' 200 'application/json' -XPUT -d "{\"plan\":\"for future tests\",\"auth\":\"$token\"}" localhost:$PORT/plan/$TEST_USER \
|
||||||
|
&& assert_equal_jq '.success' 1
|
||||||
|
|
||||||
curl_test 'Check missing plan in json using accept' 404 'application/json' -H 'Accept: application/json' localhost:$PORT/plan/testuser@exampl3.com
|
curl_test 'Check missing plan in json using accept' 404 'application/json' -H 'Accept: application/json' localhost:$PORT/plan/testuser@exampl3.com
|
||||||
|
|
||||||
curl_test 'Check missing plan in json using querystring' 404 'application/json' localhost:$PORT/plan/testuser@exampl3.com?format=json
|
curl_test 'Check missing plan in json using querystring' 404 'application/json' localhost:$PORT/plan/testuser@exampl3.com?format=json
|
||||||
|
|
Reference in New Issue