Skip to content

Commit

Permalink
fix: Fix DIDDoc versions API response results and an infinite redirec…
Browse files Browse the repository at this point in the history
…ts in get DIDDoc versions API [DEV-2413] (#131)

* Fix problem that returns response from APIs:
- get DIDDoc version metadata;
- get DIDDoc versions.

* Update an incorrect integration tests for getting
DIDDoc versions.

* Fix problem with an infinity redirects in get
DIDDoc Versions API.
  • Loading branch information
abdulla-ashurov authored Apr 4, 2023
1 parent 56a2e98 commit addd28d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion services/diddoc/diddoc_all_version_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package diddoc
import (
"net/http"

"github.com/cheqd/did-resolver/migrations"
"github.com/cheqd/did-resolver/services"
"github.com/cheqd/did-resolver/types"
)
Expand All @@ -21,7 +22,9 @@ func (dd *DIDDocAllVersionMetadataRequestService) SpecificPrepare(c services.Res
}

func (dd DIDDocAllVersionMetadataRequestService) Redirect(c services.ResolverContext) error {
path := types.RESOLVER_PATH + dd.Did + types.DID_VERSIONS_PATH
migratedDid := migrations.MigrateDID(dd.Did)

path := types.RESOLVER_PATH + migratedDid + types.DID_VERSIONS_PATH
return c.Redirect(http.StatusMovedPermanently, path)
}

Expand All @@ -32,6 +35,7 @@ func (dd *DIDDocAllVersionMetadataRequestService) SpecificValidation(c services.
func (dd *DIDDocAllVersionMetadataRequestService) Query(c services.ResolverContext) error {
result, err := c.DidDocService.GetAllDidDocVersionsMetadata(dd.Did, dd.RequestedContentType)
if err != nil {
err.IsDereferencing = dd.IsDereferencing
return err
}
dd.Result = result
Expand Down
1 change: 1 addition & 0 deletions services/diddoc/diddoc_version_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (dd *DIDDocVersionMetadataRequestService) SpecificValidation(c services.Res
func (dd *DIDDocVersionMetadataRequestService) Query(c services.ResolverContext) error {
result, err := c.DidDocService.GetDIDDocVersionsMetadata(dd.Did, dd.Version, dd.RequestedContentType)
if err != nil {
err.IsDereferencing = dd.IsDereferencing
return err
}
dd.Result = result
Expand Down
3 changes: 1 addition & 2 deletions tests/pytest/test_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
r"didDocument\": null,(.*?)\"didDocumentMetadata\": \{\}"),
(helpers.TESTNET_DID_VERSIONS,
r"\"dereferencingMetadata(.*?)\"contentStream\":(.*?)\"contentMetadata\":(.*?)"),
(helpers.FAKE_TESTNET_DID_VERSIONS, r"\"didResolutionMetadata(.*?)\"error\": \"notFound\"(.*?)"
r"didDocument\": null,(.*?)\"didDocumentMetadata\": \{\}"),
(helpers.FAKE_TESTNET_DID_VERSIONS, r"\"dereferencingMetadata(.*?)\"contentStream\":(.*?)\"contentMetadata\":(.*?)"),
(helpers.TESTNET_DID_VERSION_METADATA, r"\"dereferencingMetadata(.*?)\"contentStream\":(.*?)linkedResourceMetadata(.*?)"
"resourceCollectionId(.*?)\"contentMetadata\":(.*?)"),
]
Expand Down

0 comments on commit addd28d

Please sign in to comment.