Skip to content

Commit 6a409fb

Browse files
committed
test(config): service secrets with json notation
This adds quick test to ensure secrets are not leaked when alternative JSON notation is used for accessing service details when name includes a dot.
1 parent 660cc66 commit 6a409fb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/sharness/t0700-remotepin.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ test_expect_success "test 'ipfs pin remote service ls' JSON on empty list" '
3232
test_expect_success "creating test user on remote pinning service" '
3333
echo CI host IP address ${TEST_PIN_SVC} &&
3434
ipfs pin remote service add test_pin_svc ${TEST_PIN_SVC} ${TEST_PIN_SVC_KEY} &&
35+
ipfs pin remote service add test.dots.in.name ${TEST_PIN_SVC} ${TEST_PIN_SVC_KEY} &&
3536
ipfs pin remote service add test_invalid_key_svc ${TEST_PIN_SVC} fake_api_key &&
3637
ipfs pin remote service add test_invalid_url_path_svc ${TEST_PIN_SVC}/invalid-path fake_api_key &&
3738
ipfs pin remote service add test_invalid_url_dns_svc https://invalid-service.example.com fake_api_key &&
@@ -100,6 +101,8 @@ test_expect_success "output does not include API.Key" '
100101
test_expect_code 1 grep -q Key config_out
101102
'
102103

104+
# dot notation
105+
103106
test_expect_success "'ipfs config Pinning.RemoteServices.test_pin_svc.API.Key' fails" '
104107
test_expect_code 1 ipfs config Pinning.RemoteServices.test_pin_svc.API.Key 2> config_out
105108
'
@@ -116,6 +119,25 @@ test_expect_success "output includes meaningful error" '
116119
test_cmp config_exp config_out
117120
'
118121

122+
# json map key notation
123+
124+
test_expect_success "'ipfs config Pinning.RemoteServices[\"test.dots.in.name\"]' fails" '
125+
test_expect_code 1 ipfs config Pinning.RemoteServices[\"test.dots.in.name\"] 2> config_out
126+
'
127+
test_expect_success "output includes meaningful error" '
128+
test_cmp config_exp config_out
129+
'
130+
131+
test_expect_success "'ipfs config Pinning.RemoteServices[\"test.dots.in.name\"].API.Key' fails" '
132+
test_expect_code 1 ipfs config Pinning.RemoteServices[\"test.dots.in.name\"].API.Key 2> config_out
133+
'
134+
135+
test_expect_success "output includes meaningful error" '
136+
test_cmp config_exp config_out
137+
'
138+
139+
# config show
140+
119141
test_expect_success "'ipfs config show' does not include Pinning.RemoteServices[*].API.Key" '
120142
ipfs config show | tee show_config | jq -r .Pinning.RemoteServices > remote_services &&
121143
test_expect_code 1 grep \"Key\" remote_services &&

0 commit comments

Comments
 (0)