-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-5919] Refactor CI to run unit tests without docker
Change-Id: I0b18532a75a49184dd4840e3bc5c99999470275c Signed-off-by: Aleksandar Likic <aleksandar.likic@securekey.com>
- Loading branch information
Aleksandar Likic
committed
Aug 25, 2017
1 parent
6648c81
commit 7570207
Showing
11 changed files
with
151 additions
and
116 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
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,20 @@ | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
version: '2' | ||
|
||
services: | ||
|
||
fabric-sdk-pkcs11-tests: | ||
container_name: fabric-sdk-pkcs11-test | ||
image: softhsm2-image | ||
environment: | ||
- FABRIC_SDK_CLIENT_BCCSP_SECURITY_DEFAULT_PROVIDER=PKCS11 | ||
volumes: | ||
- ../../:/opt/gopath/src/github.com/hyperledger/fabric-sdk-go | ||
command: /opt/gopath/src/github.com/hyperledger/fabric-sdk-go/test/scripts/integration.sh | ||
depends_on: | ||
- orderer.example.com | ||
- builder |
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,97 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
api "github.com/hyperledger/fabric-sdk-go/api/apiconfig" | ||
pkcsFactory "github.com/hyperledger/fabric/bccsp/factory" | ||
pkcs11 "github.com/hyperledger/fabric/bccsp/pkcs11" | ||
) | ||
|
||
var configImpl api.Config | ||
var securityLevel = 256 | ||
|
||
const ( | ||
providerTypePKCS11 = "PKCS11" | ||
) | ||
|
||
func TestPKCS11CSPConfigWithValidOptions(t *testing.T) { | ||
opts := configurePKCS11Options("SHA2", securityLevel) | ||
f := &pkcsFactory.PKCS11Factory{} | ||
// | ||
csp, err := f.Get(opts) | ||
if err != nil { | ||
t.Fatalf(err.Error()) | ||
} | ||
if csp == nil { | ||
t.Fatalf("BCCSP PKCS11 was not configured") | ||
} | ||
fmt.Println("TestPKCS11CSPConfigWithValidOptions passed. BCCSP PKCS11 provider was configured\n", csp) | ||
|
||
} | ||
|
||
func TestPKCS11CSPConfigWithEmptyHashFamily(t *testing.T) { | ||
|
||
opts := configurePKCS11Options("", securityLevel) | ||
|
||
f := &pkcsFactory.PKCS11Factory{} | ||
fmt.Println(f.Name()) | ||
_, err := f.Get(opts) | ||
if err == nil { | ||
t.Fatalf("Expected error 'Hash Family not supported'") | ||
} | ||
fmt.Println("TestPKCS11CSPConfigWithEmptyHashFamily passed. ") | ||
|
||
} | ||
|
||
func TestPKCS11CSPConfigWithIncorrectLevel(t *testing.T) { | ||
|
||
opts := configurePKCS11Options("SHA2", 100) | ||
|
||
f := &pkcsFactory.PKCS11Factory{} | ||
fmt.Println(f.Name()) | ||
_, err := f.Get(opts) | ||
if err == nil { | ||
t.Fatalf("Expected error 'Failed initializing configuration'") | ||
} | ||
|
||
} | ||
|
||
func TestPKCS11CSPConfigWithEmptyProviderName(t *testing.T) { | ||
f := &pkcsFactory.PKCS11Factory{} | ||
if f.Name() != providerTypePKCS11 { | ||
t.Fatalf("Expected default name for PKCS11. Got %s", f.Name()) | ||
} | ||
} | ||
|
||
func configurePKCS11Options(hashFamily string, securityLevel int) *pkcsFactory.FactoryOpts { | ||
providerLib, softHSMPin, softHSMTokenLabel := pkcs11.FindPKCS11Lib() | ||
|
||
pkks := pkcs11.FileKeystoreOpts{KeyStorePath: os.TempDir()} | ||
//PKCS11 options | ||
pkcsOpt := pkcs11.PKCS11Opts{ | ||
SecLevel: securityLevel, | ||
HashFamily: hashFamily, | ||
FileKeystore: &pkks, | ||
Library: providerLib, | ||
Pin: softHSMPin, | ||
Label: softHSMTokenLabel, | ||
Ephemeral: false, | ||
} | ||
|
||
opts := &pkcsFactory.FactoryOpts{ | ||
ProviderName: providerTypePKCS11, | ||
Pkcs11Opts: &pkcsOpt, | ||
} | ||
pkcsFactory.InitFactories(opts) | ||
return opts | ||
|
||
} |
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
File renamed without changes.