Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
fix: Longform VDR method should not include did prefix (#301)
Browse files Browse the repository at this point in the history
Longform VDR method should not include did prefix

Closes #300

Signed-off-by: Sandra Vrtikapa <[email protected]>

Signed-off-by: Sandra Vrtikapa <[email protected]>
  • Loading branch information
sandrask authored Nov 9, 2022
1 parent ec7f44f commit f28b04b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions component/vdr/longform/vdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
RecoveryPublicKeyOpt = "recoveryPublicKey"

sha2_256 = 18
defaultDIDMethod = "did:ion"
defaultDIDMethod = "ion"
)

type sidetreeClient interface {
Expand Down Expand Up @@ -76,7 +76,7 @@ func New(opts ...Option) (*VDR, error) {

var err error

v.sidetreeDocHandler, err = dochandler.New(v.method)
v.sidetreeDocHandler, err = dochandler.New(fmt.Sprintf("did:%s", v.method))
if err != nil {
return nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions component/vdr/longform/vdr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestVDRI_Accept(t *testing.T) {
t.Run("test return false", func(t *testing.T) {
v, err := New()
require.NoError(t, err)
require.False(t, v.Accept("did:different"))
require.False(t, v.Accept("different"))
})
}

Expand All @@ -67,10 +67,10 @@ func TestVDRI_Options(t *testing.T) {
t.Run("test success", func(t *testing.T) {
docLoader := createTestDocLoader(t)

v, err := New(WithDIDMethod("did:different"), WithDocumentLoader(docLoader))
v, err := New(WithDIDMethod("different"), WithDocumentLoader(docLoader))
require.NoError(t, err)
require.False(t, v.Accept(defaultDIDMethod))
require.True(t, v.Accept("did:different"))
require.True(t, v.Accept("different"))

err = v.Close()
require.NoError(t, err)
Expand All @@ -82,7 +82,7 @@ func TestVDRI_Read(t *testing.T) {
v, err := New()
require.NoError(t, err)

longFormDID := fmt.Sprintf("%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)
longFormDID := fmt.Sprintf("did:%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)

docResolution, err := v.Read(longFormDID)
require.NoError(t, err)
Expand All @@ -104,7 +104,7 @@ func TestVDRI_Read(t *testing.T) {
require.Equal(t, 1, len(didDoc.CapabilityDelegation))
require.Equal(t, 1, len(didDoc.KeyAgreement))

require.Equal(t, docResolution.DocumentMetadata.EquivalentID[0], fmt.Sprintf("%s:%s", defaultDIDMethod, didSuffix))
require.Equal(t, docResolution.DocumentMetadata.EquivalentID[0], fmt.Sprintf("did:%s:%s", defaultDIDMethod, didSuffix))
})

t.Run("test sidetree document handler error", func(t *testing.T) {
Expand All @@ -113,7 +113,7 @@ func TestVDRI_Read(t *testing.T) {

v.sidetreeDocHandler = &mockDocHandler{Err: fmt.Errorf("document handler error")}

longFormDID := fmt.Sprintf("%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)
longFormDID := fmt.Sprintf("did:%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)

docResolution, err := v.Read(longFormDID)
require.Error(t, err)
Expand All @@ -127,7 +127,7 @@ func TestVDRI_Read(t *testing.T) {

v.sidetreeDocHandler = &mockDocHandler{ResolutionResult: &document.ResolutionResult{}}

longFormDID := fmt.Sprintf("%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)
longFormDID := fmt.Sprintf("did:%s:%s:%s", defaultDIDMethod, didSuffix, requestJCS)

docResolution, err := v.Read(longFormDID)
require.Error(t, err)
Expand Down

0 comments on commit f28b04b

Please sign in to comment.