27 lines
919 B
Erlang
27 lines
919 B
Erlang
-module(api_admin_tests).
|
|
-export([test/0]).
|
|
|
|
test() ->
|
|
io:format("Testing admin panel API...~n"),
|
|
|
|
AdminToken = api_test_runner:get_admin_token(),
|
|
|
|
% TEST 1: Admin healthcheck
|
|
io:format(" TEST 1: Admin healthcheck... "),
|
|
{ok, {{_, 200, _}, _, _}} = httpc:request(get, {"http://localhost:8445/admin/health", []}, [], []),
|
|
io:format("OK~n"),
|
|
|
|
% TEST 2: Admin stats
|
|
io:format(" TEST 2: Admin stats... "),
|
|
{ok, {{_, 200, _}, _, _}} = httpc:request(get,
|
|
{"http://localhost:8445/admin/stats", [{"Authorization", "Bearer " ++ binary_to_list(AdminToken)}]}, [], []),
|
|
io:format("OK~n"),
|
|
|
|
% TEST 3: List users
|
|
io:format(" TEST 3: List users... "),
|
|
{ok, {{_, 200, _}, _, _}} = httpc:request(get,
|
|
{"http://localhost:8445/admin/users", [{"Authorization", "Bearer " ++ binary_to_list(AdminToken)}]}, [], []),
|
|
io:format("OK~n"),
|
|
|
|
io:format("~n✅ Admin API tests passed!~n"),
|
|
{?MODULE, ok}. |