mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 18:23:13 +02:00
relay/api: return an error 401 when header "x-weechat-totp" is received with empty value
This commit is contained in:
@@ -713,13 +713,6 @@ TEST(RelayHttp, GetAuthStatus)
|
||||
hashtable_set (client->http_req->headers, "authorization", "Basic \u26c4");
|
||||
LONGS_EQUAL(-2, relay_http_get_auth_status (client));
|
||||
|
||||
/* test invalid TOTP */
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "abcdef");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "1234567");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_remove (client->http_req->headers, "x-weechat-totp");
|
||||
|
||||
/* test invalid plain-text password ("test") */
|
||||
hashtable_set (client->http_req->headers, "authorization", "Basic cGxhaW46dGVzdA==");
|
||||
LONGS_EQUAL(-2, relay_http_get_auth_status (client));
|
||||
@@ -898,6 +891,20 @@ TEST(RelayHttp, GetAuthStatus)
|
||||
hashtable_set (client->http_req->headers, "authorization", auth_header);
|
||||
LONGS_EQUAL(0, relay_http_get_auth_status (client));
|
||||
|
||||
/* test invalid TOTP */
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "abcdef");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "1234567");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_remove (client->http_req->headers, "x-weechat-totp");
|
||||
|
||||
/* test valid TOTP without TOTP configuration */
|
||||
hashtable_set (client->http_req->headers, "x-weechat-totp", "123456");
|
||||
LONGS_EQUAL(-4, relay_http_get_auth_status (client));
|
||||
hashtable_remove (client->http_req->headers, "x-weechat-totp");
|
||||
|
||||
/* test missing/invalid TOTP */
|
||||
config_file_option_set (relay_config_network_totp_secret, "secretbase32", 1);
|
||||
config_file_option_set (relay_config_network_totp_window, "1", 1);
|
||||
|
||||
Reference in New Issue
Block a user