From f8513511ff5c77aca1cd2b7fc570d0dd34c4a417 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 8 Feb 2015 11:11:16 +0100 Subject: Add tests for invalid login Signed-off-by: Florian Pritz --- application/tests/test_api_v1.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'application/tests/test_api_v1.php') diff --git a/application/tests/test_api_v1.php b/application/tests/test_api_v1.php index faf0d9af7..7fe06ca36 100644 --- a/application/tests/test_api_v1.php +++ b/application/tests/test_api_v1.php @@ -134,6 +134,38 @@ class test_api_v1 extends Test { $this->t->ok(is_int($ret["data"][0]["created"]) , "expected key 1 creation time is int"); } + public function test_authentication_invalidPassword() + { + $userid = $this->createUser(3); + $ret = $this->CallEndpoint("POST", "user/apikeys", array( + "username" => "testuser-api_v1-3", + "password" => "wrongpass", + )); + $this->expectError("invalid password", $ret); + + $this->t->is_deeply(array ( + 'status' => 'error', + 'error_id' => 'user/login-failed', + 'message' => 'Login failed', + ), $ret, "expected error"); + } + + public function test_authentication_invalidUser() + { + $userid = $this->createUser(4); + $ret = $this->CallEndpoint("POST", "user/apikeys", array( + "username" => "testuser-api_v1-invalid", + "password" => "testpass4", + )); + $this->expectError("invalid username", $ret); + + $this->t->is_deeply(array ( + 'status' => 'error', + 'error_id' => 'user/login-failed', + 'message' => 'Login failed', + ), $ret, "expected error"); + } + public function test_history_empty() { $apikey = $this->createUserAndApikey(); -- cgit v1.2.3-24-g4f1b