MCPcopy
hub / github.com/containerd/containerd / TestRefreshTokenResolver

Function TestRefreshTokenResolver

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

Source from the content-addressed store, hash-verified

149}
150
151func TestRefreshTokenResolver(t *testing.T) {
152 th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
153 if r.Method != http.MethodPost {
154 rw.WriteHeader(http.StatusMethodNotAllowed)
155 return
156 }
157 rw.Header().Set("Content-Type", "application/json")
158 rw.WriteHeader(http.StatusOK)
159
160 r.ParseForm()
161 if r.PostForm.Get("grant_type") != "refresh_token" || r.PostForm.Get("refresh_token") != "somerefreshtoken" {
162 rw.Write([]byte(`{"access_token":"insufficientscope"}`))
163 } else {
164 rw.Write([]byte(`{"access_token":"perfectlyvalidopaquetoken"}`))
165 }
166 })
167 creds := func(string) (string, string, error) {
168 return "", "somerefreshtoken", nil
169 }
170
171 runBasicTest(t, "testname", withTokenServer(th, creds))
172}
173
174func TestFetchRefreshToken(t *testing.T) {
175 f := func(t *testing.T, disablePOST bool) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…