Skip to content

Commit

Permalink
fixup! go/oasis-test-runner/oasis: Add a keymanager replication test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yawning committed May 5, 2020
1 parent 505fbb0 commit 3085711
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions go/oasis-test-runner/oasis/keymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (

"github.com/oasislabs/oasis-core/go/common/node"
"github.com/oasislabs/oasis-core/go/consensus/tendermint/crypto"
"github.com/oasislabs/oasis-core/go/oasis-node/cmd/common"
"github.com/oasislabs/oasis-core/go/oasis-node/cmd/common/flags"
kmCmd "github.com/oasislabs/oasis-core/go/oasis-node/cmd/keymanager"
"github.com/oasislabs/oasis-core/go/oasis-test-runner/env"
registry "github.com/oasislabs/oasis-core/go/registry/api"
)
Expand Down Expand Up @@ -44,17 +47,17 @@ func (pol *KeymanagerPolicy) provisionStatusArgs() []string {
func (pol *KeymanagerPolicy) provision() error {
if pol.runtime.teeHardware == node.TEEHardwareInvalid {
// No policy document.
pol.statusArgs = append(pol.statusArgs, "--keymanager.policy.file", "")
pol.statusArgs = append(pol.statusArgs, "--"+kmCmd.CfgPolicyFile, "")
} else {
// Policy signed with test keys.
policyPath := filepath.Join(pol.dir.String(), kmPolicyFile)
policyArgs := []string{
"keymanager", "init_policy",
"--debug.dont_blame_oasis",
"--keymanager.policy.file", policyPath,
"--keymanager.policy.id", pol.runtime.id.String(),
"--keymanager.policy.serial", strconv.Itoa(pol.serial),
"--keymanager.policy.enclave.id", pol.runtime.mrEnclave.String() + pol.runtime.mrSigner.String(),
"--" + flags.CfgDebugDontBlameOasis,
"--" + kmCmd.CfgPolicyFile, policyPath,
"--" + kmCmd.CfgPolicyID, pol.runtime.id.String(),
"--" + kmCmd.CfgPolicySerial, strconv.Itoa(pol.serial),
"--" + kmCmd.CfgPolicyEnclaveID, pol.runtime.mrEnclave.String() + pol.runtime.mrSigner.String(),
}

for _, rt := range pol.net.runtimes {
Expand All @@ -63,7 +66,7 @@ func (pol *KeymanagerPolicy) provision() error {
}

arg := fmt.Sprintf("%s=%s%s", rt.id, rt.mrEnclave, rt.mrSigner)
policyArgs = append(policyArgs, "--keymanager.policy.may.query", arg)
policyArgs = append(policyArgs, "--"+kmCmd.CfgPolicyMayQuery, arg)
}

w, err := pol.dir.NewLogWriter("provision-policy.log")
Expand All @@ -82,18 +85,18 @@ func (pol *KeymanagerPolicy) provision() error {
// Sign policy with test keys.
signArgsTpl := []string{
"keymanager", "sign_policy",
"--debug.allow_test_keys",
"--debug.dont_blame_oasis",
"--keymanager.policy.file", policyPath,
"--" + common.CfgDebugAllowTestKeys,
"--" + flags.CfgDebugDontBlameOasis,
"--" + kmCmd.CfgPolicyFile, policyPath,
}
for i := 1; i <= 3; i++ {
signatureFile := filepath.Join(pol.dir.String(), fmt.Sprintf("%s.sign.%d", kmPolicyFile, i))
signArgs := append([]string{}, signArgsTpl...)
signArgs = append(signArgs, []string{
"--keymanager.policy.signature.file", signatureFile,
"--keymanager.policy.testkey", fmt.Sprintf("%d", i),
"--" + kmCmd.CfgPolicySigFile, signatureFile,
"--" + kmCmd.CfgPolicyTestKey, fmt.Sprintf("%d", i),
}...)
pol.statusArgs = append(pol.statusArgs, "--keymanager.policy.signature.file", signatureFile)
pol.statusArgs = append(pol.statusArgs, "--"+kmCmd.CfgPolicySigFile, signatureFile)

w, err := pol.dir.NewLogWriter("provision-policy-sign.log")
if err != nil {
Expand All @@ -109,7 +112,7 @@ func (pol *KeymanagerPolicy) provision() error {
}
}

pol.statusArgs = append(pol.statusArgs, "--keymanager.policy.file", policyPath)
pol.statusArgs = append(pol.statusArgs, "--"+kmCmd.CfgPolicyFile, policyPath)
}

return nil
Expand Down Expand Up @@ -211,10 +214,10 @@ func (km *Keymanager) provisionGenesis() error {
// a list of runtimes allowed to query the key manager.
statusArgs := []string{
"keymanager", "init_status",
"--debug.dont_blame_oasis",
"--debug.allow_test_keys",
"--keymanager.status.id", km.runtime.id.String(),
"--keymanager.status.file", filepath.Join(km.dir.String(), kmStatusFile),
"--" + common.CfgDebugAllowTestKeys,
"--" + flags.CfgDebugDontBlameOasis,
"--" + kmCmd.CfgStatusID, km.runtime.id.String(),
"--" + kmCmd.CfgStatusFile, filepath.Join(km.dir.String(), kmStatusFile),
}
statusArgs = append(statusArgs, km.policy.provisionStatusArgs()...)

Expand Down

0 comments on commit 3085711

Please sign in to comment.