From 43178c9da75cbcee4af61f27abae5f24648353c0 Mon Sep 17 00:00:00 2001 From: YoungHypo Date: Wed, 28 Aug 2024 17:45:11 +0800 Subject: [PATCH] change all label to v2.5.9;modify postman test.json;print command in cryptogen Signed-off-by: YoungHypo --- .gitignore | 4 + .../api/lib/configtxgen/configtxgen.py | 2 +- .../api/lib/configtxlator/configtxlator.py | 2 +- src/api-engine/api/lib/peer/chaincode.py | 2 +- src/api-engine/api/lib/peer/channel.py | 2 +- .../api/lib/pki/cryptogen/cryptogen.py | 31 +- src/api-engine/api/routes/chaincode/views.py | 18 +- src/api-engine/api/routes/channel/views.py | 8 +- tests/postman/Makefile | 2 +- tests/postman/env.json.tmpl | 16 +- tests/postman/test/test.json | 606 ++++-------------- 11 files changed, 175 insertions(+), 518 deletions(-) diff --git a/.gitignore b/.gitignore index d870dfec1..7bee34dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -252,3 +252,7 @@ src/dashboard/lambda/mock/index.js # Local Netlify folder .netlify deno.lock + +# test postman +tests/postman/env.json +tests/postman/junitResult.xml \ No newline at end of file diff --git a/src/api-engine/api/lib/configtxgen/configtxgen.py b/src/api-engine/api/lib/configtxgen/configtxgen.py index 4cd92e198..f67ca6680 100644 --- a/src/api-engine/api/lib/configtxgen/configtxgen.py +++ b/src/api-engine/api/lib/configtxgen/configtxgen.py @@ -8,7 +8,7 @@ class ConfigTxGen: """Class represents cryptotxgen.""" - def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version="2.2.0"): + def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version="2.5.9"): """init CryptoGen param: network: network's name diff --git a/src/api-engine/api/lib/configtxlator/configtxlator.py b/src/api-engine/api/lib/configtxlator/configtxlator.py index 1c90b2e1a..dde841623 100644 --- a/src/api-engine/api/lib/configtxlator/configtxlator.py +++ b/src/api-engine/api/lib/configtxlator/configtxlator.py @@ -10,7 +10,7 @@ class ConfigTxLator: Class represents configtxlator CLI. """ - def __init__(self, configtxlator=FABRIC_TOOL, version="2.2.0"): + def __init__(self, configtxlator=FABRIC_TOOL, version="2.5.9"): self.configtxlator = configtxlator + "/configtxlator" self.version = version diff --git a/src/api-engine/api/lib/peer/chaincode.py b/src/api-engine/api/lib/peer/chaincode.py index 103a05492..45e48c734 100644 --- a/src/api-engine/api/lib/peer/chaincode.py +++ b/src/api-engine/api/lib/peer/chaincode.py @@ -9,7 +9,7 @@ class ChainCode(Command): - def __init__(self, version="2.2.0", peer=FABRIC_TOOL, **kwargs): + def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs): self.peer = peer + "/peer" super(ChainCode, self).__init__(version, **kwargs) diff --git a/src/api-engine/api/lib/peer/channel.py b/src/api-engine/api/lib/peer/channel.py index 640a453e5..46fa80fd1 100644 --- a/src/api-engine/api/lib/peer/channel.py +++ b/src/api-engine/api/lib/peer/channel.py @@ -11,7 +11,7 @@ class Channel(Command): """Call CMD to perform channel create, join and other related operations""" - def __init__(self, version="2.2.0", peer=FABRIC_TOOL, **kwargs): + def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs): self.peer = peer + "/peer" super(Channel, self).__init__(version, **kwargs) diff --git a/src/api-engine/api/lib/pki/cryptogen/cryptogen.py b/src/api-engine/api/lib/pki/cryptogen/cryptogen.py index 1d11d581b..2419f7d15 100644 --- a/src/api-engine/api/lib/pki/cryptogen/cryptogen.py +++ b/src/api-engine/api/lib/pki/cryptogen/cryptogen.py @@ -4,11 +4,14 @@ from subprocess import call from api.config import CELLO_HOME, FABRIC_TOOL +import logging +LOG = logging.getLogger(__name__) + class CryptoGen: """Class represents crypto-config tool.""" - def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.2.0"): + def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.5.9"): """init CryptoGen param: name: organization's name @@ -30,8 +33,17 @@ def generate(self, output="crypto-config", config="crypto-config.yaml"): return: """ try: - call([self.cryptogen, "generate", "--output={}/{}/{}".format(self.filepath, self.name, output), - "--config={}/{}/{}".format(self.filepath, self.name, config)]) + command = [ + self.cryptogen, + "generate", + "--output={}/{}/{}".format(self.filepath, self.name, output), + "--config={}/{}/{}".format(self.filepath, self.name, config) + ] + + LOG.info("Running command: " + " ".join(command)) + + call(command) + except Exception as e: err_msg = "cryptogen generate fail for {}!".format(e) raise Exception(err_msg) @@ -44,8 +56,17 @@ def extend(self, input="crypto-config", config="crypto-config.yaml"): return: """ try: - call([self.cryptogen, "extend", "--input={}/{}/{}".format(self.filepath, self.name, input), - "--config={}/{}/{}".format(self.filepath, self.name, config)]) + command = [ + self.cryptogen, + "extend", + "--input={}/{}/{}".format(self.filepath, self.name, input), + "--config={}/{}/{}".format(self.filepath, self.name, config) + ] + + LOG.info("Running command: " + " ".join(command)) + + call(command) + except Exception as e: err_msg = "cryptogen extend fail for {}!".format(e) raise Exception(err_msg) diff --git a/src/api-engine/api/routes/chaincode/views.py b/src/api-engine/api/routes/chaincode/views.py index d1a62bdbf..3a4b17b9f 100644 --- a/src/api-engine/api/routes/chaincode/views.py +++ b/src/api-engine/api/routes/chaincode/views.py @@ -162,7 +162,7 @@ def package(self, request): # ) # peer_node = qs.first() # envs = init_env_vars(peer_node, org) - # peer_channel_cli = PeerChainCode("v2.2.0", **envs) + # peer_channel_cli = PeerChainCode("v2.5.9", **envs) # return_code, content = peer_channel_cli.lifecycle_calculatepackageid(temp_cc_path) # if (return_code != 0): # return Response( @@ -241,7 +241,7 @@ def install(self, request): peer_node = qs.first() envs = init_env_vars(peer_node, org) - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) res = peer_channel_cli.lifecycle_install(cc_targz) if res != 0: return Response(err("install chaincode failed."), status=status.HTTP_400_BAD_REQUEST) @@ -270,7 +270,7 @@ def query_installed(self, request): envs = init_env_vars(peer_node, org) timeout = "5s" - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) res, installed_chaincodes = peer_channel_cli.lifecycle_query_installed( timeout) if res != 0: @@ -300,7 +300,7 @@ def get_installed_package(self, request): envs = init_env_vars(peer_node, org) timeout = "5s" - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) res = peer_channel_cli.lifecycle_get_installed_package(timeout) if res != 0: return Response(err("get installed package failed."), status=status.HTTP_400_BAD_REQUEST) @@ -352,7 +352,7 @@ def approve_for_my_org(self, request): peer_node = qs.first() envs = init_env_vars(peer_node, org) - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) code, content = peer_channel_cli.lifecycle_approve_for_my_org(orderer_url, orderer_tls_root_cert, channel_name, chaincode_name, chaincode_version, policy, sequence) if code != 0: @@ -384,7 +384,7 @@ def query_approved(self, request): channel_name = request.data.get("channel_name") cc_name = request.data.get("chaincode_name") - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) code, content = peer_channel_cli.lifecycle_query_approved( channel_name, cc_name) if code != 0: @@ -438,7 +438,7 @@ def check_commit_readiness(self, request): peer_node = qs.first() envs = init_env_vars(peer_node, org) - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) code, content = peer_channel_cli.lifecycle_check_commit_readiness(orderer_url, orderer_tls_root_cert, channel_name, chaincode_name, chaincode_version, policy, sequence) @@ -507,7 +507,7 @@ def commit(self, request): peer_address_list.append(peer_address) peer_root_certs.append(peer_tls_cert) - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) code = peer_channel_cli.lifecycle_commit(orderer_url, orderer_tls_root_cert, channel_name, chaincode_name, chaincode_version, policy, peer_address_list, peer_root_certs, sequence) @@ -539,7 +539,7 @@ def query_committed(self, request): raise ResourceNotFound peer_node = qs.first() envs = init_env_vars(peer_node, org) - peer_channel_cli = PeerChainCode("v2.2.0", **envs) + peer_channel_cli = PeerChainCode("v2.5.9", **envs) code, chaincodes_commited = peer_channel_cli.lifecycle_query_committed( channel_name, chaincode_name) if code != 0: diff --git a/src/api-engine/api/routes/channel/views.py b/src/api-engine/api/routes/channel/views.py index a96d39ae0..787e1b5a2 100644 --- a/src/api-engine/api/routes/channel/views.py +++ b/src/api-engine/api/routes/channel/views.py @@ -147,7 +147,7 @@ def create(self, request): ordering_node = Node.objects.get(id=orderers[0]) peer_node = Node.objects.get(id=peers[0]) envs = init_env_vars(peer_node, org) - peer_channel_cli = PeerChannel("v2.2.0", **envs) + peer_channel_cli = PeerChannel("v2.5.9", **envs) peer_channel_cli.create( channel=name, orderer_url="{}.{}:{}".format( @@ -312,7 +312,7 @@ def update(self, request, pk=None): env = { "FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name), } - cli = PeerChannel("v2.2.0", **env) + cli = PeerChannel("v2.5.9", **env) cli.signconfigtx( channel.get_channel_artifacts_path(CFG_DELTA_ENV_PB)) LOG.info("Peers to send the update transaction success") @@ -343,7 +343,7 @@ def get_channel_org_config(self, request, pk=None): env = { "FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name), } - peer_channel_cli = PeerChannel("v2.2.0", **env) + peer_channel_cli = PeerChannel("v2.5.9", **env) peer_channel_cli.fetch(option="config", channel=channel.name) # Decode latest config block into json @@ -407,7 +407,7 @@ def join_peers(envs, block_path): :param block_path: Path to file containing genesis block """ # Join the peers to the channel. - peer_channel_cli = PeerChannel("v2.2.0", **envs) + peer_channel_cli = PeerChannel("v2.5.9", **envs) peer_channel_cli.join( block_file=block_path ) diff --git a/tests/postman/Makefile b/tests/postman/Makefile index bf778f174..432030475 100644 --- a/tests/postman/Makefile +++ b/tests/postman/Makefile @@ -3,4 +3,4 @@ initial-json: test-api: @$(MAKE) initial-json - bash ${ROOT_PATH}/tests/postman/test.sh || (echo "test api failed $$?"; exit 1) + bash test.sh || (echo "test api failed $$?"; exit 1) diff --git a/tests/postman/env.json.tmpl b/tests/postman/env.json.tmpl index 380e97ecf..57a8ce7c7 100644 --- a/tests/postman/env.json.tmpl +++ b/tests/postman/env.json.tmpl @@ -4,13 +4,13 @@ "values": [ { "key": "apiServer", - "value": "http://127.0.0.1:$API_ENGINE_SERVICE_PORT", + "value": "http://localhost", "description": "", "enabled": true }, { "key": "webRoot", - "value": "$API_ENGINE_WEBROOT", + "value": "8080", "description": "", "enabled": true }, @@ -86,6 +86,18 @@ "description": "", "enabled": true }, + { + "key": "ordererID", + "value": "", + "description": "", + "enabled": true + }, + { + "key": "peerID", + "value": "", + "description": "", + "enabled": true + }, { "key": "nodeCapacity", "value": "40", diff --git a/tests/postman/test/test.json b/tests/postman/test/test.json index f2d38094c..4747ceceb 100644 --- a/tests/postman/test/test.json +++ b/tests/postman/test/test.json @@ -7,19 +7,19 @@ }, "item": [ { - "name": "Login Admin", + "name": "Register Admin", "event": [ { "listen": "test", "script": { - "id": "30bb7433-5d34-407a-9c24-8d33f080446e", + "id": "register admin", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"token\", jsonData.token);" + "var responseBody = pm.response.json();", + "pm.environment.set(\"orgID\", responseBody.data.id);" ], "type": "text/javascript" } @@ -33,95 +33,55 @@ "name": "Content-Type", "value": "application/json", "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"username\": \"admin\",\n\t\"password\": \"pass\"\n}" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/auth/login/", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "auth", - "login", - "" - ] - }, - "description": "Login Admin" - }, - "response": [] - }, - { - "name": "List Agents", - "event": [ - { - "listen": "test", - "script": { - "id": "2493c5e9-eaf2-4689-a6ec-59080e571783", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [ + }, { - "key": "Authorization", - "value": "JWT {{token}}", + "key": "accept", + "name": "accept", + "value": "application/json", "type": "text" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"email\": \"admin@163.com\",\n\t\"password\": \"123...\",\n\t\"orgName\": \"org1.cello.com\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/agents", + "raw": "localhost:8080/api/v1/register", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ - "agents" + "api", + "v1", + "register" ] }, - "description": "List Agents" + "description": "Register Admin" }, "response": [] }, { - "name": "Create Organization", + "name": "Login Admin", "event": [ { "listen": "test", "script": { - "id": "a0f5e8df-9ce8-44e6-ad23-2f0899ce594a", + "id": "30bb7433-5d34-407a-9c24-8d33f080446e", "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});", "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"orgID\", jsonData.id);" + "var responseBody = pm.response.json();", + "pm.environment.set(\"token\", responseBody.data.token);" ], "type": "text/javascript" } } ], "request": { - "auth": { - "type": "noauth" - }, "method": "POST", "header": [ { @@ -131,45 +91,44 @@ "type": "text" }, { - "key": "Authorization", - "value": "JWT {{token}}", + "key": "accept", + "name": "accept", + "value": "application/json", "type": "text" } + ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"{{orgName}}\"\n}" + "raw": "{\n\t\"email\": \"admin@163.com\",\n\t\"password\": \"123...\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/organizations", + "raw": "localhost:8080/api/v1/login", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ - "organizations" + "api", + "v1", + "login" ] }, - "description": "Create Organization" + "description": "Login Admin" }, "response": [] }, { - "name": "Retrieve Organization", + "name": "Verify Token", "event": [ { "listen": "test", "script": { - "id": "a0f5e8df-9ce8-44e6-ad23-2f0899ce594a", + "id": "token-verify", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Test is right org\", function () {", - " var jsonData = pm.response.json();", - " var orgName = pm.environment.get(\"orgName\");", - "", - " tests[\"Name is right\"] = jsonData.name === orgName;", "});" ], "type": "text/javascript" @@ -177,55 +136,56 @@ } ], "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", + "method": "POST", "header": [ { "key": "Content-Type", "name": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { - "key": "Authorization", - "value": "JWT {{token}}", + "key": "accept", + "name": "accept", + "value": "application/json", "type": "text" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"token\": \"{{token}}\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/organizations/{{orgID}}", + "raw": "localhost:8080/api/v1/token-verify", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ - "organizations", - "{{orgID}}" + "api", + "v1", + "token-verify" ] }, - "description": "Retrieve Organization" + "description": "Verify Token" }, "response": [] }, { - "name": "Create Admin with organization", + "name": "Create Agent", "event": [ { "listen": "test", "script": { - "id": "a0f5e8df-9ce8-44e6-ad23-2f0899ce594a", + "id": "create agent", "exec": [ "pm.test(\"Status code is 201\", function () {", " pm.response.to.have.status(201);", "});", "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"operatorID\", jsonData.id);" + "var responseBody = pm.response.json();", + "pm.environment.set(\"agentID\", responseBody.data.id);" ], "type": "text/javascript" } @@ -240,78 +200,36 @@ { "key": "Content-Type", "name": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "value": "JWT {{token}}", + "value": "application/json", "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"username\": \"{{operatorName}}\",\n\t\"organization\": \"{{orgID}}\",\n\t\"role\": \"administrator\",\n\t\"password\": \"{{operatorPassword}}\",\n\t\"email\": \"{{operatorEmail}}\"\n}" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/users", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "users" - ] - }, - "description": "Create Admin with organization" - }, - "response": [] - }, - { - "name": "Create Agent", - "event": [ - { - "listen": "test", - "script": { - "id": "5fb7881e-27c4-4420-bebb-9c9a604ef129", - "exec": [ - "pm.test(\"Status code is 201\", function () {", - " pm.response.to.have.status(201);", - "});", - "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"agentID\", jsonData.id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ + }, { - "key": "Content-Type", + "key": "accept", + "name": "accept", "value": "application/json", "type": "text" }, { "key": "Authorization", + "name": "Authorization", "value": "JWT {{token}}", "type": "text" } ], "body": { "mode": "raw", - "raw": "{\n\t\"name\": \"{{k8sAgentName}}\",\n\t\"worker_api\": \"{{k8sAgentWorkerApi}}\",\n\t\"capacity\": {{agentCapacity}},\n\t\"node_capacity\": {{nodeCapacity}},\n\t\"log_level\": \"info\",\n\t\"type\": \"kubernetes\",\n\t\"schedulable\": true,\n\t\"k8s_config\": {\n\t\t\"credential_type\": \"cert_key\",\n\t\t\"enable_ssl\": false,\n\t\t\"nfs_server\": \"{{k8sNfsServer}}\",\n\t\t\"cert\": \"cert\",\n\t\t\"key\": \"key\"\n\t}\n}" + "raw": "{\n\t\"name\": \"agent\",\n\t\"type\": \"docker\",\n\t\"urls\": \"http://192.168.1.38:5001\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/agents", + "raw": "localhost:8080/api/v1/agents", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ + "api", + "v1", "agents" ] }, @@ -320,27 +238,19 @@ "response": [] }, { - "name": "Retrieve Agent", + "name": "Create Orderer Nodes", "event": [ { "listen": "test", "script": { - "id": "269f857f-7e26-417d-a4b0-dec87aac3853", + "id": "Create Orderer Nodes", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "", - "pm.test(\"Test is right agent\", function () {", - " var jsonData = pm.response.json();", - " var agentName = pm.environment.get(\"k8sAgentName\");", - " var agentCapacity = parseInt(pm.environment.get(\"agentCapacity\"));", - " var k8sAgentWorkerApi = pm.environment.get(\"k8sAgentWorkerApi\");", - "", - " tests[\"Name is right\"] = jsonData.name === agentName;", - " tests[\"Capacity is right\"] = jsonData.capacity === agentCapacity;", - " tests[\"Worker api is right\"] = jsonData.worker_api === k8sAgentWorkerApi;", - "});" + "var responseBody = pm.response.json();", + "pm.environment.set(\"ordererID\", responseBody.data.id);" ], "type": "text/javascript" } @@ -350,310 +260,62 @@ "auth": { "type": "noauth" }, - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "value": "JWT {{token}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/agents/{{agentID}}", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "agents", - "{{agentID}}" - ] - }, - "description": "Retrieve Agent" - }, - "response": [] - }, - { - "name": "Auth Operator", - "event": [ - { - "listen": "test", - "script": { - "id": "62366c1c-74bf-4f81-ae81-f5da3c17eabb", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"operatorToken\", jsonData.token);" - ], - "type": "text/javascript" - } - } - ], - "request": { "method": "POST", "header": [ { "key": "Content-Type", + "name": "Content-Type", "value": "application/json", "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"username\": \"{{operatorName}}\",\n\t\"password\": \"{{operatorPassword}}\"\n}" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/auth/login/", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "auth", - "login", - "" - ] - }, - "description": "Auth Operator" - }, - "response": [] - }, - { - "name": "Apply agent with operator token", - "event": [ - { - "listen": "test", - "script": { - "id": "62366c1c-74bf-4f81-ae81-f5da3c17eabb", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "var jsonData = pm.response.json();", - "pm.environment.set(\"appliedAgentID\", jsonData.id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "value": "JWT {{operatorToken}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"type\": \"kubernetes\",\n\t\"capacity\": {{agentCapacity}}\n}" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/agents/organization", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "agents", - "organization" - ] - }, - "description": "Apply agent with operator token" - }, - "response": [] - }, - { - "name": "Retrieve Agent with operator token", - "event": [ - { - "listen": "test", - "script": { - "id": "269f857f-7e26-417d-a4b0-dec87aac3853", - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Test is right agent\", function () {", - " var jsonData = pm.response.json();", - " var agentID = pm.environment.get(\"appliedAgentID\");", - "", - " tests[\"ID is right\"] = jsonData.id === agentID;", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" }, { - "key": "Authorization", - "value": "JWT {{operatorToken}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/agents/{{agentID}}", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "agents", - "{{agentID}}" - ] - }, - "description": "Retrieve Agent with operator token" - }, - "response": [] - }, - { - "name": "Release Agent with operator token", - "event": [ - { - "listen": "test", - "script": { - "id": "269f857f-7e26-417d-a4b0-dec87aac3853", - "exec": [ - "pm.test(\"Status code is 204\", function () {", - " pm.response.to.have.status(204);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "DELETE", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - }, - { - "key": "Authorization", - "value": "JWT {{operatorToken}}", + "key": "accept", + "name": "accept", + "value": "application/json", "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/agents/{{agentID}}/organization", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "agents", - "{{agentID}}", - "organization" - ] - }, - "description": "Release agent with operator token" - }, - "response": [] - }, - { - "name": "Delete Agent", - "event": [ - { - "listen": "test", - "script": { - "id": "269f857f-7e26-417d-a4b0-dec87aac3853", - "exec": [ - "pm.test(\"Status code is 204\", function () {", - " pm.response.to.have.status(204);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "DELETE", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" }, { "key": "Authorization", + "name": "Authorization", "value": "JWT {{token}}", "type": "text" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"orderer\",\n\t\"num\": \"1\",\n\t\"type\": \"orderer\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/agents/{{agentID}}", + "raw": "localhost:8080/api/v1/nodes", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ - "agents", - "{{agentID}}" + "api", + "v1", + "nodes" ] }, - "description": "Delete Agent" + "description": "Create Orderer Nodes" }, "response": [] }, { - "name": "Delete User", + "name": "Create Peer Nodes", "event": [ { "listen": "test", "script": { - "id": "a0f5e8df-9ce8-44e6-ad23-2f0899ce594a", + "id": "Create Peer Nodes", "exec": [ - "pm.test(\"Status code is 204\", function () {", - " pm.response.to.have.status(204);", - "});" + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});", + "", + "var responseBody = pm.response.json();", + "pm.environment.set(\"peerID\", responseBody.data.id);" ], "type": "text/javascript" } @@ -663,87 +325,45 @@ "auth": { "type": "noauth" }, - "method": "DELETE", + "method": "POST", "header": [ { "key": "Content-Type", "name": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" }, { - "key": "Authorization", - "value": "JWT {{token}}", + "key": "accept", + "name": "accept", + "value": "application/json", "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{apiServer}}{{webRoot}}/users/{{operatorID}}", - "host": [ - "{{apiServer}}{{webRoot}}" - ], - "path": [ - "users", - "{{operatorID}}" - ] - }, - "description": "Delete User" - }, - "response": [] - }, - { - "name": "Delete Organization", - "event": [ - { - "listen": "test", - "script": { - "id": "a0f5e8df-9ce8-44e6-ad23-2f0899ce594a", - "exec": [ - "pm.test(\"Status code is 204\", function () {", - " pm.response.to.have.status(204);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "DELETE", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/json" }, { "key": "Authorization", + "name": "Authorization", "value": "JWT {{token}}", "type": "text" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"name\": \"peer\",\n\t\"num\": \"1\",\n\t\"type\": \"peer\"\n}" }, "url": { - "raw": "{{apiServer}}{{webRoot}}/organizations/{{orgID}}", + "raw": "localhost:8080/api/v1/nodes", + "protocol": "http", "host": [ - "{{apiServer}}{{webRoot}}" + "localhost" ], + "port": "8080", "path": [ - "organizations", - "{{orgID}}" + "api", + "v1", + "nodes" ] }, - "description": "Delete Organization" + "description": "Create Peer Nodes" }, "response": [] }