Skip to content

Commit 901ac86

Browse files
syaifulizhanchidev
authored andcommitted
test: propagate secret-file worker policy
Signed-off-by: syaifulizhan <[email protected]> (cherry picked from commit 8e74c86) Signed-off-by: chidev <[email protected]>
1 parent 7912fdd commit 901ac86

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎scripts/test-runtime.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ _cbm_test_runtime_daemon() {
112112
# cbm_mcp_index_policy_add_to_args: every key in cbm_index_policy_key_at, and
113113
# nothing else.
114114
cbm_test_index_worker_policy_json() {
115-
printf '%s' '"_cbm_index_policy":{"index_max_files":"off","index_max_source_mb":"off"}'
115+
printf '%s' '"_cbm_index_policy":{"index_max_files":"off","index_max_source_mb":"off","index_secret_files":"false"}'
116116
}
117117

118118
cbm_test_runtime_cleanup() {

‎tests/test_daemon_application.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,9 +1772,14 @@ static bool app_fake_worker_policy_equals(app_fake_worker_context_t *context, in
17721772
yyjson_val *bytes = policy && yyjson_is_obj(policy)
17731773
? yyjson_obj_get(policy, CBM_INDEX_CONFIG_MAX_SOURCE_MB)
17741774
: NULL;
1775-
bool equal = files && bytes && yyjson_is_str(files) && yyjson_is_str(bytes) &&
1775+
yyjson_val *secret_files = policy && yyjson_is_obj(policy)
1776+
? yyjson_obj_get(policy, CBM_INDEX_CONFIG_SECRET_FILES)
1777+
: NULL;
1778+
bool equal = files && bytes && secret_files && yyjson_is_str(files) && yyjson_is_str(bytes) &&
1779+
yyjson_is_str(secret_files) &&
17761780
strcmp(yyjson_get_str(files), max_files) == 0 &&
1777-
strcmp(yyjson_get_str(bytes), max_source_mb) == 0;
1781+
strcmp(yyjson_get_str(bytes), max_source_mb) == 0 &&
1782+
strcmp(yyjson_get_str(secret_files), "false") == 0;
17781783
yyjson_doc_free(document);
17791784
return equal;
17801785
}

‎tests/test_index_policy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ TEST(index_policy_mcp_rejects_forged_override_and_preserves_serving_index) {
371371
(void)snprintf(args, sizeof(args),
372372
"{\"repo_path\":\"%s\",\"name\":\"ResourcePolicyFixture\","
373373
"\"mode\":\"fast\",\"_cbm_index_policy\":{"
374-
"\"index_max_files\":\"off\",\"index_max_source_mb\":\"off\"}}",
374+
"\"index_max_files\":\"off\",\"index_max_source_mb\":\"off\","
375+
"\"index_secret_files\":\"false\"}}",
375376
repo);
376377
char *limited_response =
377378
configured && server ? cbm_mcp_handle_tool(server, "index_repository", args) : NULL;

‎tests/test_worker_session_scope.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ run_worker() {
7575
# without one is refused ("missing or incomplete trusted worker policy").
7676
# This script plays the supervisor, so it sends what the supervisor sends --
7777
# both limits off, the default.
78-
policy='"_cbm_index_policy":{"index_max_files":"off","index_max_source_mb":"off"}'
78+
policy='"_cbm_index_policy":{"index_max_files":"off","index_max_source_mb":"off","index_secret_files":"false"}'
7979

8080
response="${tmpdir}/scoped.response"
8181
if ! run_worker "{\"repo_path\":\"${repo}\",\"mode\":\"fast\",${policy}}" "${response}" \

0 commit comments

Comments
 (0)