1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-14 08:21:28 +05:30

Add support for Windows credential manager.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-02-19 19:15:51 -05:00
parent dd7a71bb12
commit 03b6cfc014
5 changed files with 103 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package wincred
import (
"testing"
"github.com/docker/docker-credential-helpers/credentials"
)
func TestWinCredHelper(t *testing.T) {
creds := &credentials.Credentials{
ServerURL: "https://foobar.docker.io:2376/v1",
Username: "foobar",
Password: "foobarbaz",
}
helper := New()
if err := helper.Add(creds); err != nil {
t.Fatal(err)
}
username, password, err := helper.Get(creds.ServerURL)
if err != nil {
t.Fatal(err)
}
if username != "foobar" {
t.Fatalf("expected %s, got %s\n", "foobar", username)
}
if password != "foobarbaz" {
t.Fatalf("expected %s, got %s\n", "foobarbaz", password)
}
if err := helper.Delete(creds.ServerURL); err != nil {
t.Fatal(err)
}
}
func TestMissingCredentials(t *testing.T) {
helper := New()
_, _, err := helper.Get("https://adsfasdf.wrewerwer.com/asdfsdddd")
if err != credentials.ErrCredentialsNotFound {
t.Fatalf("exptected ErrCredentialsNotFound, got %v", err)
}
}