feat: init born-multi recipients.txt + which recipients line (EGB-283)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cad5b66f77
commit
50b73083f1
2 changed files with 51 additions and 4 deletions
|
|
@ -7,14 +7,14 @@ make_second_identity() {
|
|||
BOB_PUB=$(age-keygen -y "$TEST_TMPDIR/bob.txt")
|
||||
}
|
||||
|
||||
@test "push without recipients.txt stays single-key (legacy behavior)" {
|
||||
@test "push with only-self recipients.txt encrypts to the store key (born-multi)" {
|
||||
init_with_remote
|
||||
# init now seeds recipients.txt with self — born-multi store.
|
||||
[ -e "$SECRETS_DIR/recipients.txt" ]
|
||||
create_project_dir myproj
|
||||
run "$SECRETS_BIN" push
|
||||
[ "$status" -eq 0 ]
|
||||
# No recipients.txt was created by push.
|
||||
[ ! -e "$SECRETS_DIR/recipients.txt" ]
|
||||
# Blob decrypts with the store's own key.
|
||||
# Blob must still decrypt with the store's own key.
|
||||
run age -d -i "$SECRETS_DIR/key.txt" "$SECRETS_DIR/myproj/.env.age"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
@ -49,6 +49,8 @@ make_second_identity() {
|
|||
init_with_remote
|
||||
STORE_PUB=$(age-keygen -y "$SECRETS_DIR/key.txt")
|
||||
printf '%s\n' "$STORE_PUB" > "$TEST_TMPDIR/elsewhere.txt"
|
||||
# Remove the born-multi recipients.txt so we can replace it with a symlink.
|
||||
rm -f "$SECRETS_DIR/recipients.txt"
|
||||
ln -s "$TEST_TMPDIR/elsewhere.txt" "$SECRETS_DIR/recipients.txt"
|
||||
create_project_dir myproj
|
||||
run "$SECRETS_BIN" push
|
||||
|
|
@ -58,6 +60,8 @@ make_second_identity() {
|
|||
|
||||
@test "recipients list on a legacy store shows the single derived key" {
|
||||
init_with_remote
|
||||
# Simulate a legacy store by removing the born-multi recipients.txt.
|
||||
rm -f "$SECRETS_DIR/recipients.txt"
|
||||
run "$SECRETS_BIN" recipients list
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"single-key"* ]] || false
|
||||
|
|
@ -117,6 +121,8 @@ make_second_identity() {
|
|||
create_project_dir myproj
|
||||
run "$SECRETS_BIN" push
|
||||
before=$(cat "$SECRETS_DIR/key.txt")
|
||||
# Simulate a legacy store by removing the born-multi recipients.txt.
|
||||
rm -f "$SECRETS_DIR/recipients.txt"
|
||||
run "$SECRETS_BIN" rekey
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$SECRETS_DIR/key.txt")" != "$before" ]
|
||||
|
|
@ -229,3 +235,23 @@ make_second_identity() {
|
|||
[ "$status" -ne 0 ]
|
||||
[[ "$output" == *"No recipient matches"* ]] || false
|
||||
}
|
||||
|
||||
@test "init seeds recipients.txt with the new store key (born-multi)" {
|
||||
run "$SECRETS_BIN" init
|
||||
[ "$status" -eq 0 ]
|
||||
[ -e "$SECRETS_DIR/recipients.txt" ]
|
||||
STORE_PUB=$(age-keygen -y "$SECRETS_DIR/key.txt")
|
||||
run cat "$SECRETS_DIR/recipients.txt"
|
||||
[[ "$output" == *"$STORE_PUB"* ]] || false
|
||||
}
|
||||
|
||||
@test "which reports the recipient count" {
|
||||
init_with_remote
|
||||
make_second_identity
|
||||
run "$SECRETS_BIN" recipients add "$BOB_PUB" --name bob
|
||||
create_project_dir myproj
|
||||
run "$SECRETS_BIN" which
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"recipients: 2"* ]] || false
|
||||
[[ "$output" == *"bob"* ]] || false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue