url.PathEscape resource ids in the sdk before sending building a request. (#2035)
This commit is contained in:
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())
|
||||
|
||||
|
||||
Reference in new issue
Block a user