MCPcopy
hub / github.com/minio/minio-go / TestIAMIsExpired

Function TestIAMIsExpired

pkg/credentials/iam_aws_test.go:241–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

239}
240
241func TestIAMIsExpired(t *testing.T) {
242 server := initIMDSv2Server("2014-12-16T01:51:37Z", false)
243 defer server.Close()
244
245 p := &IAM{
246 Endpoint: server.URL,
247 }
248 p.CurrentTime = func() time.Time {
249 return time.Date(2014, 12, 15, 21, 26, 0, 0, time.UTC)
250 }
251
252 if !p.IsExpired() {
253 t.Error("Expected creds to be expired before retrieve.")
254 }
255
256 _, err := p.RetrieveWithCredContext(defaultCredContext)
257 if err != nil {
258 t.Fatal(err)
259 }
260
261 if p.IsExpired() {
262 t.Error("Expected creds to not be expired after retrieve.")
263 }
264
265 p.CurrentTime = func() time.Time {
266 return time.Date(3014, 12, 15, 21, 26, 0, 0, time.UTC)
267 }
268
269 if !p.IsExpired() {
270 t.Error("Expected creds to be expired when curren time has changed")
271 }
272}
273
274func TestEcsTask(t *testing.T) {
275 server := initEcsTaskTestServer("2014-12-16T01:51:37Z")

Callers

nothing calls this directly

Calls 5

initIMDSv2ServerFunction · 0.85
IsExpiredMethod · 0.65
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected