From a74e11812d8ac5dc51a0b46ec55206b73413e8b0 Mon Sep 17 00:00:00 2001 From: Stuart McLaren Date: Tue, 17 Dec 2024 15:19:47 +0000 Subject: [PATCH] Query filter for /secrets should use single quotes 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"} ``` --- internal/datasources/secret/data_source.go | 2 +- internal/simulator/secret.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/datasources/secret/data_source.go b/internal/datasources/secret/data_source.go index c8cf9bb..f0438f6 100644 --- a/internal/datasources/secret/data_source.go +++ b/internal/datasources/secret/data_source.go @@ -62,7 +62,7 @@ func (s *DataSource) Configure( } func createNameFilter(name string) string { - return constants.NameFilter + name + return constants.NameFilter + "'" + name + "'" } func getSecretByName( diff --git a/internal/simulator/secret.go b/internal/simulator/secret.go index e4589cc..4aa6975 100644 --- a/internal/simulator/secret.go +++ b/internal/simulator/secret.go @@ -18,7 +18,7 @@ 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"). @@ -26,7 +26,7 @@ func simulateSecretGetByName() { 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").