feat: delete user scim v2 endpoint (#9151)

# Which Problems Are Solved
- Adds support for the user delete SCIM v2 endpoint

# How the Problems Are Solved
- Adds support for the user delete SCIM v2 endpoint under `DELETE
/scim/v2/{orgID}/Users/{id}`

# Additional Context
Part of #8140
This commit is contained in:
Lars
2025-01-09 15:12:13 +01:00
committed by GitHub
parent e621224ab2
commit af09e51b1e
10 changed files with 277 additions and 50 deletions

View File

@@ -0,0 +1,22 @@
package scim
import (
"errors"
"strconv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type AssertedScimError struct {
Error *ScimError
}
func RequireScimError(t require.TestingT, httpStatus int, err error) AssertedScimError {
require.Error(t, err)
var scimErr *ScimError
assert.True(t, errors.As(err, &scimErr))
assert.Equal(t, strconv.Itoa(httpStatus), scimErr.Status)
return AssertedScimError{scimErr} // wrap it, otherwise error handling is enforced
}

View File

@@ -58,6 +58,19 @@ func (c *ResourceClient) Create(ctx context.Context, orgID string, body []byte)
return user, err
}
func (c *ResourceClient) Delete(ctx context.Context, orgID, id string) error {
return c.do(ctx, http.MethodDelete, orgID, id)
}
func (c *ResourceClient) do(ctx context.Context, method, orgID, url string) error {
req, err := http.NewRequestWithContext(ctx, method, c.buildURL(orgID, url), nil)
if err != nil {
return err
}
return c.doReq(req, nil)
}
func (c *ResourceClient) doWithBody(ctx context.Context, method, orgID, url string, body io.Reader, responseEntity interface{}) error {
req, err := http.NewRequestWithContext(ctx, method, c.buildURL(orgID, url), body)
if err != nil {