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

feat: Add BDD test for legacy-connection protocol #3353

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
5 changes: 0 additions & 5 deletions pkg/didcomm/protocol/legacyconnection/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"

"github.com/google/uuid"

Expand Down Expand Up @@ -720,10 +719,6 @@ func (s *Service) requestMsgRecord(msg service.DIDCommMsg, ctx service.DIDCommCo
DIDCommVersion: service.V1,
}

if !strings.HasPrefix(connRecord.TheirDID, "did") {
connRecord.TheirDID = "did:peer:" + connRecord.TheirDID
}

if err := s.connectionRecorder.SaveConnectionRecord(connRecord); err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/didcomm/protocol/legacyconnection/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ func (ctx *context) handleInboundRequest(request *Request, options *options,
connRec.MyDID = responseDidDoc.ID
connRec.TheirDID = request.Connection.DID
connRec.TheirLabel = request.Label
connRec.RecipientKeys = destination.RecipientKeys

if len(responseDidDoc.Service) > 0 {
connRec.RecipientKeys = responseDidDoc.Service[0].RecipientKeys
}

accept, err := destination.ServiceEndpoint.Accept()
if err != nil {
Expand Down Expand Up @@ -605,7 +608,7 @@ func (ctx *context) getMyDIDDoc(pubDID string, routerConnections []string, servi
}

func (ctx *context) addRouterKeys(doc *did.Doc, routerConnections []string) error {
svc, ok := did.LookupService(doc, didCommServiceType)
svc, ok := did.LookupService(doc, legacyDIDCommServiceType)
if ok {
for _, recKey := range svc.RecipientKeys {
for _, connID := range routerConnections {
Expand Down
8 changes: 5 additions & 3 deletions pkg/didcomm/protocol/legacyconnection/states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,10 @@ func TestGetDIDDocAndConnection(t *testing.T) {
require.NoError(t, err)
customKMS := newKMS(t, mockstorage.NewMockStoreProvider())
ctx := context{
kms: customKMS,
vdRegistry: &mockvdr.MockVDRegistry{CreateValue: mockdiddoc.GetMockDIDDoc(t, false)},
kms: customKMS,
vdRegistry: &mockvdr.MockVDRegistry{
CreateValue: mockdiddoc.GetLegacyInteropMockDIDDoc(t, "1234567abcdefg", []byte("key")),
},
connectionRecorder: connRec,
routeSvc: &mockroute.MockMediatorSvc{
Connections: []string{"xyz"},
Expand All @@ -1225,7 +1227,7 @@ func TestGetDIDDocAndConnection(t *testing.T) {
keyType: kms.ED25519Type,
keyAgreementType: kms.X25519ECDHKWType,
}
didDoc, err := ctx.getMyDIDDoc("", []string{"xyz"}, didCommServiceType)
didDoc, err := ctx.getMyDIDDoc("", []string{"xyz"}, legacyDIDCommServiceType)
require.Error(t, err)
require.Contains(t, err.Error(), "did doc - add key to the router")
require.Nil(t, didDoc)
Expand Down
2 changes: 2 additions & 0 deletions test/bdd/bddtests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/issuecredential"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/jwt"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/ld"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/legacyconnection"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/mediator"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/messaging"
"github.com/hyperledger/aries-framework-go/test/bdd/pkg/outofband"
Expand Down Expand Up @@ -219,5 +220,6 @@ func features() []feature {
waci.NewIssuanceDIDCommV1SDKSteps(),
waci.NewIssuanceDIDCommV2SDKSteps(),
walletjsonld.NewSDKSteps(),
legacyconnection.NewLegacyConnectionControllerSteps(),
}
}
25 changes: 25 additions & 0 deletions test/bdd/features/legacyconnection_e2e_controller.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright Avast Software. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Reference : https://github.com/hyperledger/aries-rfcs/tree/main/features/0160-connection-protocol

@all
@controller
@legacyconnection_e2e_controller
Feature: Establishing DIDComm V1 using Connection RFC-0160 protocol between the agents using controller API

Scenario: legacy connection e2e flow using controller api
Given "Alice" agent is running on "localhost" port "8081" with controller "https://localhost:8082"
And "Bob" agent is running on "localhost" port "9081" with controller "https://localhost:9082"

When "Alice" creates legacy invitation through controller with label "alice-agent"
And "Bob" receives legacy invitation from "Alice" through controller
And "Bob" approves connection invitation through controller
And "Alice" approves connection request through controller
And "Alice" waits for legacy post state event "completed" to web notifier
And "Bob" waits for legacy post state event "completed" to web notifier

Then "Alice" retrieves connection record through controller and validates that legacy connection state is "completed"
And "Bob" retrieves connection record through controller and validates that legacy connection state is "completed"
Loading