(t *testing.T)
| 20 | import "testing" |
| 21 | |
| 22 | func TestStaticGet(t *testing.T) { |
| 23 | creds := NewStatic("UXHW", "SECRET", "", SignatureV4) |
| 24 | credValues, err := creds.GetWithContext(defaultCredContext) |
| 25 | if err != nil { |
| 26 | t.Fatal(err) |
| 27 | } |
| 28 | |
| 29 | if credValues.AccessKeyID != "UXHW" { |
| 30 | t.Errorf("Expected access key ID to match \"UXHW\", got %s", credValues.AccessKeyID) |
| 31 | } |
| 32 | if credValues.SecretAccessKey != "SECRET" { |
| 33 | t.Errorf("Expected secret access key to match \"SECRET\", got %s", credValues.SecretAccessKey) |
| 34 | } |
| 35 | |
| 36 | if credValues.SessionToken != "" { |
| 37 | t.Error("Expected session token to match") |
| 38 | } |
| 39 | |
| 40 | if credValues.SignerType != SignatureV4 { |
| 41 | t.Errorf("Expected 'S3v4', got %s", credValues.SignerType) |
| 42 | } |
| 43 | |
| 44 | if creds.IsExpired() { |
| 45 | t.Error("Static credentials should never expire") |
| 46 | } |
| 47 | |
| 48 | creds = NewStatic("", "", "", SignatureDefault) |
| 49 | credValues, err = creds.GetWithContext(defaultCredContext) |
| 50 | if err != nil { |
| 51 | t.Fatal(err) |
| 52 | } |
| 53 | |
| 54 | if credValues.AccessKeyID != "" { |
| 55 | t.Errorf("Expected access key ID to match empty string, got %s", credValues.AccessKeyID) |
| 56 | } |
| 57 | if credValues.SecretAccessKey != "" { |
| 58 | t.Errorf("Expected secret access key to match empty string, got %s", credValues.SecretAccessKey) |
| 59 | } |
| 60 | |
| 61 | if !credValues.SignerType.IsAnonymous() { |
| 62 | t.Errorf("Expected 'Anonymous', got %s", credValues.SignerType) |
| 63 | } |
| 64 | |
| 65 | if creds.IsExpired() { |
| 66 | t.Error("Static credentials should never expire") |
| 67 | } |
| 68 | } |
nothing calls this directly
no test coverage detected