(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func 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 | }, |
nothing calls this directly
no test coverage detected