When a Certificate inside the library contained a : in the alias (name), the functions Client.GetCertificateFromLibraryByName and AdminOrg.GetCertificateFromLibraryByName are not able to find it, returning an ENF (Entity Not Found) error.
How to reproduce
Given any VCD version, it is as simple as changing the certificate name in the tests, for example:
alias := "Test_CertificateInLibrary:1"
Fix
The function shouldDoSlowSearch documentation made the following statements:
shouldDoSlowSearch (...) the encoding is rejected by the API in VCD 10.2 version.
(...) Yet, this not needed anymore in VCD 10.3 version.
(...)
However, if one uses Postman to send the following query in VCD 10.4.x:
"minorErrorCode": "BAD_REQUEST",
"message": "Cannot parse the supplied filter: alias==Test;Certificate;In;Library&filterEncoded=true&pageSize=128",
"stackTrace": "com.vmware.vcloud.api.rest.parser.QueryParseException: Cannot parse the supplied filter: alias==Test;Certificate;In;Library&filterEncoded=true&pageSize=128\n\tat com.vmware.vcloud.api.rest.providers.filters.openapi.QueryValidationFilter.enforceFilteringRestric
So, the statements are false. For this reason, this PR removes the VCD version check in shouldDoSlowSearch, as this issue happens always and independent of the VCD version.
This PR also removes the url.QueryEscape inside shouldDoSlowSearch:
This operation is wrong, as the OpenAPI generic calls to retrieve all items also escape the parameters:
func (client *Client) newOpenApiRequest(...) {
...
// Add the params to our URL
reqUrlCopy.RawQuery += params.Encode()
So in result, the alias==%s filter was encoded twice, causing the VCD filter processor to fail when the alias has special characters like :, as they're encoded twice.
Tests
Tested in 10.4.2
GOVCD_SKIP_VAPP_CREATION=1 go test -tags functional -check.f 'Test_CertificateInLibrary|Test_GetCertificateFromLibrary.*|Test_NsxtVdcGroup' -check.vv -timeout=0
Bug description
When a Certificate inside the library contained a
:
in the alias (name), the functionsClient.GetCertificateFromLibraryByName
andAdminOrg.GetCertificateFromLibraryByName
are not able to find it, returning an ENF (Entity Not Found) error.How to reproduce
Given any VCD version, it is as simple as changing the certificate name in the tests, for example:
Fix
The function
shouldDoSlowSearch
documentation made the following statements:However, if one uses Postman to send the following query in VCD 10.4.x:
It returns the error:
So, the statements are false. For this reason, this PR removes the VCD version check in shouldDoSlowSearch, as this issue happens always and independent of the VCD version.
This PR also removes the
url.QueryEscape
inside shouldDoSlowSearch:This operation is wrong, as the OpenAPI generic calls to retrieve all items also escape the parameters:
So in result, the
alias==%s
filter was encoded twice, causing the VCD filter processor to fail when the alias has special characters like:
, as they're encoded twice.Tests
Tested in 10.4.2