Skip to content

Commit

Permalink
Query filter for /secrets should use single quotes
Browse files Browse the repository at this point in the history
Unlike other resources, when filtering secrets by
name, the name should be surrounded by single quotes.

If no quotes are present the following error is returned:

```
{"httpStatusCode":400,"errorCode":"HPE_GL_DATA_SERVICES_INVALID_PARAMETER","message":"unsupported OData filter \"name eq foo\" due to unsupported OData comparison value type (must be String)","debugId":"f461e8f8dc017a5fca7d6a6c404c0016"}
```
  • Loading branch information
stuart-mclaren-hpe committed Dec 17, 2024
1 parent 4d0d5d4 commit 4528488
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/datasources/secret/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *DataSource) Configure(
}

func createNameFilter(name string) string {
return constants.NameFilter + name
return constants.NameFilter + "'" + name + "'"
}

func getSecretByName(
Expand Down
4 changes: 2 additions & 2 deletions internal/simulator/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func simulateSecretGetByName() {

gock.New("http://localhost").
Get("/data-services/v1beta1/secrets").
MatchParam("filter", "name eq "+secretName).
MatchParam("filter", "name eq "+ "'" + secretName + "'").
MatchHeader("Authorization", "Bearer abcdefghijklmnopqrstuvwxyz-0123456789").
Reply(200).
SetHeader("Content-Type", "application/json").
BodyString(secretByName)

gock.New("http://localhost").
Get("/data-services/v1beta1/secrets").
MatchParam("filter", "name eq "+secretName).
MatchParam("filter", "name eq "+ "'" + secretName + "'").
MatchHeader("Authorization", "Bearer expired-token").
Reply(401).
SetHeader("Content-Type", "text/plain").
Expand Down

0 comments on commit 4528488

Please sign in to comment.