summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-10-07 12:24:10 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-11-01 17:29:04 +0100
commite83d6beb227aeee9846f220e1fcee5c7abfb3844 (patch)
treeadadc602a3e98e7c6078757f24f9069c638533fa
parent786915852f698f2c77a29b2a33b4cd44190d0c77 (diff)
Test calling endpoints with unsupported authentication method
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/test/tests/test_api_v2.php26
1 files changed, 26 insertions, 0 deletions
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(