Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix DIDDoc versions API response results and an infinite redirects in get DIDDoc versions API [DEV-2413] #131

Merged
merged 4 commits into from
Apr 4, 2023
Merged
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
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