From 5853c4bcc2b3440690b7703d209c0439127e7a68 Mon Sep 17 00:00:00 2001 From: Atsushin Date: Tue, 21 Dec 2021 00:28:55 +0900 Subject: [PATCH] Simplify e2e-test for upgrading test env to the latest (#268) Signed-off-by: Atsushi Neki --- .env | 3 + .gitignore | 2 +- .../connection-profile/org1-network-pem.json | 61 -- app/platform/fabric/e2e-test/runTestSuite.sh | 116 +-- .../e2e-test/specs/apitest_suite_test.go | 3 +- .../fabric/e2e-test/specs/apitest_test.go | 769 +----------------- .../e2e-test/specs/apitest_utils_test.go | 2 +- .../fabric/e2e-test/specs/runexplorer.sh | 43 +- .../fabric/e2e-test/specs/stopexplorer.sh | 7 +- app/platform/fabric/gateway/FabricGateway.ts | 40 +- ci/azure-pipelines-release.yml | 2 +- ci/azure-pipelines.yml | 46 +- docker-compose.yaml | 14 +- package.json | 8 +- scripts/verify-license.sh | 4 +- test/api/config.json | 9 + .../configs => test/api}/config_multi.json | 4 +- .../api}/config_single-disable-auth.json | 2 +- .../api}/config_single-pem.json | 2 +- .../configs => test/api}/config_single.json | 2 +- .../org1-network-disable-auth.json | 20 +- .../connection-profile/org1-network-pem.json | 61 ++ .../api}/connection-profile/org1-network.json | 26 +- .../api}/connection-profile/org2-network.json | 26 +- .../connection-profile/test-network-ca.json | 69 ++ test/api/connection-profile/test-network.json | 48 ++ 26 files changed, 337 insertions(+), 1052 deletions(-) create mode 100644 .env delete mode 100644 app/platform/fabric/e2e-test/configs/connection-profile/org1-network-pem.json create mode 100644 test/api/config.json rename {app/platform/fabric/e2e-test/configs => test/api}/config_multi.json (52%) rename {app/platform/fabric/e2e-test/configs => test/api}/config_single-disable-auth.json (55%) rename {app/platform/fabric/e2e-test/configs => test/api}/config_single-pem.json (58%) rename {app/platform/fabric/e2e-test/configs => test/api}/config_single.json (59%) rename {app/platform/fabric/e2e-test/configs => test/api}/connection-profile/org1-network-disable-auth.json (53%) create mode 100644 test/api/connection-profile/org1-network-pem.json rename {app/platform/fabric/e2e-test/configs => test/api}/connection-profile/org1-network.json (57%) rename {app/platform/fabric/e2e-test/configs => test/api}/connection-profile/org2-network.json (56%) create mode 100644 test/api/connection-profile/test-network-ca.json create mode 100644 test/api/connection-profile/test-network.json diff --git a/.env b/.env new file mode 100644 index 000000000..0d82721a7 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +EXPLORER_CONFIG_FILE_PATH=./examples/net1/config.json +EXPLORER_PROFILE_DIR_PATH=./examples/net1/connection-profile +FABRIC_CRYPTO_PATH=/fabric-path/fabric-samples/test-network/organizations \ No newline at end of file diff --git a/.gitignore b/.gitignore index 10afcdc16..b32f375ca 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ app/test/coverage/ venv .vscode -test/* +test/fabric-samples tmp/* logs diff --git a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network-pem.json b/app/platform/fabric/e2e-test/configs/connection-profile/org1-network-pem.json deleted file mode 100644 index d72ef06bd..000000000 --- a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network-pem.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "org1-network", - "version": "1.0.0", - "license": "Apache-2.0", - "client": { - "tlsEnable": true, - "adminCredential": { - "id": "exploreradmin2", - "password": "exploreradminpw" - }, - "enableAuthentication": true, - "organization": "org1", - "connection": { - "timeout": { - "peer": { - "endorser": "300" - }, - "orderer": "300" - } - } - }, - "channels": { - "commonchannel": { - "peers": { - "peer0-org1": {} - }, - "connection": { - "timeout": { - "peer": { - "endorser": "6000", - "eventHub": "6000", - "eventReg": "6000" - } - } - } - } - }, - "organizations": { - "org1": { - "mspid": "Org1ExampleCom", - "adminPrivateKey": { - "pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgTOe+tIgG/TCjBruv\na5namOzeiEGhNxV+wYke2Ya7vXqhRANCAATux7xsRpKYrTJv18qJPfI8ypWrjcno\nzs9pF0UsrT2zKfaKPouGT3Tl58DujHvwXbM68FKQPiA86GA4AKrSMpZx\n-----END PRIVATE KEY-----\n\n" - }, - "peers": ["peer0-org1"], - "signedCert": { - "pem": "-----BEGIN CERTIFICATE-----\nMIIB9DCCAZugAwIBAgIQOiMkd2Zh+BDeMU+pGOsfdzAKBggqhkjOPQQDAjBbMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzENMAsGA1UEChMEb3JnMTEQMA4GA1UEAxMHY2Eub3JnMTAeFw0yMDA3\nMTQwNjI3MDBaFw0zMDA3MTIwNjI3MDBaME8xCzAJBgNVBAYTAlVTMRMwEQYDVQQI\nEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRMwEQYDVQQDDApB\nZG1pbkBvcmcxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7se8bEaSmK0yb9fK\niT3yPMqVq43J6M7PaRdFLK09syn2ij6Lhk905efA7ox78F2zOvBSkD4gPOhgOACq\n0jKWcaNNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQw\nIoAg0W6Kv0Z9DV5E+3sD6OErwjsJ882ogeeGzrB9jCBwZ74wCgYIKoZIzj0EAwID\nRwAwRAIgG6fqi1lB4sjcosYRbO2YxDYJ92jmvR6FqCqKOXtwSQQCIGnXgTzNGvof\np1DFPz5c3DKmgjQlok2MAlKn6z01JRBM\n-----END CERTIFICATE-----\n\n" - } - } - }, - "peers": { - "peer0-org1": { - "tlsCACerts": { - "pem": "-----BEGIN CERTIFICATE-----\nMIICJjCCAc2gAwIBAgIQRckhJx+KJbD5liP6bky2SjAKBggqhkjOPQQDAjBeMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzENMAsGA1UEChMEb3JnMTETMBEGA1UEAxMKdGxzY2Eub3JnMTAeFw0y\nMDA3MTQwNjI3MDBaFw0zMDA3MTIwNjI3MDBaMF4xCzAJBgNVBAYTAlVTMRMwEQYD\nVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQK\nEwRvcmcxMRMwEQYDVQQDEwp0bHNjYS5vcmcxMFkwEwYHKoZIzj0CAQYIKoZIzj0D\nAQcDQgAEVzX85nYUlr/Kc8kWYcdr2L4ICp1GURWDgG0oZd9X6ATZUj2yghcTk6hh\nKvawyyfVuH95S3johA3WZzzRW537FaNtMGswDgYDVR0PAQH/BAQDAgGmMB0GA1Ud\nJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MCkGA1Ud\nDgQiBCDkk8d226n5IMJh9RwUaanA3lDDErXkSXT9uTUhA++3lDAKBggqhkjOPQQD\nAgNHADBEAiBx7YneCm31nYCo8kk7LD1gLbMeW//ItePlwLjYtowGcwIgPdjuHCOX\nH+U/87Z4PvNbNdoDi4a22Bg8BPIPRISxYjU=\n-----END CERTIFICATE-----\n\n" - }, - "url": "grpcs://localhost:31000", - "grpcOptions": { - "ssl-target-name-override": "peer0-org1" - } - } - } -} diff --git a/app/platform/fabric/e2e-test/runTestSuite.sh b/app/platform/fabric/e2e-test/runTestSuite.sh index acfc28c21..c15a6825c 100755 --- a/app/platform/fabric/e2e-test/runTestSuite.sh +++ b/app/platform/fabric/e2e-test/runTestSuite.sh @@ -1,98 +1,50 @@ #!/bin/bash ROOTDIR="$(cd "$(dirname "$0")"/../../../.. && pwd)" -FABRIC_V1_VERSION=1.4.11 -FABRIC_CA_V1_VERSION=1.4.9 -FABRIC_V2_VERSION=2.3.1 -FABRIC_CA_V2_VERSION=1.4.9 - -echo "#### Downloaded fabric-test repo" - -if [ $# -eq 0 ]; then - echo "$0 [-1 | -2]" - exit 1; -fi - -while getopts "12" opt; do - case "$opt" in - 1) - SDKVER=1.4.11 - export FABRIC_VERSION=1 - export RELEASE_VERSION=1.4-stable - CHECKOUT_HASH=45799a2ee4eefa49ae705cc57ed415270c35d60a - # export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/config - export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/bin:$PATH - PULL_PEER_IMAGE_VERSION=${FABRIC_V1_VERSION} - PULL_CA_IMAGE_VERSION=${FABRIC_CA_V1_VERSION} - ;; - 2) - SDKVER=2.0.0-beta.2 - export FABRIC_VERSION=2 - CHECKOUT_HASH=09680bea5aa0ec464982f7979fd99a777e8c1fed - export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/config - export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/bin:$PATH - PULL_PEER_IMAGE_VERSION=${FABRIC_V2_VERSION} - PULL_CA_IMAGE_VERSION=${FABRIC_CA_V2_VERSION} - ;; - *) - echo "$0 [-1 | -2]" - exit 1; - ;; - esac -done - -echo "HASH: ${CHECKOUT_HASH}" -echo "SDK : ${SDKVER}" -echo "ROOT: ${ROOTDIR}" -set -e +mkdir $ROOTDIR/test 2>/dev/null -mkdir -p $GOPATH/src/github.com/hyperledger - -pushd $GOPATH/src/github.com/hyperledger -sudo rm -rf fabric-test -if [ ! -d fabric-test ]; then - git clone https://github.com/hyperledger/fabric-test.git -fi -cd fabric-test -# git checkout 45799a2ee4eefa49ae705cc57ed415270c35d60a -git checkout ${CHECKOUT_HASH} -make pull-binaries-fabric -echo "#### Updated each sub-module under fabric-test repo" -popd +pushd $ROOTDIR/test -pushd $GOPATH/src/github.com/hyperledger/fabric-test/tools/PTE -npm install fabric-client@${SDKVER} -npm install fabric-ca-client@${SDKVER} -echo "#### Installed required node packages" -popd +curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.3.3 1.5.2 +# curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.1.1 1.4.7 0.4.20 +# curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.2.4 1.5.2 -pushd $ROOTDIR/app/platform/fabric/e2e-test -rm -f PTE -ln -s $GOPATH/src/github.com/hyperledger/fabric-test/tools/PTE ./PTE popd -pushd $ROOTDIR -rm -rf wallet logs -popd +pushd $ROOTDIR/test/fabric-samples/test-network -curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- ${PULL_PEER_IMAGE_VERSION} ${PULL_CA_IMAGE_VERSION} 0.4.18 -s -b -docker tag hyperledger/fabric-ca:${PULL_CA_IMAGE_VERSION} hyperledger/fabric-ca:${PULL_PEER_IMAGE_VERSION} +git checkout a97e8d1267fafb013aadae6850312c1b07a1ecd8 +docker rm -f $(docker ps -qa) 2>/dev/null +docker volume rm $(docker volume ls -q) 2>/dev/null +./network.sh down -pushd $ROOTDIR/app/platform/fabric/e2e-test/specs +set -e + +./network.sh up createChannel -ca -c org1channel +./network.sh createChannel -ca -c commonchannel +find organizations/peerOrganizations/ -type f -name "*_sk" | xargs dirname | xargs -I{} bash -c "pushd {} && ln -s *_sk priv_sk && popd" +./network.sh deployCC -c org1channel -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go + +export PATH=${PWD}/../bin:$PATH +export FABRIC_CFG_PATH=$PWD/../config/ +export CORE_PEER_TLS_ENABLED=true +export CORE_PEER_LOCALMSPID="Org1MSP" +export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt +export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp +export CORE_PEER_ADDRESS=localhost:7051 -rm -rf templates -sed -i -e '/github.com\/hyperledger\/fabric-test/d' go.mod -if [ ${FABRIC_VERSION} -eq 2 ]; then - cp -a templates-v2 templates - go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH} - go get github.com/hyperledger/fabric-test/tools/operator@${CHECKOUT_HASH} - go get github.com/hyperledger/fabric-test/chaincodes/samplecc/go@${CHECKOUT_HASH} -else - cp -a templates-v1 templates - go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH} -fi +peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C org1channel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}' + +sleep 3 + +peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C org1channel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"TransferAsset","Args":["asset6","Christopher"]}' + +popd + +pushd $ROOTDIR/app/platform/fabric/e2e-test/specs echo "#### Starting Ginkgo based test suite" ginkgo -v -stream -failFast + popd \ No newline at end of file diff --git a/app/platform/fabric/e2e-test/specs/apitest_suite_test.go b/app/platform/fabric/e2e-test/specs/apitest_suite_test.go index a91379592..998133c2f 100644 --- a/app/platform/fabric/e2e-test/specs/apitest_suite_test.go +++ b/app/platform/fabric/e2e-test/specs/apitest_suite_test.go @@ -41,9 +41,8 @@ func dumpLog() { fmt.Println("=== Dump Explorer app log ===") fmt.Println(cwd) os.Chdir(relativePahtToRoot) - cmd := exec.Command("cat", "logs/console/console.log") + cmd := exec.Command("docker", "logs", "explorer.mynetwork.com") session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) Expect(err).ShouldNot(HaveOccurred()) session.Wait() - fmt.Println(session.Out) } diff --git a/app/platform/fabric/e2e-test/specs/apitest_test.go b/app/platform/fabric/e2e-test/specs/apitest_test.go index 57b8b3253..c597e6e70 100644 --- a/app/platform/fabric/e2e-test/specs/apitest_test.go +++ b/app/platform/fabric/e2e-test/specs/apitest_test.go @@ -1,20 +1,15 @@ package apitest import ( - "fmt" - "log" "os" "os/exec" "strconv" - "strings" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/hyperledger/fabric-test/tools/operator/launcher" "github.com/hyperledger/fabric-test/tools/operator/networkclient" - "github.com/hyperledger/fabric-test/tools/operator/testclient" ) var ( @@ -116,72 +111,10 @@ var _ = Describe("REST API Test Suite - Single profile", func() { Describe("Running REST API Test Suite in fabric-test", func() { - It("Starting fabric network", func() { - var fabricVer = os.Getenv("FABRIC_VERSION") - if fabricVer == "1" { - networkSpecPath = "apitest-network-spec.yml" - } else { - networkSpecPath = "apitest-network-spec-v2.yml" - } - fmt.Printf("Network spec is %s\n", networkSpecPath) - err := launcher.Launcher("up", "docker", "", networkSpecPath) - Expect(err).NotTo(HaveOccurred()) - }) - - It("starting fabric network", func() { - out, err := exec.Command("pwd").Output() - if err != nil { - log.Fatal(err) - } - fmt.Printf("The date is %s\n", out) - inputSpecPath = "apitest-input-singleprofile.yml" - - By("0) Generating channel artifacts") - _, err = networkclient.ExecuteCommand("./genchannelartifacts.sh", []string{}, true) - Expect(err).NotTo(HaveOccurred()) - - By("1) Creating channel") - action = "create" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("2) Joining Peers to channel") - action = "join" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("3) Updating channel with anchor peers") - action = "anchorpeer" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("4) Installing Chaincode on Peers") - action = "install" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("5) Instantiating Chaincode") - action = "instantiate" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("6) Sending Queries") - action = "query" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("7) Sending Invokes") - action = "invoke" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - }) - It("launch explorer", func() { cwd, _ := os.Getwd() os.Chdir(relativePahtToRoot) - os.RemoveAll("./logs") + // os.RemoveAll("./logs") os.Chdir(cwd) cmd := exec.Command("bash", "./runexplorer.sh", "-m", "single") @@ -275,68 +208,6 @@ var _ = Describe("REST API Test Suite - Single profile", func() { basicCheck("exploreradmin2") - Describe("Bugfix check:", func() { - - It("Add new channel to org1 and explorer should detect it", func() { - inputSpecPath = "apitest-input-singleprofile_addnewch.yml" - - By("1) Creating channel") - action := "create" - err := testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("2) Joining Peers to channel") - action = "join" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("3) Updating channel with anchor peers") - action = "anchorpeer" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("4) Instantiating Chaincode") - action = "instantiate" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("5) Sending Queries") - action = "query" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("6) Sending Invokes") - action = "invoke" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - }) - - It("Should include the newly added channel when retrieving channels again", func() { - resp := restGetWithToken("/api/channels", &ChannelsResponse{}, token) - result := resp.Result().(*ChannelsResponse) - Expect(result.Channels).Should(ContainElements([]string{"org1channel", "commonchannel", "channel2422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422"})) - }) - - It("Should create a new event hub for the newly added channel within 60s", func() { - channelMonitored = "channel2422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422422" - Eventually(CheckHowManyEventHubRegistered, 70, 5).Should(Equal(true)) - channelMonitored = "commonchannel" - Expect(CheckHowManyEventHubRegistered()).Should(Equal(true)) - channelMonitored = "org1channel" - Expect(CheckHowManyEventHubRegistered()).Should(Equal(true)) - }) - - It("should be able to validate hashchain correctly", func() { - _, err := exec.Command("bash", "./validate_hash.sh", "-c", "commonchannel").Output() - Expect(err).NotTo(HaveOccurred()) - - _, err = exec.Command("bash", "./validate_hash.sh", "-c", "org1channel").Output() - Expect(err).NotTo(HaveOccurred()) - }) - }) - It("stop explorer", func() { _, err := networkclient.ExecuteCommand("bash", []string{"./stopexplorer.sh"}, true) Expect(err).NotTo(HaveOccurred()) @@ -370,643 +241,5 @@ var _ = Describe("REST API Test Suite - Single profile", func() { Expect(err).NotTo(HaveOccurred()) }) - It("Shutdown network", func() { - err := launcher.Launcher("down", "docker", "", networkSpecPath) - Expect(err).NotTo(HaveOccurred()) - - dockerList := []string{"ps", "-aq", "-f", "status=exited"} - containerList, _ := networkclient.ExecuteCommand("docker", dockerList, false) - if containerList != "" { - list := strings.Split(containerList, "\n") - containerArgs := []string{"rm", "-f"} - containerArgs = append(containerArgs, list...) - networkclient.ExecuteCommand("docker", containerArgs, true) - } - ccimagesList := []string{"images", "-q", "--filter=reference=dev*"} - images, _ := networkclient.ExecuteCommand("docker", ccimagesList, false) - if images != "" { - list := strings.Split(images, "\n") - imageArgs := []string{"rmi", "-f"} - imageArgs = append(imageArgs, list...) - networkclient.ExecuteCommand("docker", imageArgs, true) - } - }) - - }) -}) - -var _ = Describe("REST API Test Suite - Multiple profile", func() { - - Describe("Running REST API Test Suite in fabric-test", func() { - - It("Starting fabric network", func() { - var fabricVer = os.Getenv("FABRIC_VERSION") - if fabricVer == "1" { - networkSpecPath = "apitest-network-spec.yml" - } else { - networkSpecPath = "apitest-network-spec-v2.yml" - } - err := launcher.Launcher("up", "docker", "", networkSpecPath) - Expect(err).NotTo(HaveOccurred()) - }) - - It("Setup fabric network", func() { - - inputSpecPath = "apitest-input-multiprofile.yml" - - By("0) Generating channel artifacts") - _, err := networkclient.ExecuteCommand("bash", []string{"./genchannelartifacts.sh"}, true) - Expect(err).NotTo(HaveOccurred()) - - By("1) Creating channel") - action = "create" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("2) Joining Peers to channel") - action = "join" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("3) Updating channel with anchor peers") - action = "anchorpeer" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("4) Installing Chaincode on Peers") - action = "install" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("5) Instantiating Chaincode") - action = "instantiate" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - By("6) Sending Invokes") - action = "invoke" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - - }) - - It("launch explorer", func() { - cwd, _ := os.Getwd() - os.Chdir(relativePahtToRoot) - os.RemoveAll("./logs") - os.Chdir(cwd) - - cmd := exec.Command("bash", "./runexplorer.sh", "-m", "multi") - err := cmd.Start() - Expect(err).NotTo(HaveOccurred()) - Eventually(isExplorerReady, 60, 5).Should(Equal(true)) - - time.Sleep(waitSyncInterval * time.Second) - }) - - Context("/auth/networklist", func() { - It("get network list", func() { - resp := restGet("/auth/networklist", &NetworklistInfo{}) - result := resp.Result().(*NetworklistInfo) - nameList := []string{} - idList := []string{} - for _, val := range result.NetworkList { - nameList = append(nameList, val.Name) - idList = append(idList, val.Id) - } - Expect(nameList).Should(HaveLen(2)) - Expect(nameList).Should(ContainElements([]string{"org1 network", "org2 network"})) - Expect(idList).Should(HaveLen(2)) - Expect(idList).Should(ContainElements([]string{"org1-network", "org2-network"})) - - }) - }) - - Context("/auth/login", func() { - It("login to org1-network", func() { - resp := restPost("/auth/login", map[string]interface{}{"user": "org1exploreradmin", "password": "exploreradminpw", "network": "org1-network"}, &LoginResponse{}) - result := resp.Result().(*LoginResponse) - Expect(result.User.Message).Should(Equal("logged in")) - Expect(result.User.Name).Should(Equal("org1exploreradmin")) - }) - - It("login to org2-network", func() { - resp := restPost("/auth/login", map[string]interface{}{"user": "org2exploreradmin", "password": "exploreradminpw", "network": "org2-network"}, &LoginResponse{}) - result := resp.Result().(*LoginResponse) - Expect(result.User.Message).Should(Equal("logged in")) - Expect(result.User.Name).Should(Equal("org2exploreradmin")) - }) - }) - - Context("/api/channels", func() { - It("get channels for Org1", func() { - // For org1 - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restGetWithToken("/api/channels", &ChannelsResponse{}, token) - result := resp.Result().(*ChannelsResponse) - Expect(result.Channels).Should(ContainElements([]string{"org1channel", "commonchannel"})) - Expect(len(result.Channels)).Should(Equal(2)) - }) - - It("get channels for Org2", func() { - // For org2 - token := restLogin("org2exploreradmin", "exploreradminpw", "org2-network") - - resp := restGetWithToken("/api/channels", &ChannelsResponse{}, token) - result := resp.Result().(*ChannelsResponse) - Expect(result.Channels).Should(ContainElements([]string{"org2channel", "commonchannel"})) - Expect(len(result.Channels)).Should(Equal(2)) - }) - }) - - Context("/api/channels/info", func() { - - It("get channels info for org1", func() { - - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - time.Sleep(waitSyncInterval * time.Second) - - resp2 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result2 := resp2.Result().(*ChannelsInfoResp) - chList := result2.getChannelList() - Expect(chList).Should(ContainElements([]string{"commonchannel", "org1channel"})) - Expect(len(chList)).Should(Equal(2)) - fmt.Fprintf(GinkgoWriter, "Info: result2 %+v\n", result2) - action := "invoke" - inputSpecPath = "apitest-input-multiprofile-invoke-org1.yml" - err := testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - - resp3 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result3 := resp3.Result().(*ChannelsInfoResp) - fmt.Fprintf(GinkgoWriter, "Info: result3 %+v\n", result3) - - compareChannelsInfoBlockCount(result2, result3, "commonchannel", 0) - compareChannelsInfoBlockCount(result2, result3, "org1channel", 1) - compareChannelsInfoTxCount(result2, result3, "commonchannel", 0) - compareChannelsInfoTxCount(result2, result3, "org1channel", 1) - - // action = "invoke" - // inputSpecPath = "apitest-input-multiprofile-invoke-org2.yml" - // err = testclient.Testclient(action, inputSpecPath) - // Expect(err).NotTo(HaveOccurred()) - - // time.Sleep(waitSyncInterval * time.Second) - - // resp4 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - // result4 := resp4.Result().(*ChannelsInfoResp) - // fmt.Fprintf(GinkgoWriter, "Info: result4 %+v\n", result4) - - // compareChannelsInfoBlockCount(result3, result4, "commonchannel", 0) - // compareChannelsInfoBlockCount(result3, result4, "org1channel", 0) - // compareChannelsInfoTxCount(result3, result4, "commonchannel", 0) - // compareChannelsInfoTxCount(result3, result4, "org1channel", 0) - - action = "invoke" - inputSpecPath = "apitest-input-multiprofile-invoke-common.yml" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - - resp5 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result5 := resp5.Result().(*ChannelsInfoResp) - fmt.Fprintf(GinkgoWriter, "Info: result5 %+v\n", result5) - - compareChannelsInfoBlockCount(result3, result5, "commonchannel", 1) - compareChannelsInfoBlockCount(result3, result5, "org1channel", 0) - compareChannelsInfoTxCount(result3, result5, "commonchannel", 1) - compareChannelsInfoTxCount(result3, result5, "org1channel", 0) - }) - - It("get channels info for org2", func() { - - token := restLogin("org2exploreradmin", "exploreradminpw", "org2-network") - - time.Sleep(waitSyncInterval * time.Second) - - resp2 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result2 := resp2.Result().(*ChannelsInfoResp) - chList := result2.getChannelList() - Expect(chList).Should(ContainElements([]string{"commonchannel", "org2channel"})) - Expect(len(chList)).Should(Equal(2)) - fmt.Fprintf(GinkgoWriter, "Info: result2 %+v\n", result2) - - action := "invoke" - inputSpecPath = "apitest-input-multiprofile-invoke-org1.yml" - err := testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - - resp3 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result3 := resp3.Result().(*ChannelsInfoResp) - fmt.Fprintf(GinkgoWriter, "Info: result3 %+v\n", result3) - - compareChannelsInfoBlockCount(result2, result3, "commonchannel", 0) - compareChannelsInfoBlockCount(result2, result3, "org2channel", 0) - compareChannelsInfoTxCount(result2, result3, "commonchannel", 0) - compareChannelsInfoTxCount(result2, result3, "org2channel", 0) - - // action = "invoke" - // inputSpecPath = "apitest-input-multiprofile-invoke-org2.yml" - // err = testclient.Testclient(action, inputSpecPath) - // Expect(err).NotTo(HaveOccurred()) - - // time.Sleep(waitSyncInterval * time.Second) - - // resp4 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - // result4 := resp4.Result().(*ChannelsInfoResp) - // fmt.Fprintf(GinkgoWriter, "Info: result4 %+v\n", result4) - - // compareChannelsInfoBlockCount(result3, result4, "commonchannel", 0) - // compareChannelsInfoBlockCount(result3, result4, "org2channel", 1) - // compareChannelsInfoTxCount(result3, result4, "commonchannel", 0) - // compareChannelsInfoTxCount(result3, result4, "org2channel", 1) - - action = "invoke" - inputSpecPath = "apitest-input-multiprofile-invoke-common.yml" - err = testclient.Testclient(action, inputSpecPath) - Expect(err).NotTo(HaveOccurred()) - - time.Sleep(waitSyncInterval * time.Second) - - resp5 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result5 := resp5.Result().(*ChannelsInfoResp) - fmt.Fprintf(GinkgoWriter, "Info: result5 %+v\n", result5) - - compareChannelsInfoBlockCount(result3, result5, "commonchannel", 1) - compareChannelsInfoBlockCount(result3, result5, "org2channel", 0) - compareChannelsInfoTxCount(result3, result5, "commonchannel", 1) - compareChannelsInfoTxCount(result3, result5, "org2channel", 0) - }) - }) - - Context("/api/block/(channelHash)/(blockHeight)", func() { - - It("get block info for org1", func() { - - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp2 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result2 := resp2.Result().(*ChannelsInfoResp) - - channelGenesisHash := result2.getGenesisHash("org1channel") - latestBlockNum := result2.getBlockHeight("org1channel") - 1 - Expect(len(channelGenesisHash)).ShouldNot(Equal(0)) - - resp3 := restGetWithToken("/api/block/"+channelGenesisHash+"/"+strconv.Itoa(latestBlockNum), &BlockResp{}, token) - result3 := resp3.Result().(*BlockResp) - Expect(result3.Status).Should(Equal(200)) - Expect(strconv.Atoi(result3.Number)).Should(Equal(latestBlockNum)) - Expect(len(result3.Transactions)).Should(Equal(1)) - - channelGenesisHash = result2.getGenesisHash("commonchannel") - latestBlockNum = result2.getBlockHeight("commonchannel") - 1 - Expect(len(channelGenesisHash)).ShouldNot(Equal(0)) - - resp3 = restGetWithToken("/api/block/"+channelGenesisHash+"/"+strconv.Itoa(latestBlockNum), &BlockResp{}, token) - result3 = resp3.Result().(*BlockResp) - Expect(result3.Status).Should(Equal(200)) - Expect(strconv.Atoi(result3.Number)).Should(Equal(latestBlockNum)) - Expect(len(result3.Transactions)).Should(Equal(1)) - }) - - It("get block info for org2", func() { - - token := restLogin("org2exploreradmin", "exploreradminpw", "org2-network") - - resp2 := restGetWithToken("/api/channels/info", &ChannelsInfoResp{}, token) - result2 := resp2.Result().(*ChannelsInfoResp) - - channelGenesisHash := result2.getGenesisHash("org2channel") - latestBlockNum := result2.getBlockHeight("org2channel") - 1 - Expect(len(channelGenesisHash)).ShouldNot(Equal(0)) - - resp3 := restGetWithToken("/api/block/"+channelGenesisHash+"/"+strconv.Itoa(latestBlockNum), &BlockResp{}, token) - result3 := resp3.Result().(*BlockResp) - Expect(result3.Status).Should(Equal(200)) - Expect(strconv.Atoi(result3.Number)).Should(Equal(latestBlockNum)) - Expect(len(result3.Transactions)).Should(Equal(1)) - - channelGenesisHash = result2.getGenesisHash("commonchannel") - latestBlockNum = result2.getBlockHeight("commonchannel") - 1 - Expect(len(channelGenesisHash)).ShouldNot(Equal(0)) - - resp3 = restGetWithToken("/api/block/"+channelGenesisHash+"/"+strconv.Itoa(latestBlockNum), &BlockResp{}, token) - result3 = resp3.Result().(*BlockResp) - Expect(result3.Status).Should(Equal(200)) - Expect(strconv.Atoi(result3.Number)).Should(Equal(latestBlockNum)) - Expect(len(result3.Transactions)).Should(Equal(1)) - }) - }) - - Context("/api/register", func() { - It("should work successfully with root admin user of org1", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin2", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser2", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - }) - - It("should work successfully with newly added admin user of org1", func() { - token := restLogin("testadmin1", "testadmin", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin3", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser3", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - }) - - It("should fail with newly added user of org1", func() { - token := restLogin("testuser1", "testuser", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin4", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't register user")) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser4", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't register user")) - }) - - It("should work successfully for org2 with user ID which has already been registered in org1", func() { - token := restLogin("org2exploreradmin", "exploreradminpw", "org2-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - }) - }) - - Context("/api/unregister", func() { - It("should work successfully with root admin user of org1", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testadmin1"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testuser1"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(200)) - }) - - It("should fail to unregister with user of org1", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser2", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - - token = restLogin("testuser1", "testuser", "org1-network") - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testuser2"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister user")) - }) - - It("should fail to unregister root admin or user which is logging in now", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - - token = restLogin("testadmin1", "testadmin", "org1-network") - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testadmin1"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister by yourself")) - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "org1exploreradmin"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister root admin user")) - }) - }) - - Context("/api/userlist", func() { - It("should work successfully with root admin user of org1", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin2", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin3", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser2", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser3", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - - token = restLogin("org2exploreradmin", "exploreradminpw", "org2-network") - - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin2", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin3", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin4", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser2", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser3", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser4", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - - resp = restGetWithToken("/api/userlist", &UserListResp{}, token) - resultUserList := resp.Result().(*UserListResp) - Expect(resultUserList.Status).Should(Equal(200)) - - list := []string{} - for _, val := range resultUserList.Message { - list = append(list, val.Username) - } - Expect(list).Should(HaveLen(9)) - Expect(list).Should(ContainElements([]string{ - "org2exploreradmin", - "testadmin1", - "testadmin2", - "testadmin3", - "testadmin4", - "testuser1", - "testuser2", - "testuser3", - "testuser4", - })) - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testadmin1"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testuser2"}, &RegisterResp{}, token) - - resp = restGetWithToken("/api/userlist", &UserListResp{}, token) - resultUserList = resp.Result().(*UserListResp) - Expect(resultUserList.Status).Should(Equal(200)) - - list = []string{} - for _, val := range resultUserList.Message { - list = append(list, val.Username) - } - Expect(list).Should(HaveLen(7)) - Expect(list).Should(ContainElements([]string{ - "org2exploreradmin", - "testadmin2", - "testadmin3", - "testadmin4", - "testuser1", - "testuser3", - "testuser4", - })) - - token = restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp = restGetWithToken("/api/userlist", &UserListResp{}, token) - resultUserList = resp.Result().(*UserListResp) - Expect(resultUserList.Status).Should(Equal(200)) - - list = []string{} - for _, val := range resultUserList.Message { - list = append(list, val.Username) - } - Expect(list).Should(HaveLen(7)) - Expect(list).Should(ContainElements([]string{ - "org1exploreradmin", - "testadmin1", - "testadmin2", - "testadmin3", - "testuser1", - "testuser2", - "testuser3", - })) - - }) - - It("should fail to unregister with user of org1", func() { - token := restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testuser1", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - resp = restPostWithToken("/api/register", map[string]interface{}{"user": "testuser2", "password": "testuser", "roles": "user"}, &RegisterResp{}, token) - - token = restLogin("testuser1", "testuser", "org1-network") - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testuser2"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister user")) - }) - - It("should fail to unregister root admin or user which is logging in now", func() { - token = restLogin("org1exploreradmin", "exploreradminpw", "org1-network") - - resp := restPostWithToken("/api/register", map[string]interface{}{"user": "testadmin1", "password": "testadmin", "roles": "admin"}, &RegisterResp{}, token) - - token = restLogin("testadmin1", "testadmin", "org1-network") - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "testadmin1"}, &RegisterResp{}, token) - resultRegister := resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister by yourself")) - - resp = restPostWithToken("/api/unregister", map[string]interface{}{"user": "org1exploreradmin"}, &RegisterResp{}, token) - resultRegister = resp.Result().(*RegisterResp) - Expect(resultRegister.Status).Should(Equal(400)) - Expect(resultRegister.Message).Should(Equal("Error: Permission error : can't unregister root admin user")) - }) - }) - - // It("get status of peers within org2channel", func() { - // resp := restGetWithToken("/api/peersStatus/"+"org2channel", &PeersStatusResp{}, token) - // result := resp.Result().(*PeersStatusResp) - // Expect(result.Status).Should(Equal(200)) - // }) - - // It("get block activity", func() { - // resp := restGetWithToken("/api/blockActivity/"+channelGenesisHash, &BlockActivityResp{}, token) - // result := resp.Result().(*BlockActivityResp) - // Expect(result.Status).Should(Equal(200)) - // Expect(result.Row[0].Channelname).Should(Equal("org2channel")) - // org2CurrentBlockNum = result.Row[0].Blocknum - // }) - - // It("Update block on org1channel and should not have any changes on org2channel", func() { - // resp := restGetWithToken("/blockActivity/"+channelGenesisHash,& - // action = "invoke" - // inputSpecPath = "apitest-input-multiprofile-invoke-org1.yml" - // err := testclient.Testclient(action, inputSpecPath) - // Expect(err).NotTo(HaveOccurred()) - - // resp := restGetWithToken("/api/blockActivity/"+channelGenesisHash, &BlockActivityResp{}, token) - // result := resp.Result().(*BlockActivityResp) - // Expect(result.Status).Should(Equal(200)) - // Expect(result.Row[0].Channelname).Should(Equal("org2channel")) - // Expect(result.Row[0].Blocknum).Should(Equal(org2CurrentBlockNum)) - // }) - - // It("Update block on org2channel and should have some changes on org2channel", func() { - // action = "invoke" - // inputSpecPath = "apitest-input-multiprofile-invoke-org2.yml" - // err := testclient.Testclient(action, inputSpecPath) - // Expect(err).NotTo(HaveOccurred()) - - // resp := restGetWithToken("/api/blockActivity/"+channelGenesisHash, &BlockActivityResp{}, token) - // result := resp.Result().(*BlockActivityResp) - // Expect(result.Status).Should(Equal(200)) - // Expect(result.Row[0].Channelname).Should(Equal("org2channel")) - // Expect(result.Row[0].Blocknum).Should(Equal(org2CurrentBlockNum + 1)) - // }) - - // XIt("register user", func() { - // resp := restPostWithToken("/api/register", map[string]interface{}{"user": "test", "password": "test", "affiliation": "department2", "role": "admin"}, &RegisterResp{}, token) - // resultRegister := resp.Result().(*RegisterResp) - // Expect(resultRegister.Status).Should(Equal(200)) - // }) - - // XIt("login with newly registered user", func() { - // resp := restPost("/auth/login", map[string]interface{}{"user": "test", "password": "test", "network": "org2-network"}, &LoginResponse{}) - // resultLogin := resp.Result().(*LoginResponse) - - // Expect(resultLogin.User.Message).Should(Equal("logged in")) - // Expect(resultLogin.User.Name).Should(Equal("test")) - // }) - - // XIt("fail to register duplicate user", func() { - // resp := restPostWithToken("/api/register", map[string]interface{}{"user": "test", "password": "test", "affiliation": "department2", "role": "admin"}, &RegisterResp{}, token) - // resultRegister := resp.Result().(*RegisterResp) - // Expect(resultRegister.Status).Should(Equal(400)) - // Expect(resultRegister.Message).Should(Equal("Error: already exists")) - // }) - - It("stop explorer", func() { - _, err := networkclient.ExecuteCommand("bash", []string{"./stopexplorer.sh"}, true) - Expect(err).NotTo(HaveOccurred()) - }) - - It("Shutdown network", func() { - cleanupContainers(networkSpecPath) - }) }) - }) diff --git a/app/platform/fabric/e2e-test/specs/apitest_utils_test.go b/app/platform/fabric/e2e-test/specs/apitest_utils_test.go index a0bf2e923..6a2ff8274 100644 --- a/app/platform/fabric/e2e-test/specs/apitest_utils_test.go +++ b/app/platform/fabric/e2e-test/specs/apitest_utils_test.go @@ -19,7 +19,7 @@ func findKeywordInConsoleLog(keyword string) bool { cwd, _ := os.Getwd() os.Chdir(relativePahtToRoot) defer os.Chdir(cwd) - arg := fmt.Sprintf(`cat logs/console/console.log | grep "%s" | wc -l`, keyword) + arg := fmt.Sprintf(`docker logs explorer.mynetwork.com 2>&1 | grep "%s" | wc -l`, keyword) cmd := exec.Command("sh", "-c", arg) result, err := cmd.Output() if err != nil { diff --git a/app/platform/fabric/e2e-test/specs/runexplorer.sh b/app/platform/fabric/e2e-test/specs/runexplorer.sh index 6bfc67387..3c5c007ad 100755 --- a/app/platform/fabric/e2e-test/specs/runexplorer.sh +++ b/app/platform/fabric/e2e-test/specs/runexplorer.sh @@ -27,31 +27,31 @@ DELAY=10 pushd ${SCRIPTPATH}/.. -cp ./configs/config_${NETWORK_MODE}.json ${ROOTPATH}/app/platform/fabric/config.json +# cp ./configs/config_${NETWORK_MODE}.json ${ROOTPATH}/app/platform/fabric/config.json if [ ${NETWORK_MODE} == "single-pem" ]; then tmpf=$(mktemp) - cat specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk | \ + cat ${ROOTPATH}/test/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk | \ awk '{printf "%s\\n",$0} END {print ""}' | \ - xargs -0 -I{} jq '.organizations.org1.adminPrivateKey.pem = "{}"' configs/connection-profile/org1-network-pem.json \ + xargs -0 -I{} jq '.organizations.org1.adminPrivateKey.pem = "{}"' ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json \ > "$tmpf" - mv -f "$tmpf" configs/connection-profile/org1-network-pem.json + mv -f "$tmpf" ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json - cat specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem | \ + cat ${ROOTPATH}/test/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem | \ awk '{printf "%s\\n",$0} END {print ""}' | \ - xargs -0 -I{} jq '.organizations.org1.signedCert.pem = "{}"' configs/connection-profile/org1-network-pem.json \ + xargs -0 -I{} jq '.organizations.org1.signedCert.pem = "{}"' ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json \ > "$tmpf" - mv -f "$tmpf" configs/connection-profile/org1-network-pem.json + mv -f "$tmpf" ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json - cat specs/crypto-config/peerOrganizations/org1/peers/peer0-org1.org1/tls/ca.crt | \ + cat ${ROOTPATH}/test/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt | \ awk '{printf "%s\\n",$0} END {print ""}' | \ - xargs -0 -I{} jq '.peers."peer0-org1".tlsCACerts.pem = "{}"' configs/connection-profile/org1-network-pem.json \ + xargs -0 -I{} jq '.peers."peer0.org1.example.com".tlsCACerts.pem = "{}"' ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json \ > "$tmpf" - mv -f "$tmpf" configs/connection-profile/org1-network-pem.json + mv -f "$tmpf" ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json - jq '.client.adminCredential.id = "exploreradmin2"' configs/connection-profile/org1-network-pem.json \ + jq '.client.adminCredential.id = "exploreradmin2"' ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json \ > "$tmpf" - mv -f "$tmpf" configs/connection-profile/org1-network-pem.json + mv -f "$tmpf" ${ROOTPATH}/test/api/connection-profile/org1-network-pem.json fi popd @@ -59,9 +59,9 @@ popd pushd ${ROOTPATH} if [ $CLEANUP -eq 1 ]; then - ./build_docker_image.sh -d - docker-compose -f ./app/platform/fabric/e2e-test/docker-compose.yaml down -v - docker-compose -f ./app/platform/fabric/e2e-test/docker-compose.yaml up -d explorerdb.mynetwork.com + # ./build_docker_image.sh + docker-compose down -v + docker-compose up -d explorerdb.mynetwork.com echo "#### Starting DB container ..." rc=1 @@ -77,12 +77,19 @@ if [ $CLEANUP -eq 1 ]; then done echo "#### Started DB container" - rm -rf logs wallet + # rm -rf logs wallet fi # export LOG_LEVEL_CONSOLE=debug +export EXPLORER_CONFIG_FILE_PATH=${ROOTPATH}/test/api/config_${NETWORK_MODE}.json +export EXPLORER_PROFILE_DIR_PATH=${ROOTPATH}/test/api/connection-profile +export FABRIC_CRYPTO_PATH=${ROOTPATH}/test/fabric-samples/test-network/organizations export EXPLORER_SYNC_BLOCKSYNCTIME_SEC=5 -npm start + +pushd ${ROOTPATH} +docker-compose up -d +popd + echo "#### Starting Explorer process ..." rc=1 @@ -92,7 +99,7 @@ while do sleep $DELAY set -x - cat logs/console/console.log 2>/dev/null | grep -q "Please open web browser to access" + docker logs explorer.mynetwork.com 2>&1 | grep -q "Please open web browser to access" rc=$? set +x done diff --git a/app/platform/fabric/e2e-test/specs/stopexplorer.sh b/app/platform/fabric/e2e-test/specs/stopexplorer.sh index d8a2fa0a6..a6812e1cd 100755 --- a/app/platform/fabric/e2e-test/specs/stopexplorer.sh +++ b/app/platform/fabric/e2e-test/specs/stopexplorer.sh @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 -SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ROOTPATH="$( cd "$(dirname "$0")/../../../../.." >/dev/null 2>&1 ; pwd -P )" CLEANUP=1 @@ -17,10 +16,10 @@ done pushd ${ROOTPATH} -npm run app-stop if [ $CLEANUP -eq 1 ]; then - docker-compose -f ./app/platform/fabric/e2e-test/docker-compose.yaml down -v - rm -rf wallet/ logs/ + docker-compose down -v +else + docker-compose down fi popd \ No newline at end of file diff --git a/app/platform/fabric/gateway/FabricGateway.ts b/app/platform/fabric/gateway/FabricGateway.ts index 78f64c422..49251c0b7 100644 --- a/app/platform/fabric/gateway/FabricGateway.ts +++ b/app/platform/fabric/gateway/FabricGateway.ts @@ -105,6 +105,7 @@ export class FabricGateway { signedCertPem, adminPrivateKeyPem ); + logger.info('1'); } if (!this.tlsEnable) { @@ -112,11 +113,13 @@ export class FabricGateway { } else { Client.setConfigSetting('discovery-protocol', 'grpcs'); } + logger.info('2'); // Set connection options; identity and wallet this.asLocalhost = String(Client.getConfigSetting('discovery-as-localhost', 'true')) === 'true'; + logger.info('3'); const connectionOptions = { identity: explorerAdminId, @@ -127,6 +130,7 @@ export class FabricGateway { }, clientTlsIdentity: '' }; + logger.info('4', connectionOptions); const mTlsIdLabel = this.fabricConfig.getClientTlsIdentity(); if (mTlsIdLabel) { @@ -140,6 +144,7 @@ export class FabricGateway { ); } } + logger.info('5', this.config); // Connect to gateway await this.gateway.connect(this.config, connectionOptions); @@ -433,25 +438,22 @@ export class FabricGateway { this.waitingResp = true; logger.info('Sending discovery request...'); await this.ds - .send({ - asLocalhost: this.asLocalhost, - requestTimeout: 5000, - refreshAge: 15000, - targets: this.dsTargets, - }) - .then(() => { - logger.info('Succeeded to send discovery request'); - }) - .catch(error => { - if (error) { - logger.warn( - 'Failed to send discovery request for channel', - error, - ); - this.waitingResp = false; - this.ds.close(); - } - }); + .send({ + asLocalhost: this.asLocalhost, + requestTimeout: 5000, + refreshAge: 15000, + targets: this.dsTargets + }) + .then(() => { + logger.info('Succeeded to send discovery request'); + }) + .catch(error => { + if (error) { + logger.warn('Failed to send discovery request for channel', error); + this.waitingResp = false; + this.ds.close(); + } + }); } else { logger.info('Have already been sending a request'); return null; diff --git a/ci/azure-pipelines-release.yml b/ci/azure-pipelines-release.yml index 72cd307b0..799f7ad7c 100644 --- a/ci/azure-pipelines-release.yml +++ b/ci/azure-pipelines-release.yml @@ -15,7 +15,7 @@ variables: jobs: - job: Release pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 steps: - script: docker login --username=$(DockerHub-Username) --password=$(DockerHub-Password) displayName: Login to Docker diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 6e58f6239..7bccc7e69 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -9,13 +9,13 @@ pr: variables: GOPATH: $(Agent.BuildDirectory)/go PATH: $(Agent.BuildDirectory)/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin - GO_VER: 1.13.8 - NODE_VER: 10.19 + GO_VER: 1.16.4 + NODE_VER: 12.13 jobs: - job: TestsWithCoverage pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 steps: - template: install_deps.yml @@ -39,47 +39,13 @@ jobs: summaryFileLocation: $(System.DefaultWorkingDirectory)/client/coverage.xml pathToSources: $(System.DefaultWorkingDirectory)/client -- job: SanityChecks_v1_4 +- job: SanityChecks pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 steps: - template: install_deps.yml - checkout: self - script: | npm install - npm run e2e-api-test-v1 + npm run e2e-api-test displayName: Run Sanity Checks for v1.4 - -- job: SanityChecks_v2_1 - pool: - vmImage: ubuntu-16.04 - steps: - - template: install_deps.yml - - checkout: self - - script: | - npm install - npm run e2e-api-test-v2 - displayName: Run Sanity Checks for v2.1 - -- job: GUITests_v1_4 - pool: - vmImage: ubuntu-16.04 - steps: - - template: install_deps.yml - - checkout: self - - script: | - npm install - npm run e2e-gui-test-v1 - displayName: Run GUI Tests for v1.4 - -- job: GUITests_v2_1 - pool: - vmImage: ubuntu-16.04 - steps: - - template: install_deps.yml - - checkout: self - - script: | - npm install - npm run e2e-gui-test-v2 - displayName: Run GUI Tests for v2.1 - \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 9478ca1c9..25f14457c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,7 @@ volumes: networks: mynetwork.com: external: - name: net_test + name: fabric_test services: @@ -40,15 +40,15 @@ services: - DATABASE_DATABASE=fabricexplorer - DATABASE_USERNAME=hppoc - DATABASE_PASSWD=password - - LOG_LEVEL_APP=debug - - LOG_LEVEL_DB=debug - - LOG_LEVEL_CONSOLE=info + - LOG_LEVEL_APP=info + - LOG_LEVEL_DB=info + - LOG_LEVEL_CONSOLE=debug - LOG_CONSOLE_STDOUT=true - DISCOVERY_AS_LOCALHOST=false volumes: - - ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json - - ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile - - /fabric-path/fabric-samples/test-network/organizations:/tmp/crypto + - ${EXPLORER_CONFIG_FILE_PATH}:/opt/explorer/app/platform/fabric/config.json + - ${EXPLORER_PROFILE_DIR_PATH}:/opt/explorer/app/platform/fabric/connection-profile + - ${FABRIC_CRYPTO_PATH}:/tmp/crypto - walletstore:/opt/explorer/wallet ports: - 8080:8080 diff --git a/package.json b/package.json index e4817fcce..b231f727d 100644 --- a/package.json +++ b/package.json @@ -119,11 +119,9 @@ "linter": "eslint", "lint:fix": "eslint . --fix", "precommit": "lint-staged && ./scripts/verify-license.sh", - "e2e-test-build-src": "npm install; cd client; npm install; npm run build", - "e2e-api-test-v1-run": "cd app/platform/fabric/e2e-test; ./runTestSuite.sh -1", - "e2e-api-test-v2-run": "cd app/platform/fabric/e2e-test; ./runTestSuite.sh -2", - "e2e-api-test-v1": "run-s e2e-test-build-src e2e-api-test-v1-run", - "e2e-api-test-v2": "run-s e2e-test-build-src e2e-api-test-v2-run", + "e2e-test-build-img": "./build_docker_image.sh", + "e2e-api-test-run": "cd app/platform/fabric/e2e-test; ./runTestSuite.sh", + "e2e-api-test": "run-s e2e-test-build-img e2e-api-test-run", "e2e-gui-test-v1-run": "cd client/e2e-test; ./gui-e2e-test-start.sh -1", "e2e-gui-test-v2-run": "cd client/e2e-test; ./gui-e2e-test-start.sh -2", "e2e-gui-test-v1": "run-s e2e-test-build-src e2e-gui-test-v1-run", diff --git a/scripts/verify-license.sh b/scripts/verify-license.sh index 02020dd96..8ed2a3349 100755 --- a/scripts/verify-license.sh +++ b/scripts/verify-license.sh @@ -35,7 +35,7 @@ else fi # If you want to exclude some paths, add a keyword with an extended regular expression format to excluded_paths -excluded_paths="\.ico$ \.jpg$ \.json$ \.png$ \.svg$ \.tx$ \.crt$ \.ya*ml$ \.key$ \.pem$ _sk$ \/META-INF\/ LICENSE$ \.xml$ CHANGELOG\.md$ app/platform/fabric/e2e-test go\.sum$ \.opts$" +excluded_paths="\.ico$ \.jpg$ \.json$ \.png$ \.svg$ \.tx$ \.crt$ \.ya*ml$ \.key$ \.pem$ _sk$ \/META-INF\/ LICENSE$ \.xml$ CHANGELOG\.md$ app/platform/fabric/e2e-test go\.sum$ \.opts$ \.env$" for check_file in ${check_files}; do @@ -74,4 +74,4 @@ if [[ ${retval} -ne 0 ]]; then echo -e "\t--------------------------------------" fi -exit ${retval} \ No newline at end of file +exit ${retval} diff --git a/test/api/config.json b/test/api/config.json new file mode 100644 index 000000000..f99d37b59 --- /dev/null +++ b/test/api/config.json @@ -0,0 +1,9 @@ +{ + "network-configs": { + "test-network": { + "name": "Test Network", + "profile": "./connection-profile/test-network.json" + } + }, + "license": "Apache-2.0" +} diff --git a/app/platform/fabric/e2e-test/configs/config_multi.json b/test/api/config_multi.json similarity index 52% rename from app/platform/fabric/e2e-test/configs/config_multi.json rename to test/api/config_multi.json index ceb8cfbb8..3b9a7123d 100644 --- a/app/platform/fabric/e2e-test/configs/config_multi.json +++ b/test/api/config_multi.json @@ -2,11 +2,11 @@ "network-configs": { "org1-network": { "name": "org1 network", - "profile": "./e2e-test/configs/connection-profile/org1-network.json" + "profile": "./connection-profile/org1-network.json" }, "org2-network": { "name": "org2 network", - "profile": "./e2e-test/configs/connection-profile/org2-network.json" + "profile": "./connection-profile/org2-network.json" } }, "license": "Apache-2.0" diff --git a/app/platform/fabric/e2e-test/configs/config_single-disable-auth.json b/test/api/config_single-disable-auth.json similarity index 55% rename from app/platform/fabric/e2e-test/configs/config_single-disable-auth.json rename to test/api/config_single-disable-auth.json index 2eac92ad8..e8304fecf 100644 --- a/app/platform/fabric/e2e-test/configs/config_single-disable-auth.json +++ b/test/api/config_single-disable-auth.json @@ -2,7 +2,7 @@ "network-configs": { "org1-network": { "name": "org1-network", - "profile": "./e2e-test/configs/connection-profile/org1-network-disable-auth.json" + "profile": "./connection-profile/org1-network-disable-auth.json" } }, "license": "Apache-2.0" diff --git a/app/platform/fabric/e2e-test/configs/config_single-pem.json b/test/api/config_single-pem.json similarity index 58% rename from app/platform/fabric/e2e-test/configs/config_single-pem.json rename to test/api/config_single-pem.json index 4bb12f8db..3be447963 100644 --- a/app/platform/fabric/e2e-test/configs/config_single-pem.json +++ b/test/api/config_single-pem.json @@ -2,7 +2,7 @@ "network-configs": { "org1-network": { "name": "org1-network", - "profile": "./e2e-test/configs/connection-profile/org1-network-pem.json" + "profile": "./connection-profile/org1-network-pem.json" } }, "license": "Apache-2.0" diff --git a/app/platform/fabric/e2e-test/configs/config_single.json b/test/api/config_single.json similarity index 59% rename from app/platform/fabric/e2e-test/configs/config_single.json rename to test/api/config_single.json index 54fd463c2..100f8a03b 100644 --- a/app/platform/fabric/e2e-test/configs/config_single.json +++ b/test/api/config_single.json @@ -2,7 +2,7 @@ "network-configs": { "org1-network": { "name": "org1-network", - "profile": "./e2e-test/configs/connection-profile/org1-network.json" + "profile": "./connection-profile/org1-network.json" } }, "license": "Apache-2.0" diff --git a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network-disable-auth.json b/test/api/connection-profile/org1-network-disable-auth.json similarity index 53% rename from app/platform/fabric/e2e-test/configs/connection-profile/org1-network-disable-auth.json rename to test/api/connection-profile/org1-network-disable-auth.json index a29e0cdbe..cf9ea752f 100644 --- a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network-disable-auth.json +++ b/test/api/connection-profile/org1-network-disable-auth.json @@ -19,9 +19,9 @@ } }, "channels": { - "commonchannel": { + "org1channel": { "peers": { - "peer0-org1": {} + "peer0.org1.example.com": {} }, "connection": { "timeout": { @@ -36,24 +36,24 @@ }, "organizations": { "org1": { - "mspid": "Org1ExampleCom", + "mspid": "Org1MSP", "adminPrivateKey": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk" }, - "peers": ["peer0-org1"], + "peers": ["peer0.org1.example.com"], "signedCert": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem" } } }, "peers": { - "peer0-org1": { + "peer0.org1.example.com": { "tlsCACerts": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/peers/peer0-org1.org1/tls/ca.crt" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" }, - "url": "grpcs://localhost:31000", + "url": "grpcs://peer0.org1.example.com:7051", "grpcOptions": { - "ssl-target-name-override": "peer0-org1" + "ssl-target-name-override": "peer0.org1.example.com" } } } diff --git a/test/api/connection-profile/org1-network-pem.json b/test/api/connection-profile/org1-network-pem.json new file mode 100644 index 000000000..fd5416aee --- /dev/null +++ b/test/api/connection-profile/org1-network-pem.json @@ -0,0 +1,61 @@ +{ + "name": "org1-network", + "version": "1.0.0", + "license": "Apache-2.0", + "client": { + "tlsEnable": true, + "adminCredential": { + "id": "exploreradmin2", + "password": "exploreradminpw" + }, + "enableAuthentication": true, + "organization": "org1", + "connection": { + "timeout": { + "peer": { + "endorser": "300" + }, + "orderer": "300" + } + } + }, + "channels": { + "org1channel": { + "peers": { + "peer0.org1.example.com": {} + }, + "connection": { + "timeout": { + "peer": { + "endorser": "6000", + "eventHub": "6000", + "eventReg": "6000" + } + } + } + } + }, + "organizations": { + "org1": { + "mspid": "Org1MSP", + "peers": ["peer0.org1.example.com"], + "adminPrivateKey": { + "pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgfY78v+PrAbIElZp3\nHFFHKHYbn9Fle6swBpees8Q9fyihRANCAAQYTOQvmQLXWd8xIi/EokFZScm+vzsx\nCFL0+/vn9bZ0Npb0Bya8SsOY6qoEHxSqh6yO/Fl3gSITdpkAnY+++hh8\n-----END PRIVATE KEY-----\n\n" + }, + "signedCert": { + "pem": "-----BEGIN CERTIFICATE-----\nMIICojCCAkmgAwIBAgIUcvuDlmqTv/tPo4X9+b4fVwBfewgwCgYIKoZIzj0EAwIw\ncDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH\nEwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMjExMjE4MTIyNzAwWhcNMjIxMjE4MTIzMjAw\nWjBgMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExFDASBgNV\nBAoTC0h5cGVybGVkZ2VyMQ4wDAYDVQQLEwVhZG1pbjESMBAGA1UEAxMJb3JnMWFk\nbWluMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEGEzkL5kC11nfMSIvxKJBWUnJ\nvr87MQhS9Pv75/W2dDaW9AcmvErDmOqqBB8UqoesjvxZd4EiE3aZAJ2PvvoYfKOB\n0DCBzTAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQU52GM\nWlX+KKoktAfGLz1aJKlNQYAwHwYDVR0jBBgwFoAUnKdufyeGWRi+m8vpggQsEcE3\n6UMwEAYDVR0RBAkwB4IFYXBwbGUwWwYIKgMEBQYHCAEET3siYXR0cnMiOnsiaGYu\nQWZmaWxpYXRpb24iOiIiLCJoZi5FbnJvbGxtZW50SUQiOiJvcmcxYWRtaW4iLCJo\nZi5UeXBlIjoiYWRtaW4ifX0wCgYIKoZIzj0EAwIDRwAwRAIgRpSfXWrVkXsFxEOp\nR22mRwNT5SZ+KEXfimlbJdgwu4cCID8z6WSXz31B1fcw2/R2kptazF1auzgr480T\nKYP8CLpc\n-----END CERTIFICATE-----\n\n" + } + } + }, + "peers": { + "peer0.org1.example.com": { + "url": "grpcs://peer0.org1.example.com:7051", + "grpcOptions": { + "ssl-target-name-override": "peer0.org1.example.com" + }, + "tlsCACerts": { + "pem": "-----BEGIN CERTIFICATE-----\nMIICJjCCAc2gAwIBAgIUAMnQSSlA+GIJL27ACagF9x23ItgwCgYIKoZIzj0EAwIw\ncDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH\nEwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMjExMjE4MTIyNzAwWhcNMzYxMjE0MTIyNzAw\nWjBwMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExDzANBgNV\nBAcTBkR1cmhhbTEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMT\nY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABG+z\nfz9hKBb3NoPcbD0hO93S5ZqUWC8UQgCdTHw+GZA/6BwXA2Z55NC6lFwP5hGvR/t1\ncJ6JREI/wyrnQuMNwHSjRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG\nAQH/AgEBMB0GA1UdDgQWBBScp25/J4ZZGL6by+mCBCwRwTfpQzAKBggqhkjOPQQD\nAgNHADBEAiBTree/qfej9NXCyuq0D6SoBJRU01yJVoXcpXEVZQU8MgIgfoJi6Kfy\nAVbM9gfFBsCrQD3eWfTBQ+NyLY26JKA+Ibo=\n-----END CERTIFICATE-----\n\n" + } + } + } +} diff --git a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network.json b/test/api/connection-profile/org1-network.json similarity index 57% rename from app/platform/fabric/e2e-test/configs/connection-profile/org1-network.json rename to test/api/connection-profile/org1-network.json index 86fffd531..7ffc2bd96 100644 --- a/app/platform/fabric/e2e-test/configs/connection-profile/org1-network.json +++ b/test/api/connection-profile/org1-network.json @@ -26,9 +26,9 @@ } }, "channels": { - "commonchannel": { + "org1channel": { "peers": { - "peer0-org1": {} + "peer0.org1.example.com": {} }, "connection": { "timeout": { @@ -43,38 +43,38 @@ }, "organizations": { "org1": { - "mspid": "Org1ExampleCom", + "mspid": "Org1MSP", "adminPrivateKey": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk" }, - "peers": ["peer0-org1"], + "peers": ["peer0.org1.example.com"], "certificateAuthorities": ["ca0"], "signedCert": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem" } } }, "peers": { - "peer0-org1": { + "peer0.org1.example.com": { "tlsCACerts": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/peers/peer0-org1.org1/tls/ca.crt" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" }, - "url": "grpcs://localhost:31000", + "url": "grpcs://peer0.org1.example.com:7051", "grpcOptions": { - "ssl-target-name-override": "peer0-org1" + "ssl-target-name-override": "peer0.org1.example.com" } } }, "certificateAuthorities": { "ca0": { - "url": "https://localhost:32000", + "url": "https://ca_org1:7054", "httpOptions": { "verify": false }, "tlsCACerts": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org1/ca/ca.org1-cert.pem" + "path": "/tmp/crypto/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem" }, - "caName": "ca0-org1" + "caName": "ca_org1" } } } diff --git a/app/platform/fabric/e2e-test/configs/connection-profile/org2-network.json b/test/api/connection-profile/org2-network.json similarity index 56% rename from app/platform/fabric/e2e-test/configs/connection-profile/org2-network.json rename to test/api/connection-profile/org2-network.json index e238a8b31..3060a643b 100644 --- a/app/platform/fabric/e2e-test/configs/connection-profile/org2-network.json +++ b/test/api/connection-profile/org2-network.json @@ -25,9 +25,9 @@ } }, "channels": { - "commonchannel": { + "org2channel": { "peers": { - "peer0-org2": {} + "peer0.org2.example.com": {} }, "connection": { "timeout": { @@ -42,38 +42,38 @@ }, "organizations": { "org2": { - "mspid": "Org2ExampleCom", + "mspid": "Org2MSP", "adminPrivateKey": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org2/users/Admin@org2/msp/keystore/priv_sk" + "path": "/tmp/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/priv_sk" }, - "peers": ["peer0-org2"], + "peers": ["peer0.org2.example.com"], "certificateAuthorities": ["ca0"], "signedCert": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org2/users/Admin@org2/msp/signcerts/Admin@org2-cert.pem" + "path": "/tmp/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/cert.pem" } } }, "peers": { - "peer0-org2": { + "peer0.org2.example.com": { "tlsCACerts": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org2/peers/peer0-org2.org2/tls/ca.crt" + "path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" }, - "url": "grpcs://localhost:31001", + "url": "grpcs://peer0.org2.example.com:9051", "grpcOptions": { - "ssl-target-name-override": "peer0-org2" + "ssl-target-name-override": "peer0.org2.example.com" } } }, "certificateAuthorities": { "ca0": { - "url": "https://localhost:32001", + "url": "https://ca_org2:8054", "httpOptions": { "verify": false }, "tlsCACerts": { - "path": "./app/platform/fabric/e2e-test/specs/crypto-config/peerOrganizations/org2/ca/ca.org2-cert.pem" + "path": "/tmp/crypto/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem" }, - "caName": "ca0-org2" + "caName": "ca_org2" } } } diff --git a/test/api/connection-profile/test-network-ca.json b/test/api/connection-profile/test-network-ca.json new file mode 100644 index 000000000..f92e12652 --- /dev/null +++ b/test/api/connection-profile/test-network-ca.json @@ -0,0 +1,69 @@ +{ + "name": "test-network", + "version": "1.0.0", + "client": { + "tlsEnable": true, + "adminCredential": { + "id": "exploreradmin", + "password": "exploreradminpw", + "affiliation": "org1.department1" + }, + "caCredential": { + "id": "admin", + "password": "adminpw" + }, + "enableAuthentication": true, + "organization": "Org1MSP", + "connection": { + "timeout": { + "peer": { + "endorser": "300" + }, + "orderer": "300" + } + } + }, + "channels": { + "mychannel": { + "peers": { + "peer0.org1.example.com": {} + }, + "connection": { + "timeout": { + "peer": { + "endorser": "6000", + "eventHub": "6000", + "eventReg": "6000" + } + } + } + } + }, + "organizations": { + "Org1MSP": { + "mspid": "Org1MSP", + "peers": ["peer0.org1.example.com"], + "certificateAuthorities": ["ca0"] + } + }, + "peers": { + "peer0.org1.example.com": { + "tlsCACerts": { + "path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" + }, + "url": "grpcs://peer0.org1.example.com:7051" + } + }, + "certificateAuthorities": { + "ca0": { + "url": "https://ca_org1:7054", + "httpOptions": { + "verify": false + }, + "tlsCACerts": { + "path": "/tmp/crypto/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem" + }, + "caName": "ca0-org1" + } + } +} diff --git a/test/api/connection-profile/test-network.json b/test/api/connection-profile/test-network.json new file mode 100644 index 000000000..44eb3dc93 --- /dev/null +++ b/test/api/connection-profile/test-network.json @@ -0,0 +1,48 @@ +{ + "name": "test-network", + "version": "1.0.0", + "client": { + "tlsEnable": true, + "adminCredential": { + "id": "exploreradmin", + "password": "exploreradminpw" + }, + "enableAuthentication": true, + "organization": "Org1MSP", + "connection": { + "timeout": { + "peer": { + "endorser": "300" + }, + "orderer": "300" + } + } + }, + "channels": { + "mychannel": { + "peers": { + "peer0.org1.example.com": {} + } + } + }, + "organizations": { + "Org1MSP": { + "mspid": "Org1MSP", + "adminPrivateKey": { + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk" + }, + "peers": ["peer0.org1.example.com"], + "signedCert": { + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem" + } + } + }, + "peers": { + "peer0.org1.example.com": { + "tlsCACerts": { + "path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" + }, + "url": "grpcs://peer0.org1.example.com:7051" + } + } +}