Skip to content

Commit

Permalink
Deprecate get_creds! function
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 17, 2017
1 parent 14ac36e commit 86c6a17
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,11 @@ end
# `SSHCredentials` and `UserPasswordCredentials` constructors using `prompt_if_incorrect`
# are deprecated in base/libgit2/types.jl.

# PR #23711
@eval LibGit2 begin
@deprecate get_creds!(cache::CachedCredentials, credid, default) get!(cache, credid, default)
end

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
4 changes: 1 addition & 3 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,9 @@ struct CachedCredentials <: AbstractCredentials
CachedCredentials() = new(Dict{String,AbstractCredentials}())
end

"Obtain the cached credentials for the given host+protocol (credid), or return and store the default if not found"
get_creds!(collection::CachedCredentials, credid, default) = get!(collection.cred, credid, default)

Base.haskey(cache::CachedCredentials, cred_id) = Base.haskey(cache.cred, cred_id)
Base.getindex(cache::CachedCredentials, cred_id) = Base.getindex(cache.cred, cred_id)
Base.get!(cache::CachedCredentials, cred_id, default) = Base.get!(cache.cred, cred_id, default)

function securezero!(p::CachedCredentials)
foreach(securezero!, values(p.cred))
Expand Down
1 change: 0 additions & 1 deletion doc/src/devdocs/libgit2.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Base.LibGit2.fullname
Base.LibGit2.features
Base.LibGit2.filename
Base.LibGit2.filemode
Base.LibGit2.get_creds!
Base.LibGit2.gitdir
Base.LibGit2.@githash_str
Base.LibGit2.head
Expand Down
2 changes: 1 addition & 1 deletion test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ mktempdir() do dir
quote
include($LIBGIT2_HELPER_PATH)
cache = CachedCredentials()
$(cached_cred !== nothing && :(LibGit2.get_creds!(cache, $cred_id, $cached_cred)))
$(cached_cred !== nothing && :(LibGit2.approve(cache, $cached_cred, $url)))
payload = CredentialPayload(cache)
err, auth_attempts = credential_loop($valid_cred, $url, "", payload)
(err, auth_attempts, cache)
Expand Down
8 changes: 4 additions & 4 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ let a = [1,2,3]
@test unsafe_securezero!(Ptr{Void}(pointer(a)), sizeof(a)) == Ptr{Void}(pointer(a))
@test a == [0,0,0]
end
let creds = Base.LibGit2.CachedCredentials()
LibGit2.get_creds!(creds, "foo", LibGit2.SSHCredentials()).pass = "bar"
securezero!(creds)
@test LibGit2.get_creds!(creds, "foo", nothing).pass == "\0\0\0"
let cache = Base.LibGit2.CachedCredentials()
get!(cache, "foo", LibGit2.SSHCredentials("", "bar"))
securezero!(cache)
@test cache["foo"].pass == "\0\0\0"
end

# Test that we can VirtualProtect jitted code to writable
Expand Down

0 comments on commit 86c6a17

Please sign in to comment.