mirror of
https://github.com/git/git.git
synced 2026-04-07 15:30:09 +02:00
credential/libsecret: store new attributes
d208bfd(credential: new attribute password_expiry_utc, 2023-02-18) anda5c76569e7(credential: new attribute oauth_refresh_token) introduced new credential attributes. libsecret assumes attribute values are non-confidential and unchanging, so we encode the new attributes in the secret, separated by newline: hunter2 password_expiry_utc=1684189401 oauth_refresh_token=xyzzy This is extensible and backwards compatible. The credential protocol already assumes that attribute values do not contain newlines. Alternatives considered: store password_expiry_utc in a libsecret attribute. This has the problem that libsecret creates new items rather than overwrites when attribute values change. Signed-off-by: M Hickford <mirth.hickford@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
0df2c18090
commit
0ce02e2fec
@@ -43,6 +43,8 @@ helper_test_clean() {
|
||||
reject $1 https example.com store-user
|
||||
reject $1 https example.com user1
|
||||
reject $1 https example.com user2
|
||||
reject $1 https example.com user-expiry
|
||||
reject $1 https example.com user-expiry-overwrite
|
||||
reject $1 https example.com user4
|
||||
reject $1 http path.tld user
|
||||
reject $1 https timeout.tld user
|
||||
@@ -328,6 +330,81 @@ helper_test_timeout() {
|
||||
'
|
||||
}
|
||||
|
||||
helper_test_password_expiry_utc() {
|
||||
HELPER=$1
|
||||
|
||||
test_expect_success "helper ($HELPER) stores password_expiry_utc" '
|
||||
check approve $HELPER <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry
|
||||
password=pass
|
||||
password_expiry_utc=9999999999
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success "helper ($HELPER) gets password_expiry_utc" '
|
||||
check fill $HELPER <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry
|
||||
password=pass
|
||||
password_expiry_utc=9999999999
|
||||
--
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success "helper ($HELPER) overwrites when password_expiry_utc changes" '
|
||||
check approve $HELPER <<-\EOF &&
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
password=pass1
|
||||
password_expiry_utc=9999999998
|
||||
EOF
|
||||
check approve $HELPER <<-\EOF &&
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
password=pass2
|
||||
password_expiry_utc=9999999999
|
||||
EOF
|
||||
check fill $HELPER <<-\EOF &&
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
password=pass2
|
||||
password_expiry_utc=9999999999
|
||||
EOF
|
||||
check reject $HELPER <<-\EOF &&
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
password=pass2
|
||||
EOF
|
||||
check fill $HELPER <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=user-expiry-overwrite
|
||||
password=askpass-password
|
||||
--
|
||||
askpass: Password for '\''https://user-expiry-overwrite@example.com'\'':
|
||||
EOF
|
||||
'
|
||||
}
|
||||
|
||||
helper_test_oauth_refresh_token() {
|
||||
HELPER=$1
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ test_atexit 'git credential-cache exit'
|
||||
|
||||
# test that the daemon works with no special setup
|
||||
helper_test cache
|
||||
helper_test_password_expiry_utc cache
|
||||
helper_test_oauth_refresh_token cache
|
||||
|
||||
test_expect_success 'socket defaults to ~/.cache/git/credential/socket' '
|
||||
|
||||
@@ -45,6 +45,8 @@ test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
|
||||
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
|
||||
|
||||
helper_test "$GIT_TEST_CREDENTIAL_HELPER"
|
||||
helper_test_password_expiry_utc "$GIT_TEST_CREDENTIAL_HELPER"
|
||||
helper_test_oauth_refresh_token "$GIT_TEST_CREDENTIAL_HELPER"
|
||||
|
||||
if test -z "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"; then
|
||||
say "# skipping timeout tests (GIT_TEST_CREDENTIAL_HELPER_TIMEOUT not set)"
|
||||
|
||||
Reference in New Issue
Block a user