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

Commit

Permalink
refactor: goal-code and web-redirect with underscore
Browse files Browse the repository at this point in the history
Following this DIDcomm V2 spec udpate:
decentralized-identity/didcomm-messaging#363
goal-code is now goal_code and web-redirect is now web_redirect.

Signed-off-by: Baha Shaaban <baha.shaaban@securekey.com>
  • Loading branch information
Baha Shaaban committed Apr 21, 2022
1 parent 7d95f17 commit deb50fd
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- WACI Presentation
- Credential Manifest support & minor improvements
- Aries RFCs / Interop
- Web-redirect support in issue-credential and present-proof protocols (V2 and V3)
- web_redirect support in issue-credential and present-proof protocols (V2 and V3)
- Media type profile support
- Various minor fixes
- Fixes and improvements to Crypto, KMS, VDR, Verifiable Credential, Storage, and other components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestOutOfBand_CreateInvitation(t *testing.T) {

mockResponse := `{"invitation":{"@id":"2429a5d3-c500-4647-9bb5-e34207bce406",
"@type":"https://didcomm.org/out-of-band/1.0/invitation","label":"label","goal":"goal",
"goal-code":"goal_code","service":["s1"],"protocols":["s1"]}}
"goal_code":"goal_code","service":["s1"],"protocols":["s1"]}}
`
fakeHandler := mockCommandRunner{data: []byte(mockResponse)}
controller.handlers[outofband.CreateInvitation] = fakeHandler.exec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestOutOfBandV2_CreateInvitation(t *testing.T) {

mockResponse := `{"invitation":{"@id":"2429a5d3-c500-4647-9bb5-e34207bce406",
"@type":"https://didcomm.org/out-of-band/2.0/invitation","label":"label","body":{
"goal":"goal","goal-code":"goal_code","accept":["didcomm/v2"]}}}
"goal":"goal","goal_code":"goal_code","accept":["didcomm/v2"]}}}
`
fakeHandler := mockCommandRunner{data: []byte(mockResponse)}
controller.handlers[outofbandv2.CreateInvitation] = fakeHandler.exec
Expand Down
4 changes: 2 additions & 2 deletions cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestOutOfBand_CreateInvitation(t *testing.T) {
reqData := `{"label":"label","goal":"goal","goal_code":"goal_code","service":["s1"],"protocols":["s1"]}`
mockResponse := `{"invitation":{"@id":"2429a5d3-c500-4647-9bb5-e34207bce406",
"@type":"https://didcomm.org/out-of-band/1.0/invitation","label":"label","goal":"goal",
"goal-code":"goal_code","service":["s1"],"protocols":["s1"]}}
"goal_code":"goal_code","service":["s1"],"protocols":["s1"]}}
`

controller.httpClient = &mockHTTPClient{
Expand All @@ -160,7 +160,7 @@ func TestOutOfBand_CreateRequest(t *testing.T) {
reqData := `{"label":"label","goal":"goal","goal_code":"goal_code","service":["s1"],
"attachments":[{"lastmod_time":"0001-01-01T00:00:00Z","data":{}}]}`
mockResponse := `{"invitation":{"@id":"26169718-f261-48f1-addd-67018977a89f",
"@type":"https://didcomm.org/out-of-band/1.0/invitation","label":"label","goal":"goal","goal-code":"goal_code",
"@type":"https://didcomm.org/out-of-band/1.0/invitation","label":"label","goal":"goal","goal_code":"goal_code",
"request~attach":[{"lastmod_time":"0001-01-01T00:00:00Z","data":{}}],"service":["s1"]}}`

controller.httpClient = &mockHTTPClient{
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/issuecredential/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
// web redirect decorator.
webRedirectDecorator = "~web-redirect"
webRedirectDecorator = "~web_redirect"
webRedirectStatusFAIL = "FAIL"
)

Expand Down Expand Up @@ -352,7 +352,7 @@ func RequestRedirect(url string) IssuerDeclineOptions {
}
}

// create web redirect properties to add ~web-redirect decorator.
// create web redirect properties to add ~web_redirect decorator.
func prepareRedirectProperties(status string, options ...IssuerDeclineOptions) issuecredential.Opt {
properties := map[string]interface{}{}

Expand Down
4 changes: 2 additions & 2 deletions pkg/client/presentproof/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type (

const (
// web redirect decorator.
webRedirectDecorator = "~web-redirect"
webRedirectDecorator = "~web_redirect"
webRedirectStatusOK = "OK"
webRedirectStatusFAIL = "FAIL"
)
Expand Down Expand Up @@ -262,7 +262,7 @@ func WithRequestPresentation(msg *RequestPresentation) presentproof.Opt {
return presentproof.WithRequestPresentation(msg)
}

// create web redirect properties to add ~web-redirect decorator.
// create web redirect properties to add ~web_redirect decorator.
func prepareRedirectProperties(redirect, status string) presentproof.Opt {
properties := map[string]interface{}{}

Expand Down
4 changes: 2 additions & 2 deletions pkg/didcomm/common/model/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ type Ack struct {
ID string `json:"@id,omitempty"`
Status string `json:"status,omitempty"`
Thread *decorator.Thread `json:"~thread,omitempty"`
WebRedirect interface{} `json:"~web-redirect,omitempty"`
WebRedirect interface{} `json:"~web_redirect,omitempty"`
}

// AckV2 acknowledgement struct.
type AckV2 struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
WebRedirect interface{} `json:"web-redirect,omitempty"`
WebRedirect interface{} `json:"web_redirect,omitempty"`
Body AckV2Body `json:"body,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/didcomm/common/model/problem_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ProblemReport struct {
Type string `json:"@type"`
ID string `json:"@id"`
Description Code `json:"description"`
WebRedirect interface{} `json:"~web-redirect,omitempty"`
WebRedirect interface{} `json:"~web_redirect,omitempty"`
}

// Code represents a problem report code.
Expand All @@ -33,5 +33,5 @@ type ProblemReportV2Body struct {
Comment string `json:"comment,omitempty"`
Args []string `json:"args,omitempty"`
EscalateTo string `json:"escalate_to,omitempty"`
WebRedirect interface{} `json:"~web-redirect,omitempty"`
WebRedirect interface{} `json:"~web_redirect,omitempty"`
}
2 changes: 1 addition & 1 deletion pkg/didcomm/protocol/introduce/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Proposal struct {
Thread *decorator.Thread `json:"~thread,omitempty"`
Timing *decorator.Timing `json:"~timing,omitempty"`
Goal string `json:"goal,omitempty"`
GoalCode string `json:"goal-code,omitempty"`
GoalCode string `json:"goal_code,omitempty"`
}

// To introducee descriptor keeps information about the introduction
Expand Down
4 changes: 2 additions & 2 deletions pkg/didcomm/protocol/issuecredential/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type IssueCredentialV2 struct { //nolint: golint
// CredentialsAttach is a slice of attachments containing the issued credentials.
CredentialsAttach []decorator.Attachment `json:"credentials~attach,omitempty"`
// WebRedirect contains optional web redirect info to be sent to holder for redirect.
WebRedirect *decorator.WebRedirect `json:"~web-redirect,omitempty"`
WebRedirect *decorator.WebRedirect `json:"~web_redirect,omitempty"`
}

// IssueCredentialV3 contains as attached payload the credentials being issued and is
Expand All @@ -164,7 +164,7 @@ type IssueCredentialV3 struct { //nolint: golint
ID string `json:"id,omitempty"`
Body IssueCredentialV3Body `json:"body,omitempty"`
// WebRedirect contains optional web redirect info to be sent to holder for redirect.
WebRedirect *decorator.WebRedirect `json:"web-redirect,omitempty"`
WebRedirect *decorator.WebRedirect `json:"web_redirect,omitempty"`
// Attachments is an array of attachments containing the presentation in the requested format(s).
// Accepted values for the format attribute of each attachment are provided in the per format Attachment
// registry immediately below.
Expand Down
4 changes: 2 additions & 2 deletions pkg/didcomm/protocol/issuecredential/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
commentText = "this is a comment"
goalCodeText = "goal-code"
goalCodeText = "goal_code"
messageIDText = "message-id-123"
)

Expand Down Expand Up @@ -47,7 +47,7 @@ func previewCredV3(t *testing.T) map[string]interface{} {
Type: CredentialPreviewMsgTypeV3,
ID: "bar-baz-qux",
Body: IssueCredentialV3Body{
GoalCode: "goal-code",
GoalCode: "goal_code",
ReplacementID: "blah-id",
Comment: commentText,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/didcomm/protocol/issuecredential/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,8 @@ func (s *Service) Accept(msgType string) bool {
// redirectInfo reads web redirect info decorator from given DIDComm Msg.
func redirectInfo(msg service.DIDCommMsg) map[string]interface{} {
var redirectInfo struct {
WebRedirectV2 map[string]interface{} `json:"~web-redirect,omitempty"`
WebRedirectV3 map[string]interface{} `json:"web-redirect,omitempty"`
WebRedirectV2 map[string]interface{} `json:"~web_redirect,omitempty"`
WebRedirectV3 map[string]interface{} `json:"web_redirect,omitempty"`
}

err := msg.Decode(&redirectInfo)
Expand Down
2 changes: 1 addition & 1 deletion pkg/didcomm/protocol/issuecredential/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
stateNameCredentialReceived = "credential-received"

// web redirect decorator V2.
webRedirect = "~web-redirect"
webRedirect = "~web_redirect"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/didcomm/protocol/outofbandv2/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ type Invitation struct {
// InvitationBody contains invitation's goal and accept headers.
type InvitationBody struct {
Goal string `json:"goal,omitempty"`
GoalCode string `json:"goal-code,omitempty"`
GoalCode string `json:"goal_code,omitempty"`
Accept []string `json:"accept,omitempty"`
}
4 changes: 2 additions & 2 deletions pkg/didcomm/protocol/presentproof/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const (
// error codes.
codeInternalError = "internal"
codeRejectedError = "rejected"
webRedirect = "~web-redirect"
webRedirectV2 = "web-redirect"
webRedirect = "~web_redirect"
webRedirectV2 = "web_redirect"
)

// state action for network call.
Expand Down
2 changes: 1 addition & 1 deletion pkg/wallet/invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type GenericInvitation struct {
From string `json:"from,omitempty"`
Label string `json:"label,omitempty"`
Goal string `json:"goal,omitempty"`
GoalCode string `json:"goal-code,omitempty"`
GoalCode string `json:"goal_code,omitempty"`
Services []interface{} `json:"services"`
Accept []string `json:"accept,omitempty"`
Protocols []string `json:"handshake_protocols,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion test/bdd/features/waci_issuance_didcomm_v1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: WACI Issuance (Go API, DIDComm V1 + Issue Credential V2)
And "Holder" creates public DID for did method "sidetree"
Then "Issuer" waits for public did to become available in sidetree for up to 10 seconds
And "Holder" waits for public did to become available in sidetree for up to 10 seconds
Then "Issuer" creates an out-of-band-v1 invitation with streamlined-vc goal-code
Then "Issuer" creates an out-of-band-v1 invitation with streamlined-vc goal_code
And "Issuer" sends the out-of-band-v1 invitation to "Holder" and they accept it
Then "Holder" sends proposal credential V2 to the "Issuer" (WACI, DIDComm V1)
And "Issuer" accepts a proposal V2 and sends an offer to the Holder (WACI, DIDComm V1)
Expand Down
2 changes: 1 addition & 1 deletion test/bdd/features/waci_issuance_didcomm_v2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: WACI Issuance (Go API, DIDComm V2 + Issue Credential V3)
And "Holder" creates public DID for did method "sidetree"
Then "Issuer" waits for public did to become available in sidetree for up to 10 seconds
And "Holder" waits for public did to become available in sidetree for up to 10 seconds
Then "Issuer" creates an out-of-band-v2 invitation with streamlined-vc goal-code
Then "Issuer" creates an out-of-band-v2 invitation with streamlined-vc goal_code
And "Issuer" sends the request to "Holder" and they accept it
Then "Holder" sends proposal credential V3 to the "Issuer" (WACI)
And "Issuer" accepts a proposal V3 and sends an offer to the Holder (WACI)
Expand Down
2 changes: 1 addition & 1 deletion test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (i *IssuanceSDKDIDCommV1Steps) SetContext(ctx *context.BDDContext) {
// RegisterSteps registers the BDD test steps on the suite.
// Note that VC proofs are not checked in this test suite.
func (i *IssuanceSDKDIDCommV1Steps) RegisterSteps(suite *godog.Suite) {
suite.Step(`^"([^"]*)" creates an out-of-band-v1 invitation with streamlined-vc goal-code$`,
suite.Step(`^"([^"]*)" creates an out-of-band-v1 invitation with streamlined-vc goal_code$`,
i.createOOBV1WithStreamlinedVCGoalCode)
suite.Step(`^"([^"]*)" sends the out-of-band-v1 invitation to "([^"]*)" and they accept it$`,
i.acceptOOBV1Invitation)
Expand Down
2 changes: 1 addition & 1 deletion test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (i *IssuanceSDKDIDCommV2Steps) SetContext(ctx *context.BDDContext) {
// RegisterSteps registers the BDD test steps on the suite.
// Note that VC proofs are not checked in this test suite.
func (i *IssuanceSDKDIDCommV2Steps) RegisterSteps(suite *godog.Suite) {
suite.Step(`^"([^"]*)" creates an out-of-band-v2 invitation with streamlined-vc goal-code$`,
suite.Step(`^"([^"]*)" creates an out-of-band-v2 invitation with streamlined-vc goal_code$`,
i.createOOBV2WithStreamlinedVCGoalCode)
suite.Step(`^"([^"]*)" sends the request to "([^"]*)" and they accept it$`, i.acceptOOBV2Invitation)
suite.Step(`^"([^"]*)" sends proposal credential V3 to the "([^"]*)" \(WACI\)$`, i.sendsProposalV3)
Expand Down

0 comments on commit deb50fd

Please sign in to comment.