diff --git a/authority/provisioner/provisioner.go b/authority/provisioner/provisioner.go index 29ebc902..291a74d5 100644 --- a/authority/provisioner/provisioner.go +++ b/authority/provisioner/provisioner.go @@ -89,6 +89,24 @@ const ( SignAudienceKey = "sign" ) +// String returns the string representation of the type. +func (t Type) String() string { + switch t { + case TypeJWK: + return "JWK" + case TypeOIDC: + return "OIDC" + case TypeGCP: + return "GCP" + case TypeAWS: + return "AWS" + case TypeAzure: + return "Azure" + default: + return "" + } +} + // Config defines the default parameters used in the initialization of // provisioners. type Config struct { diff --git a/authority/provisioner/provisioner_test.go b/authority/provisioner/provisioner_test.go new file mode 100644 index 00000000..11615e1a --- /dev/null +++ b/authority/provisioner/provisioner_test.go @@ -0,0 +1,26 @@ +package provisioner + +import "testing" + +func TestType_String(t *testing.T) { + tests := []struct { + name string + t Type + want string + }{ + {"JWK", TypeJWK, "JWK"}, + {"OIDC", TypeOIDC, "OIDC"}, + {"AWS", TypeAWS, "AWS"}, + {"Azure", TypeAzure, "Azure"}, + {"GCP", TypeGCP, "GCP"}, + {"noop", noopType, ""}, + {"notFound", 1000, ""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.String(); got != tt.want { + t.Errorf("Type.String() = %v, want %v", got, tt.want) + } + }) + } +}