This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1962 from soluchok/issue-1945
feat: Present Proof - added correlation id
- Loading branch information
Showing
16 changed files
with
396 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package presentproof | ||
|
||
import "errors" | ||
|
||
const ( | ||
myDIDPropKey = "myDID" | ||
theirDIDPropKey = "theirDID" | ||
piidPropKey = "piid" | ||
errorPropKey = "error" | ||
) | ||
|
||
type eventProps struct { | ||
myDID string | ||
theirDID string | ||
piid string | ||
err error | ||
} | ||
|
||
func newEventProps(md *metaData) *eventProps { | ||
return &eventProps{ | ||
myDID: md.MyDID, | ||
theirDID: md.TheirDID, | ||
piid: md.PIID, | ||
err: md.err, | ||
} | ||
} | ||
|
||
func (e *eventProps) MyDID() string { | ||
return e.myDID | ||
} | ||
|
||
func (e *eventProps) TheirDID() string { | ||
return e.theirDID | ||
} | ||
|
||
func (e *eventProps) PIID() string { | ||
return e.piid | ||
} | ||
|
||
func (e eventProps) Err() error { | ||
if errors.As(e.err, &customError{}) { | ||
return nil | ||
} | ||
|
||
return e.err | ||
} | ||
|
||
// All implements EventProperties interface | ||
func (e eventProps) All() map[string]interface{} { | ||
all := map[string]interface{}{} | ||
if e.myDID != "" { | ||
all[myDIDPropKey] = e.myDID | ||
} | ||
|
||
if e.theirDID != "" { | ||
all[theirDIDPropKey] = e.theirDID | ||
} | ||
|
||
if e.piid != "" { | ||
all[piidPropKey] = e.piid | ||
} | ||
|
||
if e.Err() != nil { | ||
all[errorPropKey] = e.Err() | ||
} | ||
|
||
return all | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package presentproof | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestEventProps_All(t *testing.T) { | ||
md := &metaData{} | ||
md.MyDID = "MyDID" | ||
md.TheirDID = "TheirDID" | ||
md.PIID = "PIID" | ||
md.err = errors.New("error") | ||
|
||
props := newEventProps(md) | ||
|
||
require.Equal(t, md.MyDID, props.MyDID()) | ||
require.Equal(t, md.TheirDID, props.TheirDID()) | ||
require.Equal(t, md.PIID, props.PIID()) | ||
require.Equal(t, md.err, props.Err()) | ||
require.Equal(t, 4, len(props.All())) | ||
|
||
md.err = customError{errors.New("error")} | ||
md.MyDID = "" | ||
|
||
props = newEventProps(md) | ||
|
||
require.Equal(t, md.MyDID, props.MyDID()) | ||
require.Equal(t, md.TheirDID, props.TheirDID()) | ||
require.Equal(t, md.PIID, props.PIID()) | ||
require.Equal(t, nil, props.Err()) | ||
require.Equal(t, 2, len(props.All())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.