-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement parse SignaturePolicyEnvelope to human readable expression (#…
…135) Signed-off-by: 1gezhanghao <[email protected]> Signed-off-by: xvkong <[email protected]> Co-authored-by: Mark S. Lewis <[email protected]>
- Loading branch information
1 parent
8a2f81e
commit b782815
Showing
2 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package chaincode | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = DescribeTable("signaturepolicyenvelope to string", | ||
func(expression string) { | ||
//gen a SignaturePolicyEnvelope from expression | ||
applicationPolicy, err := NewApplicationPolicy(expression, "") | ||
Expect(err).NotTo(HaveOccurred()) | ||
policy := applicationPolicy.GetSignaturePolicy() | ||
|
||
//parse the SignaturePolicyEnvelope back to expression | ||
dstExpression, err := SignaturePolicyEnvelopeToString(policy) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
fmt.Println("src Expression:", expression) | ||
fmt.Println("dst Expression:", dstExpression) | ||
|
||
Expect(dstExpression).To(Equal(expression)) | ||
}, | ||
Entry("When keyword has OR", `OR('Org3MSP.peer','Org1MSP.admin','Org2MSP.member')`), | ||
Entry("When keyword has AND", `AND('Org3MSP.peer','Org1MSP.admin','Org2MSP.member')`), | ||
Entry("When keyword has AND,OR", `AND('Org3MSP.peer',OR('Org1MSP.admin','Org2MSP.member'))`), | ||
Entry("When keyword has OutOf", `OutOf(2,'Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')`), | ||
) |