(t *testing.T)
| 239 | } |
| 240 | |
| 241 | func 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 | |
| 274 | func TestEcsTask(t *testing.T) { |
| 275 | server := initEcsTaskTestServer("2014-12-16T01:51:37Z") |
nothing calls this directly
no test coverage detected