-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init rest api bddtests, first cover GetTransactionCert(). Fix Github issue #2363 Change-Id: I55c23eb25d1d6caac06ad6893fd5eef1e35e2d3b Signed-off-by: grapebaba <281165273@qq.com>
- Loading branch information
1 parent
27e7db7
commit 3ccede0
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
membersrvc0: | ||
extends: | ||
file: compose-defaults.yml | ||
service: membersrvc | ||
|
||
vp0: | ||
extends: | ||
file: compose-defaults.yml | ||
service: vp | ||
environment: | ||
- CORE_PEER_ID=vp0 | ||
- CORE_SECURITY_ENABLED=true | ||
- CORE_PEER_PKI_ECA_PADDR=membersrvc0:7054 | ||
- CORE_PEER_PKI_TCA_PADDR=membersrvc0:7054 | ||
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc0:7054 | ||
links: | ||
- membersrvc0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Test REST API Features of Peers | ||
# | ||
# Tags that can be used and will affect test internals: | ||
# @doNotDecompose will NOT decompose the named compose_yaml after scenario ends. Useful for setting up environment and reviewing after scenario. | ||
# @chaincodeImagesUpToDate use this if all scenarios chaincode images are up to date, and do NOT require building. BE SURE!!! | ||
|
||
Feature: Peer REST API | ||
As a Fabric developer | ||
I want to verify REST API behavior | ||
|
||
Scenario: 1 peer and 1 membersrvc, query transaction certs with query parameter count | ||
Given we compose "docker-compose-rest.yml" | ||
And I use the following credentials for querying peers: | ||
| peer | username | secret | | ||
| vp0 | test_user0 | MS9qrN8hFjlE | | ||
And I register with CA supplying username "test_user0" and secret "MS9qrN8hFjlE" on peers: | ||
| vp0 | | ||
|
||
When I request transaction certs with query parameters on "vp0" | ||
| key | value | | ||
| count | 1 | | ||
Then I should get a JSON response with "1" different transaction certs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# Copyright IBM Corp. 2016 All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import requests | ||
from behave import * | ||
from peer_basic_impl import buildUrl | ||
from peer_basic_impl import getAttributeFromJSON | ||
|
||
import bdd_test_util | ||
|
||
|
||
@when(u'I request transaction certs with query parameters on "{containerName}"') | ||
def step_impl(context, containerName): | ||
assert 'table' in context, "table (of query parameters) not found in context" | ||
assert 'userName' in context, "userName not found in context" | ||
assert 'compose_containers' in context, "compose_containers not found in context" | ||
|
||
ipAddress = bdd_test_util.ipFromContainerNamePart(containerName, context.compose_containers) | ||
request_url = buildUrl(context, ipAddress, "/registrar/{0}/tcert".format(context.userName)) | ||
print("Requesting path = {0}".format(request_url)) | ||
queryParams = {} | ||
for row in context.table.rows: | ||
key, value = row['key'], row['value'] | ||
queryParams[key] = value | ||
|
||
print("Query parameters = {0}".format(queryParams)) | ||
resp = requests.get(request_url, params=queryParams, headers={'Accept': 'application/json'}, verify=False) | ||
|
||
assert resp.status_code == 200, "Failed to GET to %s: %s" % (request_url, resp.text) | ||
context.response = resp | ||
print("") | ||
|
||
@then(u'I should get a JSON response with "{expectedValue}" different transaction certs') | ||
def step_impl(context, expectedValue): | ||
print(context.response.json()) | ||
foundValue = getAttributeFromJSON("OK", context.response.json(), "Attribute not found in response (OK)") | ||
print(len(set(foundValue))) | ||
assert (len(set(foundValue)) == int(expectedValue)), "For attribute OK, expected different transaction cert of size (%s), instead found (%s)" % (expectedValue, len(set(foundValue))) |