MCPcopy
hub / github.com/containerd/containerd / TestBasicAuthTokenResolver

Function TestBasicAuthTokenResolver

core/remotes/docker/resolver_test.go:129–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestBasicAuthTokenResolver(t *testing.T) {
130 th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
131 if r.Method != http.MethodGet {
132 rw.WriteHeader(http.StatusMethodNotAllowed)
133 return
134 }
135 rw.Header().Set("Content-Type", "application/json")
136 rw.WriteHeader(http.StatusOK)
137 username, password, ok := r.BasicAuth()
138 if !ok || username != "user1" || password != "password1" {
139 rw.Write([]byte(`{"access_token":"insufficientscope"}`))
140 } else {
141 rw.Write([]byte(`{"access_token":"perfectlyvalidopaquetoken"}`))
142 }
143 })
144 creds := func(string) (string, string, error) {
145 return "user1", "password1", nil
146 }
147
148 runBasicTest(t, "testname", withTokenServer(th, creds))
149}
150
151func TestRefreshTokenResolver(t *testing.T) {
152 th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 5

withTokenServerFunction · 0.85
HeaderMethod · 0.80
runBasicTestFunction · 0.70
SetMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…