From deb50fd4cb9753e4562db2ba1d24b978a707ebda Mon Sep 17 00:00:00 2001 From: Baha Shaaban Date: Thu, 21 Apr 2022 13:14:26 -0400 Subject: [PATCH] refactor: goal-code and web-redirect with underscore Following this DIDcomm V2 spec udpate: https://github.com/decentralized-identity/didcomm-messaging/pull/363 goal-code is now goal_code and web-redirect is now web_redirect. Signed-off-by: Baha Shaaban --- CHANGELOG.md | 2 +- cmd/aries-agent-mobile/pkg/wrappers/command/outofband_test.go | 2 +- .../pkg/wrappers/command/outofbandv2_test.go | 2 +- cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go | 4 ++-- pkg/client/issuecredential/client.go | 4 ++-- pkg/client/presentproof/client.go | 4 ++-- pkg/didcomm/common/model/ack.go | 4 ++-- pkg/didcomm/common/model/problem_report.go | 4 ++-- pkg/didcomm/protocol/introduce/models.go | 2 +- pkg/didcomm/protocol/issuecredential/models.go | 4 ++-- pkg/didcomm/protocol/issuecredential/params_test.go | 4 ++-- pkg/didcomm/protocol/issuecredential/service.go | 4 ++-- pkg/didcomm/protocol/issuecredential/states.go | 2 +- pkg/didcomm/protocol/outofbandv2/models.go | 2 +- pkg/didcomm/protocol/presentproof/states.go | 4 ++-- pkg/wallet/invitation.go | 2 +- test/bdd/features/waci_issuance_didcomm_v1.feature | 2 +- test/bdd/features/waci_issuance_didcomm_v2.feature | 2 +- test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go | 2 +- test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go | 2 +- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7e95e8a2..8a5bcf338e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/aries-agent-mobile/pkg/wrappers/command/outofband_test.go b/cmd/aries-agent-mobile/pkg/wrappers/command/outofband_test.go index c063d22a98..080fe2eb93 100644 --- a/cmd/aries-agent-mobile/pkg/wrappers/command/outofband_test.go +++ b/cmd/aries-agent-mobile/pkg/wrappers/command/outofband_test.go @@ -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 diff --git a/cmd/aries-agent-mobile/pkg/wrappers/command/outofbandv2_test.go b/cmd/aries-agent-mobile/pkg/wrappers/command/outofbandv2_test.go index 306a6c71ce..ba9b441bb1 100644 --- a/cmd/aries-agent-mobile/pkg/wrappers/command/outofbandv2_test.go +++ b/cmd/aries-agent-mobile/pkg/wrappers/command/outofbandv2_test.go @@ -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 diff --git a/cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go b/cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go index 2d19304a06..f4371545c3 100644 --- a/cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go +++ b/cmd/aries-agent-mobile/pkg/wrappers/rest/outofband_test.go @@ -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{ @@ -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{ diff --git a/pkg/client/issuecredential/client.go b/pkg/client/issuecredential/client.go index b5a97d7a49..1c69ad189d 100644 --- a/pkg/client/issuecredential/client.go +++ b/pkg/client/issuecredential/client.go @@ -18,7 +18,7 @@ import ( const ( // web redirect decorator. - webRedirectDecorator = "~web-redirect" + webRedirectDecorator = "~web_redirect" webRedirectStatusFAIL = "FAIL" ) @@ -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{}{} diff --git a/pkg/client/presentproof/client.go b/pkg/client/presentproof/client.go index 9bf1eb49ce..38d3efc2c6 100644 --- a/pkg/client/presentproof/client.go +++ b/pkg/client/presentproof/client.go @@ -47,7 +47,7 @@ type ( const ( // web redirect decorator. - webRedirectDecorator = "~web-redirect" + webRedirectDecorator = "~web_redirect" webRedirectStatusOK = "OK" webRedirectStatusFAIL = "FAIL" ) @@ -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{}{} diff --git a/pkg/didcomm/common/model/ack.go b/pkg/didcomm/common/model/ack.go index f549d30828..aec145cb6c 100644 --- a/pkg/didcomm/common/model/ack.go +++ b/pkg/didcomm/common/model/ack.go @@ -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"` } diff --git a/pkg/didcomm/common/model/problem_report.go b/pkg/didcomm/common/model/problem_report.go index e5bcc92fa5..163413b45d 100644 --- a/pkg/didcomm/common/model/problem_report.go +++ b/pkg/didcomm/common/model/problem_report.go @@ -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. @@ -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"` } diff --git a/pkg/didcomm/protocol/introduce/models.go b/pkg/didcomm/protocol/introduce/models.go index af024f858e..f4649a95ce 100644 --- a/pkg/didcomm/protocol/introduce/models.go +++ b/pkg/didcomm/protocol/introduce/models.go @@ -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 diff --git a/pkg/didcomm/protocol/issuecredential/models.go b/pkg/didcomm/protocol/issuecredential/models.go index a9aa514b7a..acce629c22 100644 --- a/pkg/didcomm/protocol/issuecredential/models.go +++ b/pkg/didcomm/protocol/issuecredential/models.go @@ -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 @@ -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. diff --git a/pkg/didcomm/protocol/issuecredential/params_test.go b/pkg/didcomm/protocol/issuecredential/params_test.go index 8ed35e651a..3e2005ce2c 100644 --- a/pkg/didcomm/protocol/issuecredential/params_test.go +++ b/pkg/didcomm/protocol/issuecredential/params_test.go @@ -18,7 +18,7 @@ import ( const ( commentText = "this is a comment" - goalCodeText = "goal-code" + goalCodeText = "goal_code" messageIDText = "message-id-123" ) @@ -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, }, diff --git a/pkg/didcomm/protocol/issuecredential/service.go b/pkg/didcomm/protocol/issuecredential/service.go index 7d89f5a622..6875c4deca 100644 --- a/pkg/didcomm/protocol/issuecredential/service.go +++ b/pkg/didcomm/protocol/issuecredential/service.go @@ -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) diff --git a/pkg/didcomm/protocol/issuecredential/states.go b/pkg/didcomm/protocol/issuecredential/states.go index 89ad0f57ef..61610ba35e 100644 --- a/pkg/didcomm/protocol/issuecredential/states.go +++ b/pkg/didcomm/protocol/issuecredential/states.go @@ -34,7 +34,7 @@ const ( stateNameCredentialReceived = "credential-received" // web redirect decorator V2. - webRedirect = "~web-redirect" + webRedirect = "~web_redirect" ) const ( diff --git a/pkg/didcomm/protocol/outofbandv2/models.go b/pkg/didcomm/protocol/outofbandv2/models.go index eebd371748..02b3b007fe 100644 --- a/pkg/didcomm/protocol/outofbandv2/models.go +++ b/pkg/didcomm/protocol/outofbandv2/models.go @@ -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"` } diff --git a/pkg/didcomm/protocol/presentproof/states.go b/pkg/didcomm/protocol/presentproof/states.go index 8c4b39b29e..037ab2114c 100644 --- a/pkg/didcomm/protocol/presentproof/states.go +++ b/pkg/didcomm/protocol/presentproof/states.go @@ -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. diff --git a/pkg/wallet/invitation.go b/pkg/wallet/invitation.go index c962682b24..4944acb222 100644 --- a/pkg/wallet/invitation.go +++ b/pkg/wallet/invitation.go @@ -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"` diff --git a/test/bdd/features/waci_issuance_didcomm_v1.feature b/test/bdd/features/waci_issuance_didcomm_v1.feature index b36e11282d..f8910a28c6 100644 --- a/test/bdd/features/waci_issuance_didcomm_v1.feature +++ b/test/bdd/features/waci_issuance_didcomm_v1.feature @@ -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) diff --git a/test/bdd/features/waci_issuance_didcomm_v2.feature b/test/bdd/features/waci_issuance_didcomm_v2.feature index d073ce05e5..0dd106ceaa 100644 --- a/test/bdd/features/waci_issuance_didcomm_v2.feature +++ b/test/bdd/features/waci_issuance_didcomm_v2.feature @@ -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) diff --git a/test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go b/test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go index 54bbe6cf35..9a13682eed 100644 --- a/test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go +++ b/test/bdd/pkg/waci/waci_issuance_didcomm_v1_sdk_steps.go @@ -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) diff --git a/test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go b/test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go index 513af54624..e5adadce65 100644 --- a/test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go +++ b/test/bdd/pkg/waci/waci_issuance_didcomm_v2_sdk_steps.go @@ -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)