Skip to content

Commit c5e35e3

Browse files
committed
Add keychain_access_control tests
1 parent 5c51b19 commit c5e35e3

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

test/macos_keychain.bash

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ _delete_keychain() {
88
security delete-keychain "${PW_KEYCHAIN}"
99
}
1010

11-
_config_append_macos_keychain() {
11+
_config_append_macos_keychain_keychain_access_control_always_allow() {
1212
cat >> "${PW_CONFIG}" << EOF
1313
[macos_keychain]
1414
keychain_access_control = always-allow
1515
EOF
1616
}
17+
18+
_config_append_macos_keychain_keychain_access_control_confirm() {
19+
cat >> "${PW_CONFIG}" << EOF
20+
[macos_keychain]
21+
keychain_access_control = confirm
22+
EOF
23+
}

test/macos_keychain.bats

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ setup() {
88
_set_config_with_copy_paste
99
# shellcheck disable=SC2016
1010
_config_append_with_plugin '$PW_HOME/plugins/macos_keychain'
11-
_config_append_macos_keychain
11+
_config_append_macos_keychain_keychain_access_control_always_allow
1212
pw init "${PW_KEYCHAIN}" <<< "${KEYCHAIN_TEST_PASSWORD}"
1313
}
1414

@@ -181,6 +181,21 @@ ${MULTI_LINE_NOTES}
181181
EOF
182182
}
183183

184+
@test "adds item with access control always-allow" {
185+
assert_adds_item "${PW_1}" "${NAME_A}"
186+
run security dump-keychain -a "${PW_KEYCHAIN}"
187+
assert_success
188+
assert_output --partial "com.apple.security"
189+
}
190+
191+
@test "adds item with access control confirm" {
192+
_config_append_macos_keychain_keychain_access_control_confirm
193+
assert_adds_item "${PW_1}" "${NAME_A}"
194+
run security dump-keychain -a "${PW_KEYCHAIN}"
195+
assert_success
196+
refute_output --partial "com.apple.security"
197+
}
198+
184199
################################################################################
185200
# add another
186201
################################################################################

0 commit comments

Comments
 (0)