Repository: TBD54566975/ssi-service
Pull request #333 (2023-03-20 18:08:07)

Adding functionality for soft deletion of dids
# Overview
Adding functionality for soft deletion of dids

# Description
This change adds a new endpoint: 
DEL - http://localhost:8080/v1/dids/:method/:id
When this is called with the correct did method and id it will flip the softDelete flag to true for the db entry.

A user can still get the did if they know the DID ID, 
GET - http://localhost:8080/v1/dids/:method/:id ✅ 

But when they get all dids this will not appear
GET - http://localhost:8080/v1/dids/:method ⚠️ 


The reason for this change is to facilitate a clean SSI-Service Admin UI but not leave any hanging VCs with unaccessible DIDS.



Patch:
diff --git a/pkg/server/router/credential.go b/pkg/server/router/credential.go
index 3b36bf6..639a64d 100644
--- a/pkg/server/router/credential.go
+++ b/pkg/server/router/credential.go
@@ -476,7 +476,7 @@ func (cr CredentialRouter) getCredentialsBySchema(ctx context.Context, schema st
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/credentials/{id} [delete]
@@ -494,5 +494,5 @@ func (cr CredentialRouter) DeleteCredential(ctx context.Context, w http.Response
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
diff --git a/pkg/server/router/did.go b/pkg/server/router/did.go
index 670505d..87eda44 100644
--- a/pkg/server/router/did.go
+++ b/pkg/server/router/did.go
@@ -222,6 +222,45 @@ type ResolveDIDResponse struct {
 	DIDDocumentMetadata *didsdk.DIDDocumentMetadata   `json:"didDocumentMetadata,omitempty"`
 }
 
+// SoftDeleteDIDByMethod godoc
+// @Description When this is called with the correct did method and id it will flip the softDelete flag to true for the db entry.
+// @Description A user can still get the did if they know the DID ID, and the did keys will still exist, but this did will not show up in the GetDIDsByMethod call
+// @Description This facilitates a clean SSI-Service Admin UI but not leave any hanging VCs with inaccessible hanging DIDs.
+// @Summary     Soft Delete DID
+// @Description Soft Deletes DID by method
+// @Tags        DecentralizedIdentityAPI
+// @Accept      json
+// @Produce     json
+// @Param       method  path     string                   true "Method"
+// @Param       id      path     string                   true "ID"
+// @Success     204     {string} string "No Content"
+// @Failure     400     {string} string "Bad request"
+// @Failure     500     {string} string "Internal server error"
+// @Router      /v1/dids/{method}/{id} [delete]
+func (dr DIDRouter) SoftDeleteDIDByMethod(ctx context.Context, w http.ResponseWriter, _ *http.Request) error {
+	method := framework.GetParam(ctx, MethodParam)
+	if method == nil {
+		errMsg := "soft delete DID by method request missing method parameter"
+		logrus.Error(errMsg)
+		return framework.NewRequestErrorMsg(errMsg, http.StatusBadRequest)
+	}
+	id := framework.GetParam(ctx, IDParam)
+	if id == nil {
+		errMsg := fmt.Sprintf("soft delete DID request missing id parameter for method: %s", *method)
+		logrus.Error(errMsg)
+		return framework.NewRequestErrorMsg(errMsg, http.StatusBadRequest)
+	}
+
+	deleteDIDRequest := did.DeleteDIDRequest{Method: didsdk.Method(*method), ID: *id}
+	if err := dr.service.SoftDeleteDIDByMethod(ctx, deleteDIDRequest); err != nil {
+		errMsg := fmt.Sprintf("could not soft delete DID with id: %s", *id)
+		logrus.WithError(err).Error(errMsg)
+		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
+	}
+
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
+}
+
 // ResolveDID godoc
 //
 // @Summary     Resolve a DID
diff --git a/pkg/server/router/issuance.go b/pkg/server/router/issuance.go
index 67342b9..16f21cc 100644
--- a/pkg/server/router/issuance.go
+++ b/pkg/server/router/issuance.go
@@ -96,7 +96,7 @@ func (ir IssuanceRouter) CreateIssuanceTemplate(ctx context.Context, w http.Resp
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/issuancetemplates/{id} [delete]
@@ -112,7 +112,7 @@ func (ir IssuanceRouter) DeleteIssuanceTemplate(ctx context.Context, w http.Resp
 			util.LoggingErrorMsgf(err, "could not delete issuance template with id: %s", *id), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
 
 type ListIssuanceTemplatesResponse struct {
diff --git a/pkg/server/router/manifest.go b/pkg/server/router/manifest.go
index a93ed23..a2a58fb 100644
--- a/pkg/server/router/manifest.go
+++ b/pkg/server/router/manifest.go
@@ -194,7 +194,7 @@ func (mr ManifestRouter) GetManifests(ctx context.Context, w http.ResponseWriter
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/manifests/{id} [delete]
@@ -212,7 +212,7 @@ func (mr ManifestRouter) DeleteManifest(ctx context.Context, w http.ResponseWrit
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
 
 type SubmitApplicationRequest struct {
@@ -407,7 +407,7 @@ func (mr ManifestRouter) GetApplications(ctx context.Context, w http.ResponseWri
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/manifests/applications/{id} [delete]
@@ -425,7 +425,7 @@ func (mr ManifestRouter) DeleteApplication(ctx context.Context, w http.ResponseW
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
 
 type GetResponseResponse struct {
diff --git a/pkg/server/router/presentation.go b/pkg/server/router/presentation.go
index 6d1db07..f2f67d3 100644
--- a/pkg/server/router/presentation.go
+++ b/pkg/server/router/presentation.go
@@ -216,7 +216,7 @@ func (pr PresentationRouter) ListDefinitions(ctx context.Context, w http.Respons
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/presentation/definition/{id} [delete]
@@ -234,7 +234,7 @@ func (pr PresentationRouter) DeleteDefinition(ctx context.Context, w http.Respon
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
 
 type CreateSubmissionRequest struct {
diff --git a/pkg/server/router/schema.go b/pkg/server/router/schema.go
index f631699..c7c9ec5 100644
--- a/pkg/server/router/schema.go
+++ b/pkg/server/router/schema.go
@@ -197,7 +197,7 @@ func (sr SchemaRouter) VerifySchema(ctx context.Context, w http.ResponseWriter,
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/schemas/{id} [delete]
@@ -215,5 +215,5 @@ func (sr SchemaRouter) DeleteSchema(ctx context.Context, w http.ResponseWriter,
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
diff --git a/pkg/server/router/webhook.go b/pkg/server/router/webhook.go
index af751ee..603846d 100644
--- a/pkg/server/router/webhook.go
+++ b/pkg/server/router/webhook.go
@@ -156,7 +156,7 @@ func (wr WebhookRouter) GetWebhooks(ctx context.Context, w http.ResponseWriter,
 // @Accept      json
 // @Produce     json
 // @Param       id  path     string true "ID"
-// @Success     200 {string} string "OK"
+// @Success     204 {string} string "No Content"
 // @Failure     400 {string} string "Bad request"
 // @Failure     500 {string} string "Internal server error"
 // @Router      /v1/webhooks/{id} [delete]
@@ -174,7 +174,7 @@ func (wr WebhookRouter) DeleteWebhook(ctx context.Context, w http.ResponseWriter
 		return framework.NewRequestError(errors.Wrap(err, errMsg), http.StatusInternalServerError)
 	}
 
-	return framework.Respond(ctx, w, nil, http.StatusOK)
+	return framework.Respond(ctx, w, nil, http.StatusNoContent)
 }
 
 // GetSupportedNouns godoc
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 95e935a..302a70b 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -134,6 +134,7 @@ func (s *SSIServer) DecentralizedIdentityAPI(service svcframework.Service) (err
 	s.Handle(http.MethodPut, path.Join(handlerPath, "/:method"), didRouter.CreateDIDByMethod)
 	s.Handle(http.MethodGet, path.Join(handlerPath, "/:method"), didRouter.GetDIDsByMethod)
 	s.Handle(http.MethodGet, path.Join(handlerPath, "/:method/:id"), didRouter.GetDIDByMethod)
+	s.Handle(http.MethodDelete, path.Join(handlerPath, "/:method/:id"), didRouter.SoftDeleteDIDByMethod)
 
 	s.Handle(http.MethodGet, path.Join(path.Join(handlerPath, ResolverPrefix), "/:id"), didRouter.ResolveDID)
 	return
diff --git a/pkg/service/did/key.go b/pkg/service/did/key.go
index 91702de..164da8c 100644
--- a/pkg/service/did/key.go
+++ b/pkg/service/did/key.go
@@ -41,8 +41,9 @@ func (h *keyDIDHandler) CreateDID(ctx context.Context, request CreateDIDRequest)
 	// store metadata in DID storage
 	id := doc.String()
 	storedDID := StoredDID{
-		ID:  id,
-		DID: *expanded,
+		ID:          id,
+		DID:         *expanded,
+		SoftDeleted: false,
 	}
 	if err = h.storage.StoreDID(ctx, storedDID); err != nil {
 		return nil, errors.Wrap(err, "could not store did:key value")
@@ -99,7 +100,26 @@ func (h *keyDIDHandler) GetDIDs(ctx context.Context, method did.Method) (*GetDID
 	}
 	dids := make([]did.DIDDocument, 0, len(gotDIDs))
 	for _, gotDID := range gotDIDs {
-		dids = append(dids, gotDID.DID)
+		if !gotDID.SoftDeleted {
+			dids = append(dids, gotDID.DID)
+		}
 	}
 	return &GetDIDsResponse{DIDs: dids}, nil
 }
+
+func (h *keyDIDHandler) SoftDeleteDID(ctx context.Context, request DeleteDIDRequest) error {
+	logrus.Debugf("soft deleting DID: %+v", request)
+
+	id := request.ID
+	gotStoredDID, err := h.storage.GetDID(ctx, id)
+	if err != nil {
+		return fmt.Errorf("error getting DID: %s", id)
+	}
+	if gotStoredDID == nil {
+		return fmt.Errorf("did with id<%s> could not be found", id)
+	}
+
+	gotStoredDID.SoftDeleted = true
+
+	return h.storage.StoreDID(ctx, *gotStoredDID)
+}
diff --git a/pkg/service/did/model.go b/pkg/service/did/model.go
index 10736e2..0389305 100644
--- a/pkg/service/did/model.go
+++ b/pkg/service/did/model.go
@@ -51,3 +51,8 @@ type GetDIDsRequest struct {
 type GetDIDsResponse struct {
 	DIDs []didsdk.DIDDocument `json:"dids"`
 }
+
+type DeleteDIDRequest struct {
+	Method didsdk.Method `json:"method" validate:"required"`
+	ID     string        `json:"id" validate:"required"`
+}
diff --git a/pkg/service/did/service.go b/pkg/service/did/service.go
index 33311fe..3305b15 100644
--- a/pkg/service/did/service.go
+++ b/pkg/service/did/service.go
@@ -117,6 +117,7 @@ type MethodHandler interface {
 	CreateDID(ctx context.Context, request CreateDIDRequest) (*CreateDIDResponse, error)
 	GetDID(ctx context.Context, request GetDIDRequest) (*GetDIDResponse, error)
 	GetDIDs(ctx context.Context, method didsdk.Method) (*GetDIDsResponse, error)
+	SoftDeleteDID(ctx context.Context, request DeleteDIDRequest) error
 }
 
 func (s *Service) instantiateHandlerForMethod(method didsdk.Method) error {
@@ -192,6 +193,14 @@ func (s *Service) GetDIDsByMethod(ctx context.Context, request GetDIDsRequest) (
 	return handler.GetDIDs(ctx, method)
 }
 
+func (s *Service) SoftDeleteDIDByMethod(ctx context.Context, request DeleteDIDRequest) error {
+	handler, err := s.getHandler(request.Method)
+	if err != nil {
+		return util.LoggingErrorMsgf(err, "could not get handler for method<%s>", request.Method)
+	}
+	return handler.SoftDeleteDID(ctx, request)
+}
+
 func (s *Service) getHandler(method didsdk.Method) (MethodHandler, error) {
 	handler, ok := s.handlers[method]
 	if !ok {
diff --git a/pkg/service/did/storage.go b/pkg/service/did/storage.go
index 52b5b66..1c1efa0 100644
--- a/pkg/service/did/storage.go
+++ b/pkg/service/did/storage.go
@@ -27,8 +27,9 @@ var (
 )
 
 type StoredDID struct {
-	ID  string          `json:"id"`
-	DID did.DIDDocument `json:"did"`
+	ID          string          `json:"id"`
+	DID         did.DIDDocument `json:"did"`
+	SoftDeleted bool            `json:"softDeleted"`
 }
 
 type Storage struct {
diff --git a/pkg/service/did/web.go b/pkg/service/did/web.go
index 033e680..d2baa87 100644
--- a/pkg/service/did/web.go
+++ b/pkg/service/did/web.go
@@ -53,8 +53,9 @@ func (h *webDIDHandler) CreateDID(ctx context.Context, request CreateDIDRequest)
 	// store metadata in DID storage
 	id := didWeb.String()
 	storedDID := StoredDID{
-		ID:  id,
-		DID: *doc,
+		ID:          id,
+		DID:         *doc,
+		SoftDeleted: false,
 	}
 	if err = h.storage.StoreDID(ctx, storedDID); err != nil {
 		return nil, errors.Wrap(err, "could not store did:web value")
@@ -111,7 +112,26 @@ func (h *webDIDHandler) GetDIDs(ctx context.Context, method did.Method) (*GetDID
 	}
 	dids := make([]did.DIDDocument, 0, len(gotDIDs))
 	for _, gotDID := range gotDIDs {
-		dids = append(dids, gotDID.DID)
+		if !gotDID.SoftDeleted {
+			dids = append(dids, gotDID.DID)
+		}
 	}
 	return &GetDIDsResponse{DIDs: dids}, nil
 }
+
+func (h *webDIDHandler) SoftDeleteDID(ctx context.Context, request DeleteDIDRequest) error {
+	logrus.Debugf("soft deleting DID: %+v", request)
+
+	id := request.ID
+	gotStoredDID, err := h.storage.GetDID(ctx, id)
+	if err != nil {
+		return fmt.Errorf("error getting DID: %s", id)
+	}
+	if gotStoredDID == nil {
+		return fmt.Errorf("did with id<%s> could not be found", id)
+	}
+
+	gotStoredDID.SoftDeleted = true
+
+	return h.storage.StoreDID(ctx, *gotStoredDID)
+}


Test patch:
diff --git a/pkg/server/router/did_test.go b/pkg/server/router/did_test.go
index c182df1..5e053c8 100644
--- a/pkg/server/router/did_test.go
+++ b/pkg/server/router/did_test.go
@@ -95,6 +95,19 @@ func TestDIDRouter(t *testing.T) {
 			}
 		}
 		assert.Len(tt, knownDIDs, 0)
+
+		// delete dids
+		err = didService.SoftDeleteDIDByMethod(context.Background(), did.DeleteDIDRequest{Method: didsdk.KeyMethod, ID: createDIDResponse.DID.ID})
+		assert.NoError(tt, err)
+
+		err = didService.SoftDeleteDIDByMethod(context.Background(), did.DeleteDIDRequest{Method: didsdk.KeyMethod, ID: createDIDResponse2.DID.ID})
+		assert.NoError(tt, err)
+
+		// get all DIDs back
+		getDIDsResponse, err = didService.GetDIDsByMethod(context.Background(), did.GetDIDsRequest{Method: didsdk.KeyMethod})
+		assert.NoError(tt, err)
+		assert.NotEmpty(tt, getDIDsResponse)
+		assert.Len(tt, getDIDsResponse.DIDs, 0)
 	})
 
 	t.Run("DID Web Service Test", func(tt *testing.T) {
@@ -165,5 +178,19 @@ func TestDIDRouter(t *testing.T) {
 			}
 		}
 		assert.Len(tt, knownDIDs, 0)
+
+		// delete dids
+		err = didService.SoftDeleteDIDByMethod(context.Background(), did.DeleteDIDRequest{Method: didsdk.WebMethod, ID: createDIDResponse.DID.ID})
+		assert.NoError(tt, err)
+
+		err = didService.SoftDeleteDIDByMethod(context.Background(), did.DeleteDIDRequest{Method: didsdk.WebMethod, ID: createDIDResponse2.DID.ID})
+		assert.NoError(tt, err)
+
+		// get all DIDs back
+		getDIDsResponse, err = didService.GetDIDsByMethod(context.Background(), did.GetDIDsRequest{Method: didsdk.WebMethod})
+		assert.NoError(tt, err)
+		assert.NotEmpty(tt, getDIDsResponse)
+		assert.Len(tt, getDIDsResponse.DIDs, 0)
 	})
+
 }
diff --git a/pkg/server/server_did_test.go b/pkg/server/server_did_test.go
index 72d4244..9327d29 100644
--- a/pkg/server/server_did_test.go
+++ b/pkg/server/server_did_test.go
@@ -156,6 +156,106 @@ func TestDIDAPI(t *testing.T) {
 		assert.Equal(tt, createdID, resp.DID.ID)
 	})
 
+	t.Run("Test Soft Delete DID By Method", func(tt *testing.T) {
+		bolt := setupTestDB(tt)
+		require.NotNil(tt, bolt)
+
+		_, keyStore := testKeyStore(tt, bolt)
+		didService := testDIDRouter(tt, bolt, keyStore)
+
+		// soft delete DID by method
+		req := httptest.NewRequest(http.MethodDelete, "https://ssi-service.com/v1/dids/bad/worse", nil)
+		w := httptest.NewRecorder()
+
+		// bad params
+		badParams := map[string]string{
+			"method": "bad",
+			"id":     "worse",
+		}
+
+		err := didService.SoftDeleteDIDByMethod(newRequestContextWithParams(badParams), w, req)
+		assert.Error(tt, err)
+		assert.Contains(tt, err.Error(), "could not soft delete DID")
+
+		// good method, bad id
+		badParams1 := map[string]string{
+			"method": "key",
+			"id":     "worse",
+		}
+		err = didService.SoftDeleteDIDByMethod(newRequestContextWithParams(badParams1), w, req)
+		assert.Error(tt, err)
+		assert.Contains(tt, err.Error(), "could not soft delete DID with id: worse: error getting DID: worse")
+
+		// store a DID
+		createDIDRequest := router.CreateDIDByMethodRequest{KeyType: crypto.Ed25519}
+		requestReader := newRequestValue(tt, createDIDRequest)
+		params := map[string]string{"method": "key"}
+		req = httptest.NewRequest(http.MethodPut, "https://ssi-service.com/v1/dids/key", requestReader)
+
+		err = didService.CreateDIDByMethod(newRequestContextWithParams(params), w, req)
+		assert.NoError(tt, err)
+
+		var createdDID router.CreateDIDByMethodResponse
+		err = json.NewDecoder(w.Body).Decode(&createdDID)
+		assert.NoError(tt, err)
+
+		// get all dids for method
+		req = httptest.NewRequest(http.MethodGet, "https://ssi-service.com/v1/dids/key", requestReader)
+		err = didService.GetDIDsByMethod(newRequestContextWithParams(params), w, req)
+		assert.NoError(tt, err)
+
+		var gotDIDsResponse router.GetDIDsByMethodResponse
+		err = json.NewDecoder(w.Body).Decode(&gotDIDsResponse)
+		assert.NoError(tt, err)
+		assert.Len(tt, gotDIDsResponse.DIDs, 1)
+
+		// get it back
+		createdID := createdDID.DID.ID
+		getDIDPath := fmt.Sprintf("https://ssi-service.com/v1/dids/key/%s", createdID)
+		req = httptest.NewRequest(http.MethodGet, getDIDPath, nil)
+
+		// good params
+		goodParams := map[string]string{
+			"method": "key",
+			"id":     createdID,
+		}
+		err = didService.GetDIDByMethod(newRequestContextWithParams(goodParams), w, req)
+		assert.NoError(tt, err)
+
+		var resp router.GetDIDByMethodResponse
+		err = json.NewDecoder(w.Body).Decode(&resp)
+		assert.NoError(tt, err)
+		assert.Equal(tt, createdID, resp.DID.ID)
+
+		// delete it
+		deleteDIDPath := fmt.Sprintf("https://ssi-service.com/v1/dids/key/%s", createdID)
+		req = httptest.NewRequest(http.MethodDelete, deleteDIDPath, nil)
+
+		err = didService.SoftDeleteDIDByMethod(newRequestContextWithParams(goodParams), w, req)
+		assert.NoError(tt, err)
+
+		// get it back
+		req = httptest.NewRequest(http.MethodGet, getDIDPath, nil)
+
+		err = didService.GetDIDByMethod(newRequestContextWithParams(goodParams), w, req)
+		assert.NoError(tt, err)
+
+		var deletedGetResp router.GetDIDByMethodResponse
+		err = json.NewDecoder(w.Body).Decode(&deletedGetResp)
+		assert.NoError(tt, err)
+		assert.Equal(tt, createdID, deletedGetResp.DID.ID)
+
+		// get all dids for method
+		req = httptest.NewRequest(http.MethodGet, "https://ssi-service.com/v1/dids/key", requestReader)
+		err = didService.GetDIDsByMethod(newRequestContextWithParams(params), w, req)
+		assert.NoError(tt, err)
+
+		var gotDIDsResponseAfterDelete router.GetDIDsByMethodResponse
+		err = json.NewDecoder(w.Body).Decode(&gotDIDsResponseAfterDelete)
+		assert.NoError(tt, err)
+		assert.Len(tt, gotDIDsResponseAfterDelete.DIDs, 0)
+	})
+
 	t.Run("Test Get DIDs By Method", func(tt *testing.T) {
 		bolt := setupTestDB(tt)
 		require.NotNil(tt, bolt)
@@ -218,7 +318,6 @@ func TestDIDAPI(t *testing.T) {
 		w.Flush()
 
 		// get all dids for method
-
 		req = httptest.NewRequest(http.MethodGet, "https://ssi-service.com/v1/dids/key", requestReader)
 		err = didService.GetDIDsByMethod(newRequestContextWithParams(params), w, req)
 		assert.NoError(tt, err)