Skip to content

Commit 8599024

Browse files
committed
Simplify test-app-secret to only need one secret
1 parent 849d1f7 commit 8599024

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

src/test-app-secrets/secrets.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
secrets:
22
- name: "example-secret"
3-
valueVar: "EXAMPLE_SECRET"
4-
- name: "pipe-secret"
5-
pipeVar: "PIPE_SECRET"
6-
- name: "path-secret"
7-
pathVar: "PATH_SECRET"
8-
- name: "multi-dest-secret"
9-
valueVar: "MULTI_VALUE"
10-
pathVar: "MULTI_PATH"
3+
valueVar: "SECRET_VALUE"
4+
pathVar: "SECRET_PATH"
5+
pipeVar: "SECRET_PIPE"

tests/test-app-secrets.bats

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ get_pid1_env() {
1515
! exec_in_container root test -e /tmp/secrets
1616
}
1717

18-
@test "secret: EXAMPLE_SECRET has correct value" {
19-
result="$(get_pid1_env EXAMPLE_SECRET)"
20-
[ "$result" = "test-value-secret" ]
18+
@test "secret: SECRET_VALUE has correct value" {
19+
result="$(get_pid1_env SECRET_VALUE)"
20+
[ "$result" = "secret-value" ]
2121
}
2222

23-
@test "secret: PIPE_SECRET fd can only be read once" {
24-
fd_path="$(get_pid1_env PIPE_SECRET)"
23+
@test "secret: SECRET_PIPE fd can only be read once" {
24+
fd_path="$(get_pid1_env SECRET_PIPE)"
2525
fd="${fd_path#/dev/fd/}"
2626
result="$(exec_in_container root cat "/proc/1/fd/${fd}")"
27-
[ "$result" = "test-pipe-secret" ]
27+
[ "$result" = "secret-value" ]
2828
result="$(exec_in_container root cat "/proc/1/fd/${fd}")"
2929
[ "$result" = "" ]
3030
}
3131

32-
@test "secret: PATH_SECRET fd is readable multiple times" {
33-
fd_path="$(get_pid1_env PATH_SECRET)"
32+
@test "secret: SECRET_PATH fd is readable multiple times" {
33+
fd_path="$(get_pid1_env SECRET_PATH)"
3434
fd="${fd_path#/dev/fd/}"
3535
result="$(exec_in_container root cat "/proc/1/fd/${fd}")"
36-
[ "$result" = "test-path-secret" ]
36+
[ "$result" = "secret-value" ]
3737
result="$(exec_in_container root cat "/proc/1/fd/${fd}")"
38-
[ "$result" = "test-path-secret" ]
38+
[ "$result" = "secret-value" ]
3939
}

tests/test-app-secrets.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ fi
1616
# Inject mock secrets to unblock the secret receiver
1717
echo "Injecting mock secrets..."
1818
echo '[
19-
{"type":"valueVar","value":"test-value-secret","target":"EXAMPLE_SECRET"},
20-
{"type":"pipeVar","value":"test-pipe-secret","target":"PIPE_SECRET"},
21-
{"type":"pathVar","value":"test-path-secret","target":"PATH_SECRET"},
22-
{"type":"valueVar","value":"test-multi-secret","target":"MULTI_VALUE"},
23-
{"type":"pathVar","value":"test-multi-secret","target":"MULTI_PATH"}
19+
{"type":"valueVar","value":"secret-value","target":"SECRET_VALUE"},
20+
{"type":"pathVar","value":"secret-value","target":"SECRET_PATH"}
21+
{"type":"pipeVar","value":"secret-value","target":"SECRET_PIPE"}
2422
]' | timeout 30 docker exec --user root -i "$CONTAINER_NAME" sh -c 'cat > /tmp/secrets'
2523

2624
bats tests/test-app-secrets.bats

0 commit comments

Comments
 (0)