mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 13:12:22 +08:00
When key not found during deletion, return 404 and not 500.
This commit is contained in:
parent
16d91aec6f
commit
e6340dd645
@ -117,7 +117,7 @@ Option<api_key_t> AuthManager::remove_key(uint32_t id) {
|
||||
Option<api_key_t> key_op = get_key(id, false);
|
||||
|
||||
if(!key_op.ok()) {
|
||||
return Option<api_key_t>(500, key_op.error());
|
||||
return Option<api_key_t>(key_op.code(), key_op.error());
|
||||
}
|
||||
|
||||
std::string api_key_store_key = std::string(API_KEYS_PREFIX) + "_" + std::to_string(id);
|
||||
|
@ -88,6 +88,14 @@ TEST_F(AuthManagerTest, CreateListDeleteAPIKeys) {
|
||||
ASSERT_EQ("abcd", list_op.get()[0].value);
|
||||
ASSERT_EQ("test key 2", list_op.get()[1].description);
|
||||
ASSERT_EQ("abcd", list_op.get()[1].value);
|
||||
|
||||
// delete key
|
||||
auto del_op = auth_manager.remove_key(1);
|
||||
ASSERT_TRUE(del_op.ok());
|
||||
|
||||
del_op = auth_manager.remove_key(1000);
|
||||
ASSERT_FALSE(del_op.ok());
|
||||
ASSERT_EQ(404, del_op.code());
|
||||
}
|
||||
|
||||
TEST_F(AuthManagerTest, CheckRestoreOfAPIKeys) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user