Skip to content

Commit 5b764cc

Browse files
committed
changes to wincred, completes list functionality in windows
Signed-off-by: avaid96 <[email protected]>
1 parent b63a32e commit 5b764cc

File tree

5 files changed

+63
-6
lines changed

5 files changed

+63
-6
lines changed

vendor/github.com/danieljoos/wincred/conversion.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/danieljoos/wincred/native.go

Lines changed: 36 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/danieljoos/wincred/wincred.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wincred/wincred_windows.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ func (h Wincred) Get(serverURL string) (string, string, error) {
3939
}
4040

4141
func (h Wincred) List() ([]string, []string, error) {
42-
accts, paths, err := winc.List()
42+
creds, err := winc.List()
43+
paths := make([]string, len(creds))
44+
accts := make([]string, len(creds))
4345
if err != nil {
4446
return err
4547
}
48+
for i := range(creds) {
49+
paths[i] = creds[i].TargetName
50+
accts[i] = creds[i].UserName
51+
}
4652
return paths, accts, nil
4753
}

wincred/wincred_windows_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ func TestWinCredHelper(t *testing.T) {
3131
t.Fatalf("expected %s, got %s\n", "foobarbaz", secret)
3232
}
3333

34+
paths, accts, err := helper.List()
35+
if err != nil || len(paths) == 0 || len(accts) == 0 {
36+
t.Fatal(err)
37+
}
38+
39+
helper.Add(creds1)
40+
defer helper.Delete(creds1.ServerURL)
41+
newpaths, newaccts, err := helper.List()
42+
if len(newpaths)-len(paths) != 1 || len(newaccts)-len(accts) != 1 {
43+
if(err == nil) {
44+
t.Fatalf("Error: len(newpaths): %d, len(paths): %d\n len(newaccts): %d, len(accts): %d\n Error= %s", len(newpaths), len(paths), len(newaccts), len(accts), "")
45+
}
46+
t.Fatalf("Error: len(newpaths): %d, len(paths): %d\n len(newaccts): %d, len(accts): %d\n Error= %s", len(newpaths), len(paths), len(newaccts), len(accts), err.Error())
47+
}
48+
3449
if err := helper.Delete(creds.ServerURL); err != nil {
3550
t.Fatal(err)
3651
}

0 commit comments

Comments
 (0)