@@ -1902,6 +1902,39 @@ mktempdir() do dir
1902
1902
@test auth_attempts == 2
1903
1903
end
1904
1904
1905
+ @testset " SSH agent username" begin
1906
+ url = " github.com:test/package.jl"
1907
+
1908
+ valid_key = joinpath (KEY_DIR, " valid" )
1909
+ username = " git"
1910
+
1911
+ ssh_empty_ex = quote
1912
+ include ($ LIBGIT2_HELPER_PATH)
1913
+ valid_cred = LibGit2. SSHCredentials ($ username, " " , $ valid_key, $ (valid_key * " .pub" ))
1914
+ credential_loop (valid_cred, $ url, Nullable (" " ), use_ssh_agent= true )
1915
+ end
1916
+
1917
+ ssh_null_ex = quote
1918
+ include ($ LIBGIT2_HELPER_PATH)
1919
+ valid_cred = LibGit2. SSHCredentials ($ username, " " , $ valid_key, $ (valid_key * " .pub" ))
1920
+ credential_loop (valid_cred, $ url, Nullable (), use_ssh_agent= true )
1921
+ end
1922
+
1923
+ challenges = [
1924
+ " Username for 'github.com':" => " \x 04" ,
1925
+ ]
1926
+
1927
+ err, auth_attempts = challenge_prompt (ssh_empty_ex, challenges)
1928
+ @test err == abort_prompt # TODO : `eauth_error` when we can disable prompting
1929
+ @test auth_attempts == 2
1930
+
1931
+ # A null username_ptr passed into `git_cred_ssh_key_from_agent` can cause a
1932
+ # segfault.
1933
+ err, auth_attempts = challenge_prompt (ssh_null_ex, challenges)
1934
+ @test err == abort_prompt # TODO : `eauth_error` when we can disable prompting
1935
+ @test auth_attempts == 1
1936
+ end
1937
+
1905
1938
@testset " SSH explicit credentials" begin
1906
1939
url = " git@github.com:test/package.jl"
1907
1940
0 commit comments