From e83d6beb227aeee9846f220e1fcee5c7abfb3844 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 7 Oct 2016 12:24:10 +0200 Subject: Test calling endpoints with unsupported authentication method Signed-off-by: Florian Pritz --- application/test/tests/test_api_v2.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/application/test/tests/test_api_v2.php b/application/test/tests/test_api_v2.php index 05d7952c6..8bc07db97 100644 --- a/application/test/tests/test_api_v2.php +++ b/application/test/tests/test_api_v2.php @@ -81,6 +81,32 @@ class test_api_v2 extends \test\Test { } } + public function test_callPrivateEndpointsWithUnsupportedAuthentication() + { + $endpoints = array( + "file/upload", + "file/history", + "file/delete", + "file/create_multipaste", + "user/apikeys", + // create_apikey is the only one that supports username/pw + //"user/create_apikey", + "user/delete_apikey", + ); + foreach ($endpoints as $endpoint) { + $ret = $this->CallEndpoint("POST", $endpoint, array( + "username" => "apiv2testuser1", + "password" => "testpass1", + )); + $this->expectError("call $endpoint without apikey", $ret); + $this->t->is_deeply(array( + 'status' => 'error', + 'error_id' => 'api/not-authenticated', + 'message' => 'Not authenticated. FileBin requires you to have an account, please go to the homepage at http://127.0.0.1:23116/ for more information.', + ), $ret, "expected error"); + } + } + public function test_callEndpointsWithoutEnoughPermissions() { $testconfig = array( -- cgit v1.2.3-24-g4f1b