-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-10175] Ginkgo runner for idemixgen
Adds a runner for idemixgen and adds to world. Needed to modify idemixgen to find the CA in the output directory as you need to cal ca-keygen and signerconfig in order. Change-Id: I70d003632ac705ea9fd1ed135440924ae902445e Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
- v3.0.0
- v3.0.0-rc1
- v3.0.0-preview
- v3.0.0-beta
- v2.5.11
- v2.5.10
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.5.0-beta2
- v2.5.0-beta
- v2.5.0-alpha3
- v2.5.0-alpha2
- v2.5.0-alpha1
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.4.0-beta
- v2.4.0-alpha
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.15
- v2.2.14
- v2.2.13
- v2.2.12
- v2.2.11
- v2.2.10
- v2.2.9
- v2.2.8
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v2.0.0-beta
- v2.0.0-alpha
- v1.4.12
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.1-rc1
- v1.4.0
- v1.4.0-rc2
- v1.4.0-rc1
- v1.3.0
- v1.3.0-rc1
- v1.2.1
- v1.2.0
- v1.2.0-rc1
1 parent
7400cc1
commit 54237e4
Showing
5 changed files
with
153 additions
and
3 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,61 @@ | ||
/* | ||
Copyright IBM Corp All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package runner | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/tedsuo/ifrit/ginkgomon" | ||
) | ||
|
||
// Idemixgen creates runners that call idemixgen functions. | ||
type Idemixgen struct { | ||
// Location of the idemixgen executable | ||
Path string | ||
// Output directory | ||
Output string | ||
// Enrollment ID for the default signer | ||
EnrollID string | ||
// The organizational unit for the default signer | ||
OrgUnit string | ||
// Flag for making the default signer an admin | ||
IsAdmin bool | ||
// Handle used to revoke the default signer | ||
RevocationHandle int | ||
} | ||
|
||
// CAKeyGen uses idemixgen to generate CA key material for an IdeMix MSP. | ||
func (c *Idemixgen) CAKeyGen(extraArgs ...string) *ginkgomon.Runner { | ||
return ginkgomon.New(ginkgomon.Config{ | ||
Name: "idemix ca-keygen", | ||
AnsiColorCode: "38m", | ||
Command: exec.Command( | ||
c.Path, | ||
append([]string{ | ||
"ca-keygen", | ||
"--output", c.Output, | ||
}, extraArgs...)..., | ||
), | ||
}) | ||
} | ||
|
||
// SignerConfig uses idemixgen to generate a signer for an IdeMix MSP. | ||
func (c *Idemixgen) SignerConfig(extraArgs ...string) *ginkgomon.Runner { | ||
return ginkgomon.New(ginkgomon.Config{ | ||
Name: "idemix signerconfig", | ||
AnsiColorCode: "38m", | ||
Command: exec.Command( | ||
c.Path, | ||
append([]string{ | ||
"signerconfig", | ||
"-e", c.EnrollID, | ||
"-u", c.OrgUnit, | ||
"--output", c.Output, | ||
}, extraArgs...)..., | ||
), | ||
}) | ||
} |
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,78 @@ | ||
/* | ||
Copyright IBM Corp All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package runner_test | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/hyperledger/fabric/integration/runner" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/tedsuo/ifrit" | ||
) | ||
|
||
var _ = Describe("Idemixgen", func() { | ||
var idemixgen *runner.Idemixgen | ||
var tempDir string | ||
var err error | ||
tempDir, err = ioutil.TempDir("", "idemix") | ||
if err != nil { | ||
Fail("Failed to create test directory") | ||
} | ||
|
||
BeforeEach(func() { | ||
idemixgen = &runner.Idemixgen{ | ||
Path: components.Paths["idemixgen"], | ||
EnrollID: "IdeMixUser1", | ||
OrgUnit: "IdeMixOU", | ||
Output: tempDir, | ||
} | ||
}) | ||
|
||
It("creates a runner that calls idemixgen ca-keygen", func() { | ||
igRunner := idemixgen.CAKeyGen() | ||
process := ifrit.Invoke(igRunner) | ||
Eventually(process.Ready()).Should(BeClosed()) | ||
Eventually(process.Wait()).Should(Receive(BeNil())) | ||
Expect(igRunner.ExitCode()).To(Equal(0)) | ||
|
||
Expect(filepath.Join(tempDir, "ca")).To(BeADirectory()) | ||
Expect(filepath.Join(tempDir, "msp")).To(BeADirectory()) | ||
}) | ||
|
||
Context("when idemixgen ca-keygen fails", func() { | ||
It("returns an error", func() { | ||
igRunner := idemixgen.CAKeyGen("bogus") | ||
process := ifrit.Invoke(igRunner) | ||
Eventually(process.Wait()).Should(Receive(HaveOccurred())) | ||
}) | ||
}) | ||
|
||
It("creates a runner that calls idemixgen signerconfig", func() { | ||
igRunner := idemixgen.SignerConfig() | ||
process := ifrit.Invoke(igRunner) | ||
Eventually(process.Ready()).Should(BeClosed()) | ||
Eventually(process.Wait()).Should(Receive(BeNil())) | ||
Expect(igRunner.ExitCode()).To(Equal(0)) | ||
|
||
Expect(filepath.Join(tempDir, "user")).To(BeADirectory()) | ||
}) | ||
|
||
Context("when idemixgen signerconfig fails", func() { | ||
It("returns an error", func() { | ||
igRunner := idemixgen.SignerConfig("bogus") | ||
process := ifrit.Invoke(igRunner) | ||
Eventually(process.Wait()).Should(Receive(HaveOccurred())) | ||
}) | ||
}) | ||
|
||
// cleanup | ||
os.RemoveAll(tempDir) | ||
}) |
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