-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-9243] Add ability to get CA's idemix public key
Changes to the getcainfo/getcacert command to get CA idemix public key in addition to the X509 CA chain. It will be stored at <client msp>/IssuerPublicKey Changed getcacert command to getcainfo and added an alias so getcacert command will also work for backward compatibility. On the server, CA's Idemix public key will be stored in the CA home directory and secret key will be stored in the msp/keystore directory. Change-Id: Ie79ccb9491171eae81a2be972afac3807f10e437 Signed-off-by: Anil Ambati <[email protected]>
- Loading branch information
Anil Ambati
committed
May 11, 2018
1 parent
534af8c
commit f718bb5
Showing
22 changed files
with
515 additions
and
107 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
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,76 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package command | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric-ca/cmd/fabric-ca-client/mocks" | ||
"github.com/hyperledger/fabric-ca/lib" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewGetCACertCmd(t *testing.T) { | ||
cmd := new(mocks.Command) | ||
cmd.On("GetViper").Return(viper.New()) | ||
getcacertCmd := newGetCAInfoCmd(cmd) | ||
assert.NotNil(t, getcacertCmd) | ||
} | ||
|
||
func TestGetCommand(t *testing.T) { | ||
cmd := new(mocks.Command) | ||
cmd.On("GetViper").Return(viper.New()) | ||
getcacertCmd := newGetCAInfoCmd(cmd) | ||
cobraCmd := getcacertCmd.getCommand() | ||
assert.NotNil(t, cobraCmd) | ||
assert.Equal(t, cobraCmd.Name(), "getcainfo") | ||
assert.Equal(t, cobraCmd.Short, GetCAInfoCmdShortDesc) | ||
assert.Equal(t, cobraCmd.Use, GetCAInfoCmdUsage) | ||
|
||
f1 := reflect.ValueOf(cobraCmd.PreRunE) | ||
f2 := reflect.ValueOf(getcacertCmd.preRunGetCACert) | ||
assert.Equal(t, f1.Pointer(), f2.Pointer(), "PreRunE function variable of the getcacert cobra command must be preRunGetCACert function of the getCACert struct") | ||
|
||
f1 = reflect.ValueOf(cobraCmd.RunE) | ||
f2 = reflect.ValueOf(getcacertCmd.runGetCACert) | ||
assert.Equal(t, f1.Pointer(), f2.Pointer(), "RunE function variable of the getcacert cobra command must be runGetCACert function of the getCACert struct") | ||
} | ||
|
||
func TestBadConfigPreRunGetCACert(t *testing.T) { | ||
cmd := new(mocks.Command) | ||
cmd.On("GetViper").Return(viper.New()) | ||
cmd.On("ConfigInit").Return(errors.New("Failed to initialize config")) | ||
getcacertCmd := newGetCAInfoCmd(cmd) | ||
cobraCmd := getcacertCmd.getCommand() | ||
err := getcacertCmd.preRunGetCACert(cobraCmd, []string{}) | ||
assert.Error(t, err) | ||
assert.Equal(t, err.Error(), "Failed to initialize config") | ||
} | ||
|
||
func TestGoodConfigPreRunGetCACert(t *testing.T) { | ||
cmd := new(mocks.Command) | ||
cmd.On("GetViper").Return(viper.New()) | ||
cmd.On("ConfigInit").Return(nil) | ||
cmd.On("GetClientCfg").Return(&lib.ClientConfig{}) | ||
getcacertCmd := newGetCAInfoCmd(cmd) | ||
cobraCmd := getcacertCmd.getCommand() | ||
err := getcacertCmd.preRunGetCACert(cobraCmd, []string{}) | ||
assert.NoError(t, err) | ||
} |
Oops, something went wrong.