MCPcopy Index your code
hub / github.com/getsops/sops / TestMasterKey_createSTSConfig

Function TestMasterKey_createSTSConfig

kms/keysource_test.go:550–572  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

548}
549
550func 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
574func Test_stsSessionName(t *testing.T) {
575 t.Run("STS session name", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

NewMasterKeyFromArnFunction · 0.85
createSTSConfigMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected