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

Function TestIAM

pkg/credentials/iam_aws_test.go:194–222  ·  pkg/credentials/iam_aws_test.go::TestIAM
(t *testing.T)

Source from the content-addressed store, hash-verified

192}
193
194func TestIAM(t *testing.T) {
195 server := initIMDSv2Server("2014-12-16T01:51:37Z", false)
196 defer server.Close()
197
198 p := &IAM{
199 Endpoint: server.URL,
200 }
201
202 creds, err := p.RetrieveWithCredContext(defaultCredContext)
203 if err != nil {
204 t.Fatal(err)
205 }
206
207 if creds.AccessKeyID != "accessKey" {
208 t.Errorf("Expected \"accessKey\", got %s", creds.AccessKeyID)
209 }
210
211 if creds.SecretAccessKey != "secret" {
212 t.Errorf("Expected \"secret\", got %s", creds.SecretAccessKey)
213 }
214
215 if creds.SessionToken != "token" {
216 t.Errorf("Expected \"token\", got %s", creds.SessionToken)
217 }
218
219 if !p.IsExpired() {
220 t.Error("Expected creds to be expired.")
221 }
222}
223
224func TestIAMFailAssume(t *testing.T) {
225 server := initIMDSv2Server("2014-12-16T01:51:37Z", true)

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