diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-08 11:11:16 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-08 11:11:16 +0100 |
commit | f8513511ff5c77aca1cd2b7fc570d0dd34c4a417 (patch) | |
tree | fe4294bd10a77df2b5db321e9cf3e319b453762e /application | |
parent | 0d2a97c67e361c41434f1cf855f4bd26a891340b (diff) |
Add tests for invalid login
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r-- | application/tests/test_api_v1.php | 32 |
1 files changed, 32 insertions, 0 deletions
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(); |