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
21 changes: 21 additions & 0 deletions discovery/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,27 @@ func TestModule_Search(t *testing.T) {
actualJSON, _ := json.Marshal(results)
assert.JSONEq(t, string(expectedJSON), string(actualJSON))
})
t.Run("retracted presentations are not returned", func(t *testing.T) {
resetStore(t, storageEngine.GetSQLDatabase())
m, testContext := setupModule(t, storageEngine, func(module *Module) {
module.config.Client.RefreshInterval = 0
})
testContext.verifier.EXPECT().VerifyVP(gomock.Any(), true, true, nil).Times(2)

vpAliceRetract := createPresentationCustom(aliceDID, func(claims map[string]interface{}, vp *vc.VerifiablePresentation) {
vp.Type = append(vp.Type, retractionPresentationType)
claims["retract_jti"] = vpAlice.ID.String()
claims[jwt.AudienceKey] = []string{testServiceID}
})

require.NoError(t, m.Register(context.Background(), testServiceID, vpAlice))
require.NoError(t, m.Register(context.Background(), testServiceID, vpAliceRetract))

// Empty query: no credential-join filter, so retraction markers leak through.
results, err := m.Search(testServiceID, map[string]string{})
require.NoError(t, err)
assert.Empty(t, results, "retraction presentations must not be returned from Search")
})
t.Run("unknown service ID", func(t *testing.T) {
m, _ := setupModule(t, storageEngine)
_, err := m.Search("unknown", nil)
Expand Down
4 changes: 4 additions & 0 deletions discovery/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ func (s *sqlStore) search(serviceID string, query map[string]string, allowUnvali
if err != nil {
return nil, fmt.Errorf("failed to parse presentation '%s': %w", match.PresentationID, err)
}
// Retraction markers are stored on the timeline (for Get()) but must not surface in search results.
if presentation.IsType(retractionPresentationType) {
continue
}
results = append(results, *presentation)
}
return results, nil
Expand Down
Loading