Debian Codegraph @

creds/netrc_test.go

raw symbols SCIP
1 package credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/
2
3 import (
4 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
5 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
6
7 "github.com/git-lfs/go-netrc/netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/"
8 )
9
10 func TestNetrcWithHostAndPortscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/TestNetrcWithHostAndPort().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
11 var netrcHelper netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#
12 netrcHelper.netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder. = &fakeNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc#{}
13
14 what := make(Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#)
15 what["protocol"] = []string{"http"}
16 what["host"] = []string{"netrc-host:123"}
17 what["path"] = []string{"/foo/bar"}
18
19 creds, err := netrcHelper.Fillscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Fill().(what)
20 if err != nil {
21 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error retrieving netrc credentials: %s", err)
22 }
23
24 username := creds["username"][0]
25 if username != "abc" {
26 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("bad username: %s", username)
27 }
28
29 password := creds["password"][0]
30 if password != "def" {
31 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("bad password: %s", password)
32 }
33 }
34
35 func TestNetrcWithHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/TestNetrcWithHost().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
36 var netrcHelper netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#
37 netrcHelper.netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder. = &fakeNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc#{}
38
39 what := make(Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#)
40 what["protocol"] = []string{"http"}
41 what["host"] = []string{"netrc-host"}
42 what["path"] = []string{"/foo/bar"}
43
44 creds, err := netrcHelper.Fillscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Fill().(what)
45 if err != nil {
46 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error retrieving netrc credentials: %s", err)
47 }
48
49 username := creds["username"][0]
50 if username != "abc" {
51 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("bad username: %s", username)
52 }
53
54 password := creds["password"][0]
55 if password != "def" {
56 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("bad password: %s", password)
57 }
58 }
59
60 func TestNetrcWithBadHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/TestNetrcWithBadHost().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
61 var netrcHelper netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#
62 netrcHelper.netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder. = &fakeNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc#{}
63
64 what := make(Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#)
65 what["protocol"] = []string{"http"}
66 what["host"] = []string{"other-host"}
67 what["path"] = []string{"/foo/bar"}
68
69 _, err := netrcHelper.Fillscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Fill().(what)
70 if err != credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. {
71 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("expected no-op for unknown host other-host")
72 }
73 }
74
75 type fakeNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc# struct{}
76
77 func (n *fakeNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc#) FindMachinescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/fakeNetrc#FindMachine().(host string, loginName string) *netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/.Machinescip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine# {
78 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(host, "netrc") {
79 return &netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/.Machinescip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#{Loginscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#Login.: "abc", Passwordscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#Password.: "def"}
80 }
81 return nil
82 }