Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion agent/common/issuerservice/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Metaform Systems, Inc. - initial API and implementation
* Matthias Buchhorn - accept 204 on a credential revocation
*
*/

Expand Down Expand Up @@ -198,7 +199,8 @@ func (i HttpApiClient) RevokeCredential(ctx context.Context, credentialID string
}
defer httpx.DrainAndClose(resp)

if resp.StatusCode != http.StatusOK {
// The IssuerService (EDC 1.0) answers a revocation with 204
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("failed to revoke credential with ID '%s' in issuer context '%s': received status code %d with message [%s]", credentialID, i.IssuerID, resp.StatusCode, httpx.ReadErrorBody(resp))
}
return nil
Expand Down
24 changes: 24 additions & 0 deletions agent/common/issuerservice/issuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Metaform Systems, Inc. - initial API and implementation
* Matthias Buchhorn - accept 204 on a credential revocation
*
*/

Expand Down Expand Up @@ -129,6 +130,29 @@ func TestHttpApiClient_RevokeCredential(t *testing.T) {
require.NoError(t, err)
}

func TestHttpApiClient_RevokeCredential_NoContent(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/v1/participants/test-issuer/credentials/test-credential-id/revoke" && r.Method == http.MethodPost {

@paullatzelsperger paullatzelsperger Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic string - please either use a variable for test-credential-id or a wildcard (cf TestHttpApiClient_CreateHolder_ApiReturnsError)

w.WriteHeader(http.StatusNoContent)
} else {
w.WriteHeader(http.StatusInternalServerError)
}
}))
defer server.Close()

tp := mocks.NewMockTokenProvider(t)
tp.On("GetToken", mock.Anything, ScopeCredentialsWrite, "test-issuer").Return("test token", nil)
client := HttpApiClient{
BaseURL: server.URL,
TokenProvider: tp,
IssuerID: "test-issuer",
HttpClient: &http.Client{},
}

err := client.RevokeCredential(t.Context(), "test-credential-id")
require.NoError(t, err, "the IssuerService answers a revocation with 204")
}

func TestHttpApiClient_RevokeCredential_ClientError(t *testing.T) {
template := "/v1/participants/.*/credentials/.*/revoke"
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading