(List (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('test_description', {[SQ <LIT_CHARS "basic credential helper tests">]})]) (Com {[LIT_CHARS .]} {[LIT_CHARS ./test-lib.sh]} ) (Com {[LIT_CHARS .]} {[DQ [VarSub TEST_DIRECTORY]] [LIT_CHARS /lib-credential.sh]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "setup helper scripts">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >dump <<-\\EOF &&\n"> <LIT_CHARS "\twhoami=`echo $0 | sed s/.*git-credential-//`\n"> <LIT_CHARS "\techo >&2 \"$whoami: $*\"\n"> <LIT_CHARS "\tOIFS=$IFS\n"> <LIT_CHARS "\tIFS==\n"> <LIT_CHARS "\twhile read key value; do\n"> <LIT_CHARS "\t\techo >&2 \"$whoami: $key=$value\"\n"> <LIT_CHARS "\t\teval \"$key=$value\"\n"> <LIT_CHARS "\tdone\n"> <LIT_CHARS "\tIFS=$OIFS\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\n"> <LIT_CHARS "\twrite_script git-credential-useless <<-\\EOF &&\n"> <LIT_CHARS "\t. ./dump\n"> <LIT_CHARS "\texit 0\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\n"> <LIT_CHARS "\twrite_script git-credential-verbatim <<-\\EOF &&\n"> <LIT_CHARS "\tuser=$1; shift\n"> <LIT_CHARS "\tpass=$1; shift\n"> <LIT_CHARS "\t. ./dump\n"> <LIT_CHARS "\ttest -z \"$user\" || echo username=$user\n"> <LIT_CHARS "\ttest -z \"$pass\" || echo password=$pass\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tPATH=\"$PWD:$PATH\"\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_fill invokes helper">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim foo bar\" <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_fill invokes multiple helpers">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill useless \"verbatim foo bar\" <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tuseless: get\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_fill stops when we get a full response">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim one two\" \"verbatim three four\" <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\tpassword=two\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_fill continues through partial response">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim one \\\"\\\"\" \"verbatim two three\" <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=two\n"> <LIT_CHARS "\tpassword=three\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: username=one\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_fill passes along metadata">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim one two\" <<-\\EOF\n"> <LIT_CHARS "\tprotocol=ftp\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=foo.git\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=ftp\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=foo.git\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\tpassword=two\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: protocol=ftp\n"> <LIT_CHARS "\tverbatim: host=example.com\n"> <LIT_CHARS "\tverbatim: path=foo.git\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_approve calls all helpers">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck approve useless \"verbatim one two\" <<-\\EOF\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tuseless: store\n"> <LIT_CHARS "\tuseless: username=foo\n"> <LIT_CHARS "\tuseless: password=bar\n"> <LIT_CHARS "\tverbatim: store\n"> <LIT_CHARS "\tverbatim: username=foo\n"> <LIT_CHARS "\tverbatim: password=bar\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "do not bother storing password-less credential">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck approve useless <<-\\EOF\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "credential_reject calls all helpers">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck reject useless \"verbatim one two\" <<-\\EOF\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tuseless: erase\n"> <LIT_CHARS "\tuseless: username=foo\n"> <LIT_CHARS "\tuseless: password=bar\n"> <LIT_CHARS "\tverbatim: erase\n"> <LIT_CHARS "\tverbatim: username=foo\n"> <LIT_CHARS "\tverbatim: password=bar\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "usernames can be preserved">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim \\\"\\\" three\" <<-\\EOF\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\tpassword=three\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: username=one\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "usernames can be overridden">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim two three\" <<-\\EOF\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=two\n"> <LIT_CHARS "\tpassword=three\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: username=one\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "do not bother completing already-full credential">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim three four\" <<-\\EOF\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\tpassword=two\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=one\n"> <LIT_CHARS "\tpassword=two\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "empty helper list falls back to internal getpass">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=askpass-username\n"> <LIT_CHARS "\tpassword=askpass-password\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\taskpass: Username:\n"> <LIT_CHARS "\taskpass: Password:\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "internal getpass does not ask for known username">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=askpass-password\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\taskpass: Password:\n"> <LIT_CHARS "\tEOF\n">]} ) (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('HELPER', {[DQ [LIT_CHARS "!f() {\n"][LIT_CHARS "\t\tcat >/dev/null\n"][LIT_CHARS "\t\techo username=foo\n"][LIT_CHARS "\t\techo password=bar\n"][LIT_CHARS "\t}; f"]]})]) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "respect configured credentials">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_config credential.helper \"$HELPER\" &&\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "match configured credential">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_config credential.https://example.com.helper \"$HELPER\" &&\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=repo.git\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "do not match configured credential">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_config credential.https://foo.helper \"$HELPER\" &&\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=bar\n"> <LIT_CHARS "\tusername=askpass-username\n"> <LIT_CHARS "\tpassword=askpass-password\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\taskpass: Username for ">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS "https://bar">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS ":\n"> <LIT_CHARS "\taskpass: Password for ">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS "https://askpass-username@bar">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS ":\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "pull username from config">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_config credential.https://example.com.username foo &&\n"> <LIT_CHARS "\tcheck fill <<-\\EOF\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=askpass-password\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\taskpass: Password for ">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS "https://foo@example.com">] [\ LIT_ESCAPED_CHAR "\\'"] [SQ <LIT_CHARS ":\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "http paths can be part of context">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck fill \"verbatim foo bar\" <<-\\EOF &&\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=foo.git\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: protocol=https\n"> <LIT_CHARS "\tverbatim: host=example.com\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\ttest_config credential.https://example.com.useHttpPath true &&\n"> <LIT_CHARS "\tcheck fill \"verbatim foo bar\" <<-\\EOF\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=foo.git\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tprotocol=https\n"> <LIT_CHARS "\thost=example.com\n"> <LIT_CHARS "\tpath=foo.git\n"> <LIT_CHARS "\tusername=foo\n"> <LIT_CHARS "\tpassword=bar\n"> <LIT_CHARS "\t--\n"> <LIT_CHARS "\tverbatim: get\n"> <LIT_CHARS "\tverbatim: protocol=https\n"> <LIT_CHARS "\tverbatim: host=example.com\n"> <LIT_CHARS "\tverbatim: path=foo.git\n"> <LIT_CHARS "\tEOF\n">]} ) (Com {[LIT_CHARS test_done]} ) )