@@ -15,8 +15,6 @@ import (
1515 "time"
1616
1717 api "github.com/hyperledger/fabric-sdk-go/api/apiconfig"
18- pkcsFactory "github.com/hyperledger/fabric/bccsp/factory"
19- pkcs11 "github.com/hyperledger/fabric/bccsp/pkcs11"
2018 logging "github.com/op/go-logging"
2119 "github.com/spf13/viper"
2220)
@@ -28,8 +26,7 @@ var bccspProviderType string
2826var securityLevel = 256
2927
3028const (
31- providerTypeSW = "SW"
32- providerTypePKCS11 = "PKCS11"
29+ providerTypeSW = "SW"
3330)
3431
3532var validRootCA = `-----BEGIN CERTIFICATE-----
@@ -277,19 +274,19 @@ func TestCSPConfig(t *testing.T) {
277274
278275 if cspconfig != nil && cspconfig .ProviderName == "SW" {
279276 if cspconfig .SwOpts .HashFamily != configImpl .SecurityAlgorithm () {
280- t .Fatalf ("In correct hashfamily found for cspconfig" )
277+ t .Fatalf ("Incorrect hashfamily found for cspconfig" )
281278 }
282279
283280 if cspconfig .SwOpts .SecLevel != configImpl .SecurityLevel () {
284- t .Fatalf ("In correct security level found for cspconfig" )
281+ t .Fatalf ("Incorrect security level found for cspconfig" )
285282 }
286283
287284 if cspconfig .SwOpts .Ephemeral {
288- t .Fatalf ("In correct Ephemeral found for cspconfig" )
285+ t .Fatalf ("Incorrect Ephemeral found for cspconfig" )
289286 }
290287
291288 if cspconfig .SwOpts .FileKeystore .KeyStorePath != configImpl .KeyStorePath () {
292- t .Fatalf ("In correct keystore path found for cspconfig" )
289+ t .Fatalf ("Incorrect keystore path found for cspconfig" )
293290 }
294291 }
295292}
@@ -471,79 +468,6 @@ func TestNetworkConfig(t *testing.T) {
471468 }
472469}
473470
474- func TestPKCS11CSPConfigWithValidOptions (t * testing.T ) {
475- opts := configurePKCS11Options ("SHA2" , securityLevel )
476- f := & pkcsFactory.PKCS11Factory {}
477- //
478- csp , err := f .Get (opts )
479- if err != nil {
480- t .Fatalf (err .Error ())
481- }
482- if csp == nil {
483- t .Fatalf ("BCCSP PKCS11 was not configured" )
484- }
485- fmt .Println ("TestPKCS11CSPConfigWithValidOptions passed. BCCSP PKCS11 provider was configured\n " , csp )
486-
487- }
488-
489- func TestPKCS11CSPConfigWithEmptyHashFamily (t * testing.T ) {
490-
491- opts := configurePKCS11Options ("" , securityLevel )
492-
493- f := & pkcsFactory.PKCS11Factory {}
494- fmt .Println (f .Name ())
495- _ , err := f .Get (opts )
496- if err == nil {
497- t .Fatalf ("Expected error 'Hash Family not supported'" )
498- }
499- fmt .Println ("TestPKCS11CSPConfigWithEmptyHashFamily passed. " )
500-
501- }
502-
503- func TestPKCS11CSPConfigWithIncorrectLevel (t * testing.T ) {
504-
505- opts := configurePKCS11Options ("SHA2" , 100 )
506-
507- f := & pkcsFactory.PKCS11Factory {}
508- fmt .Println (f .Name ())
509- _ , err := f .Get (opts )
510- if err == nil {
511- t .Fatalf ("Expected error 'Failed initializing configuration'" )
512- }
513-
514- }
515-
516- func TestPKCS11CSPConfigWithEmptyProviderName (t * testing.T ) {
517- f := & pkcsFactory.PKCS11Factory {}
518- if f .Name () != providerTypePKCS11 {
519- t .Fatalf ("Expected default name for PKCS11. Got %s" , f .Name ())
520- }
521- }
522-
523- func configurePKCS11Options (hashFamily string , securityLevel int ) * pkcsFactory.FactoryOpts {
524- providerLib , softHSMPin , softHSMTokenLabel := pkcs11 .FindPKCS11Lib ()
525-
526- pkks := pkcs11.FileKeystoreOpts {KeyStorePath : os .TempDir ()}
527- //PKCS11 options
528- pkcsOpt := pkcs11.PKCS11Opts {
529- SecLevel : securityLevel ,
530- HashFamily : hashFamily ,
531- FileKeystore : & pkks ,
532- Library : providerLib ,
533- Pin : softHSMPin ,
534- Label : softHSMTokenLabel ,
535- Ephemeral : false ,
536- }
537-
538- opts := & pkcsFactory.FactoryOpts {
539- ProviderName : providerTypePKCS11 ,
540- Pkcs11Opts : & pkcsOpt ,
541- }
542- pkcsFactory .InitFactories (opts )
543- return opts
544-
545- }
546-
547471func TestMain (m * testing.M ) {
548472 var err error
549473 configImpl , err = InitConfig ("../../test/fixtures/config/config_test.yaml" )
0 commit comments