Skip to content

Commit

Permalink
fix: const for rawResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
duffney committed Dec 5, 2024
1 parent 762f5c9 commit eada4d6
Showing 1 changed file with 10 additions and 40 deletions.
50 changes: 10 additions & 40 deletions pkg/keymanagementprovider/azurekeyvault/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ import (
"github.com/stretchr/testify/mock"
)

const rawResponse = `{
"error": {
"code": "Forbidden",
"message": "Operation get is not allowed on a disabled secret.",
"innererror": {
"code": "SecretDisabled"
}
}
}`

// TestCreate tests the Create function
func TestCreate(t *testing.T) {
factory := &akvKMProviderFactory{}
Expand Down Expand Up @@ -361,16 +371,6 @@ func TestGetCertificates(t *testing.T) {
},
mockSecretKVClient: &MockSecretKVClient{
GetSecretFunc: func(_ context.Context, _ string, _ string) (azsecrets.GetSecretResponse, error) {
rawResponse := `{
"error": {
"code": "Forbidden",
"message": "Operation get is not allowed on a disabled secret.",
"innererror": {
"code": "SecretDisabled"
}
}
}`

httpErr := &azcore.ResponseError{
StatusCode: http.StatusForbidden,
RawResponse: &http.Response{
Expand All @@ -392,16 +392,6 @@ func TestGetCertificates(t *testing.T) {
},
mockSecretKVClient: &MockSecretKVClient{
GetSecretFunc: func(_ context.Context, _ string, _ string) (azsecrets.GetSecretResponse, error) {
rawResponse := `{
"error": {
"code": "Forbidden",
"message": "Operation get is not allowed on a disabled secret.",
"innererror": {
"code": "SecretDisabled"
}
}
}`

httpErr := &azcore.ResponseError{
StatusCode: http.StatusForbidden,
RawResponse: &http.Response{
Expand Down Expand Up @@ -652,16 +642,6 @@ func TestGetCertificates(t *testing.T) {
},
mockSecretKVClient: &MockSecretKVClient{
GetSecretFunc: func(_ context.Context, _ string, _ string) (azsecrets.GetSecretResponse, error) {
rawResponse := `{
"error": {
"code": "Forbidden",
"message": "Operation get is not allowed on a disabled secret.",
"innererror": {
"code": "SecretDisabled"
}
}
}`

httpErr := &azcore.ResponseError{
StatusCode: http.StatusForbidden,
RawResponse: &http.Response{
Expand Down Expand Up @@ -1646,16 +1626,6 @@ func TestInitializeKvClient_FailureInAzCertificatesClient(t *testing.T) {
assert.Contains(t, err.Error(), "failed to create workload identity credential")
}
func TestIsSecretDisabledError(t *testing.T) {
rawResponse := `{
"error": {
"code": "Forbidden",
"message": "Operation get is not allowed on a disabled secret.",
"innererror": {
"code": "SecretDisabled"
}
}
}`

httpErr := &azcore.ResponseError{
StatusCode: http.StatusForbidden,
RawResponse: &http.Response{
Expand Down

0 comments on commit eada4d6

Please sign in to comment.