feat(cli,registry): expose install options; paginate user listings
This commit is contained in:
1 parent
c7d2662cf2
commit
eabcb92d0b
8 files changed
+154
-15
No files matched your search
@@ -84,7 +84,7 @@ check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info -
|
||||
check_process(0 "Usage: vbs daemon target flags .*--name.*--file" "" daemon target flags --help)
|
||||
check_process(0 "Usage: vbs daemon pack .*--output" "" daemon pack --help)
|
||||
check_process(0 "Usage: vbs daemon actions .*--limit" "" daemon actions --help)
|
||||
check_process(0 "Usage: vbs daemon install .*--prefix" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon install .*--prefix.*--component.*--no-cmake-export.*--no-native-export" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon uninstall .*--prefix" "" daemon uninstall --help)
|
||||
check_process(0 "Usage: vbs daemon gen-tests .*--input.*--output-dir" "" daemon gen-tests --help)
|
||||
check_process(0 "Usage: vbs daemon init .*--dir" "" daemon init --help)
|
||||
|
||||
+84
-2
@@ -533,6 +533,86 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
|
||||
auto bad_limit = send_loopback_http(port, "GET", "/api/v1/packages?limit=501");
|
||||
Void::Testing::expect(bad_limit.has_value() && bad_limit->status == 400);
|
||||
|
||||
// Admin user listing: bounded page plus total/limit/offset envelope.
|
||||
auto users_default = send_loopback_http(port, "GET", "/api/v1/users", {{"Cookie", cookie}});
|
||||
Void::Testing::expect(users_default.has_value() && users_default->status == 200);
|
||||
if (users_default) {
|
||||
Void::Testing::expect_eq(envelope_value(users_default->body, "total"), std::string{"3"});
|
||||
Void::Testing::expect_eq(envelope_value(users_default->body, "limit"), std::string{"100"});
|
||||
Void::Testing::expect_eq(envelope_value(users_default->body, "offset"), std::string{"0"});
|
||||
Void::Testing::expect(count_occurrences(users_default->body, "\"username\":") == 3);
|
||||
}
|
||||
const auto first_username = [](const std::string &body) {
|
||||
const std::string key = "\"username\":\"";
|
||||
const auto start = body.find(key);
|
||||
if (start == std::string::npos) {
|
||||
return std::string{};
|
||||
}
|
||||
const auto value_start = start + key.size();
|
||||
const auto end = body.find('"', value_start);
|
||||
return end == std::string::npos ? std::string{}
|
||||
: body.substr(value_start, end - value_start);
|
||||
};
|
||||
auto users_first =
|
||||
send_loopback_http(port, "GET", "/api/v1/users?limit=2", {{"Cookie", cookie}});
|
||||
auto users_second =
|
||||
send_loopback_http(port, "GET", "/api/v1/users?limit=2&offset=2", {{"Cookie", cookie}});
|
||||
Void::Testing::expect(users_first.has_value() && users_first->status == 200);
|
||||
Void::Testing::expect(users_second.has_value() && users_second->status == 200);
|
||||
if (users_first && users_second) {
|
||||
Void::Testing::expect(count_occurrences(users_first->body, "\"username\":") == 2);
|
||||
Void::Testing::expect_eq(envelope_value(users_first->body, "total"), std::string{"3"});
|
||||
Void::Testing::expect_eq(envelope_value(users_first->body, "limit"), std::string{"2"});
|
||||
Void::Testing::expect_eq(envelope_value(users_first->body, "offset"), std::string{"0"});
|
||||
Void::Testing::expect(count_occurrences(users_second->body, "\"username\":") == 1);
|
||||
Void::Testing::expect_eq(envelope_value(users_second->body, "total"), std::string{"3"});
|
||||
Void::Testing::expect_eq(envelope_value(users_second->body, "offset"), std::string{"2"});
|
||||
Void::Testing::expect(!first_username(users_first->body).empty());
|
||||
Void::Testing::expect(first_username(users_first->body) !=
|
||||
first_username(users_second->body));
|
||||
}
|
||||
auto users_empty_limit =
|
||||
send_loopback_http(port, "GET", "/api/v1/users?limit=0", {{"Cookie", cookie}});
|
||||
Void::Testing::expect(users_empty_limit.has_value() && users_empty_limit->status == 200);
|
||||
if (users_empty_limit) {
|
||||
Void::Testing::expect(users_empty_limit->body.find("\"users\":[]") != std::string::npos);
|
||||
Void::Testing::expect_eq(envelope_value(users_empty_limit->body, "total"),
|
||||
std::string{"3"});
|
||||
}
|
||||
auto users_far_page =
|
||||
send_loopback_http(port, "GET", "/api/v1/users?offset=99", {{"Cookie", cookie}});
|
||||
Void::Testing::expect(users_far_page.has_value() && users_far_page->status == 200);
|
||||
if (users_far_page) {
|
||||
Void::Testing::expect(users_far_page->body.find("\"users\":[]") != std::string::npos);
|
||||
Void::Testing::expect_eq(envelope_value(users_far_page->body, "total"), std::string{"3"});
|
||||
Void::Testing::expect_eq(envelope_value(users_far_page->body, "offset"), std::string{"99"});
|
||||
}
|
||||
for (const std::string bad_users_limit_url :
|
||||
{"/api/v1/users?limit=abc", "/api/v1/users?limit=501"}) {
|
||||
auto bad_users_limit =
|
||||
send_loopback_http(port, "GET", bad_users_limit_url, {{"Cookie", cookie}});
|
||||
Void::Testing::expect(bad_users_limit.has_value() && bad_users_limit->status == 400);
|
||||
if (bad_users_limit) {
|
||||
Void::Testing::expect(bad_users_limit->body.find("invalid_limit") != std::string::npos);
|
||||
}
|
||||
}
|
||||
for (const std::string bad_users_offset_url :
|
||||
{"/api/v1/users?offset=abc", "/api/v1/users?offset=-1"}) {
|
||||
auto bad_users_offset =
|
||||
send_loopback_http(port, "GET", bad_users_offset_url, {{"Cookie", cookie}});
|
||||
Void::Testing::expect(bad_users_offset.has_value() && bad_users_offset->status == 400);
|
||||
if (bad_users_offset) {
|
||||
Void::Testing::expect(bad_users_offset->body.find("invalid_offset") !=
|
||||
std::string::npos);
|
||||
}
|
||||
}
|
||||
auto users_unauthenticated = send_loopback_http(port, "GET", "/api/v1/users");
|
||||
Void::Testing::expect(users_unauthenticated.has_value() &&
|
||||
users_unauthenticated->status == 401);
|
||||
auto users_non_admin = send_loopback_http(port, "GET", "/api/v1/users",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(users_non_admin.has_value() && users_non_admin->status == 403);
|
||||
|
||||
// 4. Consistent backup & restore into a brand-new registry instance preserves releases &
|
||||
// download!
|
||||
const auto backup_dir = tmp / "backup";
|
||||
@@ -1343,7 +1423,8 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
const std::string &out = second_list->stdout_data;
|
||||
while (pos < out.size()) {
|
||||
const auto nl = out.find('\n', pos);
|
||||
const std::string line = out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
const std::string line =
|
||||
out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
if (line.find(" extra ") != std::string::npos) {
|
||||
extra_id = line.substr(0, line.find(' '));
|
||||
}
|
||||
@@ -1366,7 +1447,8 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
const std::string &out = final_list->stdout_data;
|
||||
while (pos < out.size()) {
|
||||
const auto nl = out.find('\n', pos);
|
||||
const std::string line = out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
const std::string line =
|
||||
out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
if (line.starts_with(extra_id) && line.find("revoked") != std::string::npos) {
|
||||
saw_revoked = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user