(t *testing.T)
| 548 | } |
| 549 | |
| 550 | func TestMasterKey_createSTSConfig(t *testing.T) { |
| 551 | t.Run("session name error", func(t *testing.T) { |
| 552 | defer func() { osHostname = os.Hostname }() |
| 553 | osHostname = func() (name string, err error) { |
| 554 | err = fmt.Errorf("an error") |
| 555 | return |
| 556 | } |
| 557 | key := NewMasterKeyFromArn(dummyARN, nil, "") |
| 558 | cfg, err := key.createSTSConfig(context.Background(), nil) |
| 559 | assert.Error(t, err) |
| 560 | assert.ErrorContains(t, err, "failed to construct STS session name") |
| 561 | assert.Nil(t, cfg) |
| 562 | }) |
| 563 | |
| 564 | t.Run("role assumption error", func(t *testing.T) { |
| 565 | key := NewMasterKeyFromArn(dummyARN, nil, "") |
| 566 | key.Role = "role" |
| 567 | got, err := key.createSTSConfig(context.Background(), &aws.Config{}) |
| 568 | assert.Error(t, err) |
| 569 | assert.ErrorContains(t, err, "failed to assume role 'role'") |
| 570 | assert.Nil(t, got) |
| 571 | }) |
| 572 | } |
| 573 | |
| 574 | func Test_stsSessionName(t *testing.T) { |
| 575 | t.Run("STS session name", func(t *testing.T) { |
nothing calls this directly
no test coverage detected