1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

Make sure missing credentials returns the right error.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-02-09 15:52:53 -08:00
parent a701e3c310
commit 4b716da070
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -18,9 +18,9 @@ import (
"github.com/calavera/docker-credential-helpers/credentials" "github.com/calavera/docker-credential-helpers/credentials"
) )
// notFoundError is the specific error message returned by OS X // errCredentialsNotFound is the specific error message returned by OS X
// when the credentials are not in the keychain. // when the credentials are not in the keychain.
const notFoundError = "The specified item could not be found in the keychain." const errCredentialsNotFound = "The specified item could not be found in the keychain."
type osxkeychain struct{} type osxkeychain struct{}
@@ -88,7 +88,7 @@ func (h osxkeychain) Get(serverURL string) (string, string, error) {
defer C.free(unsafe.Pointer(errMsg)) defer C.free(unsafe.Pointer(errMsg))
goMsg := C.GoString(errMsg) goMsg := C.GoString(errMsg)
if goMsg == notFoundError { if goMsg == errCredentialsNotFound {
return "", "", credentials.ErrCredentialsNotFound return "", "", credentials.ErrCredentialsNotFound
} }
+8
View File
@@ -35,3 +35,11 @@ func TestOSXKeychainHelper(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestMissingCredentials(t *testing.T) {
helper := New()
_, _, err := helper.Get("https://adsfasdf.wrewerwer.com/asdfsdddd")
if err != credentials.ErrCredentialsNotFound {
t.Fatal("exptected ErrCredentialsNotFound, got %v", err)
}
}