MCPcopy
hub / github.com/kubernetes/client-go / TestRefreshCreds

Function TestRefreshCreds

plugin/pkg/client/auth/exec/exec_test.go:165–499  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestRefreshCreds(t *testing.T) {
166 tests := []struct {
167 name string
168 config api.ExecConfig
169 output string
170 interactive bool
171 response *clientauthentication.Response
172 wantInput string
173 wantCreds credentials
174 wantExpiry time.Time
175 wantErr bool
176 }{
177 {
178 name: "basic-request",
179 config: api.ExecConfig{
180 APIVersion: "client.authentication.k8s.io/v1alpha1",
181 },
182 wantInput: `{
183 "kind":"ExecCredential",
184 "apiVersion":"client.authentication.k8s.io/v1alpha1",
185 "spec": {}
186 }`,
187 output: `{
188 "kind": "ExecCredential",
189 "apiVersion": "client.authentication.k8s.io/v1alpha1",
190 "status": {
191 "token": "foo-bar"
192 }
193 }`,
194 wantCreds: credentials{token: "foo-bar"},
195 },
196 {
197 name: "interactive",
198 config: api.ExecConfig{
199 APIVersion: "client.authentication.k8s.io/v1alpha1",
200 },
201 interactive: true,
202 wantInput: `{
203 "kind":"ExecCredential",
204 "apiVersion":"client.authentication.k8s.io/v1alpha1",
205 "spec": {
206 "interactive": true
207 }
208 }`,
209 output: `{
210 "kind": "ExecCredential",
211 "apiVersion": "client.authentication.k8s.io/v1alpha1",
212 "status": {
213 "token": "foo-bar"
214 }
215 }`,
216 wantCreds: credentials{token: "foo-bar"},
217 },
218 {
219 name: "response",
220 config: api.ExecConfig{
221 APIVersion: "client.authentication.k8s.io/v1alpha1",
222 },

Callers

nothing calls this directly

Calls 7

newAuthenticatorFunction · 0.85
newCacheFunction · 0.85
compJSONFunction · 0.85
refreshCredsLockedMethod · 0.80
RunMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected