forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for REST server API key security (hyperledger-ar…
…chives#3969) * Add integration test for REST server API key security Signed-off-by: Mark S. Lewis <[email protected]> * Add integration test for incorrect REST server API key Signed-off-by: Mark S. Lewis <[email protected]>
- Loading branch information
1 parent
e866a16
commit 82ad8b2
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/composer-tests-integration/features/rest-apikey.feature
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,44 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
@rest @rest-apikey | ||
Feature: Rest steps | ||
|
||
Background: | ||
Given I have admin business cards available | ||
|
||
Scenario: Using a secured REST API, requests are rejeted if the API key is not supplied | ||
Given I have a secured REST API server for test-network using API key "conga" | ||
And I have cleared the cookie jar | ||
When I make a GET request to /api/system/ping | ||
Then The response code should be 401 | ||
|
||
Scenario: Using a secured REST API, requests are rejeted if the wrong API key is supplied | ||
When I make a GET request to /api/system/ping with API key "cOnGa" | ||
Then The response code should be 401 | ||
|
||
Scenario: Using a secured REST API, requests are accepted if the correct API key is supplied | ||
When I make a GET request to /api/system/ping with API key "conga" | ||
Then The response code should be 200 | ||
And The response body should be JSON matching | ||
""" | ||
{ | ||
"version": _.isString, | ||
"participant": "org.hyperledger.composer.system.NetworkAdmin#admin", | ||
"identity": _.isString | ||
} | ||
""" | ||
|
||
Scenario: Finally, shutdown the REST server | ||
When I shutdown the REST server |
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