Skip to content

Commit

Permalink
fix: Return the updated identity as described in the API spec
Browse files Browse the repository at this point in the history
  • Loading branch information
borisroman committed Jun 26, 2023
1 parent ae22c7c commit 0862ef2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion identity/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,5 +947,5 @@ func (h *Handler) deleteIdentityCredentials(w http.ResponseWriter, r *http.Reque
return
}

w.WriteHeader(http.StatusNoContent)
h.r.Writer().Write(w, r, WithCredentialsMetadataAndAdminMetadataInJSON(*identity))
}
6 changes: 3 additions & 3 deletions identity/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ func TestHandler(t *testing.T) {
t.Run("type=remove webauthn passwordless type/"+name, func(t *testing.T) {
expected := `{"credentials":[{"id":"THTndqZP5Mjvae1BFvJMaMfEMm7O7HE1ju+7PBaYA7Y=","added_at":"2022-12-16T14:11:55Z","public_key":"pQECAyYgASFYIMJLQhJxQRzhnKPTcPCUODOmxYDYo2obrm9bhp5lvSZ3IlggXjhZvJaPUqF9PXqZqTdWYPR7R+b2n/Wi+IxKKXsS4rU=","display_name":"test","authenticator":{"aaguid":"rc4AAjW8xgpkiwsl8fBVAw==","sign_count":0,"clone_warning":false},"is_passwordless":true,"attestation_type":"none"}],"user_handle":"Ef5JiMpMRwuzauWs/9J0gQ=="}`
i := createIdentity(map[identity.CredentialsType]string{identity.CredentialsTypeWebAuthn: expected})(t)
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/webauthn", http.StatusNoContent)
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/webauthn", http.StatusOK)
// Check that webauthn has not been deleted
res := get(t, ts, "/identities/"+i.ID.String(), http.StatusOK)
assert.EqualValues(t, i.ID.String(), res.Get("id").String(), "%s", res.Raw)
Expand Down Expand Up @@ -1364,7 +1364,7 @@ func TestHandler(t *testing.T) {
require.NoError(t, err)

i := createIdentity(map[identity.CredentialsType]string{identity.CredentialsTypeWebAuthn: string(message)})(t)
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/webauthn", http.StatusNoContent)
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/webauthn", http.StatusOK)
// Check that webauthn has not been deleted
res := get(t, ts, "/identities/"+i.ID.String(), http.StatusOK)
assert.EqualValues(t, i.ID.String(), res.Get("id").String(), "%s", res.Raw)
Expand Down Expand Up @@ -1419,7 +1419,7 @@ func TestHandler(t *testing.T) {
if tc.exist {
assert.True(t, resBefore.Get("credentials").Get(credName).Exists())
// Remove
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/"+credName, http.StatusNoContent)
remove(t, ts, "/identities/"+i.ID.String()+"/credentials/"+credName, http.StatusOK)
// Query back
resAfter := get(t, ts, "/identities/"+i.ID.String(), http.StatusOK)
assert.EqualValues(t, i.ID.String(), resAfter.Get("id").String(), "%s", resAfter.Raw)
Expand Down

0 comments on commit 0862ef2

Please sign in to comment.