url.PathEscape resource ids in the sdk before sending building a request. (#2035)

This commit is contained in:
Todd authored and GitHub committed 2022-04-27 08:13:46 -07:00
1 parent 89196f2ce7
commit a1cf3234ed
29 files changed
+199 -87

No files matched your search

@@ -1,6 +1,7 @@
package authmethods_test
import (
"fmt"
"net/http"
"os"
"sync"
@@ -319,10 +320,19 @@ func TestErrors(t *testing.T) {
require.NoError(err)
assert.NotNil(u)
// A malformed id is processed as the id and not a different path to the api.
_, err = amClient.Read(tc.Context(), fmt.Sprintf("%s/../", u.Item.Id))
require.Error(err)
apiErr := api.AsServerError(err)
require.NotNil(apiErr)
assert.EqualValues(http.StatusBadRequest, apiErr.Response().StatusCode())
require.Len(apiErr.Details.RequestFields, 1)
assert.Equal(apiErr.Details.RequestFields[0].Name, "id")
// Updating the wrong version should fail.
_, err = amClient.Update(tc.Context(), u.Item.Id, 73, authmethods.WithName("anything"))
require.Error(err)
apiErr := api.AsServerError(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())