-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from bci-oss/feature/automated-api-tests
Introduce e2eTests for DTR
- Loading branch information
Showing
5 changed files
with
269 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,72 @@ | ||
############################################################### | ||
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
name: AAS Registry End-to-End tests | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
clientId: | ||
description: 'clientId' | ||
required: true | ||
clientSecret: | ||
description: 'clientSecret' | ||
required: true | ||
tokenUrl: | ||
description: 'tokenUrl' | ||
required: true | ||
aasRegistryUrl: | ||
description: 'AAS-Registry-Url' | ||
required: true | ||
|
||
jobs: | ||
end_to_end_tests: | ||
runs-on: ubuntu-latest | ||
name: Execute End-to-End tests | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
check-latest: true | ||
|
||
- name: Install python dependencies | ||
working-directory: ./e2e-tests | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Install python dependencies | ||
working-directory: ./e2e-tests/aas-registry | ||
run: | | ||
py.test . -vv --html=./output/report.html --self-contained-html | ||
env: | ||
CLIENT_ID: ${{ inputs.clientId }} | ||
CLIENT_SECRET: ${{ inputs.clientSecret }} | ||
AUTH_SERVER_TOKEN_URL: ${{ inputs.tokenUrl }} | ||
AAS_REGISTRY_API_URL: ${{ inputs.aasRegistryUrl }} | ||
|
||
- name: Upload test report | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: aas-registry-e2e-test-report | ||
path: ./e2e-tests/aas-registry/output/report.html |
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,25 @@ | ||
############################################################### | ||
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
name: Common variable definitions | ||
description: | ||
Contains common variable definitions. | ||
|
||
variables: | ||
aas_registry_api_url: "{tavern.env_vars.AAS_REGISTRY_API_URL}" |
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,49 @@ | ||
############################################################### | ||
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
name: Authentication stage | ||
description: | ||
Reusable test stage for authentication | ||
|
||
variables: | ||
auth: | ||
client_id: "{tavern.env_vars.CLIENT_ID}" | ||
client_secret: "{tavern.env_vars.CLIENT_SECRET}" | ||
auth_server_token_url: "{tavern.env_vars.AUTH_SERVER_TOKEN_URL}" | ||
|
||
stages: | ||
- id: request_auth_token | ||
name: Request token | ||
request: | ||
url: "{auth.auth_server_token_url:s}" | ||
headers: | ||
Accept: "*/*" | ||
Content-Type: "application/x-www-form-urlencoded" | ||
data: | ||
grant_type: "client_credentials" | ||
client_id: "{auth.client_id:s}" | ||
client_secret: "{auth.client_secret:s}" | ||
method: POST | ||
response: | ||
status_code: 200 | ||
headers: | ||
content-type: application/json | ||
save: | ||
json: | ||
access_token: access_token |
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,120 @@ | ||
############################################################### | ||
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
# Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
test_name: Test APIs are protected with authentication | ||
|
||
includes: | ||
- !include common.yaml | ||
- !include stage_auth.yaml | ||
|
||
stages: | ||
- name: Test get shell descriptors without access token | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors" | ||
method: GET | ||
response: | ||
status_code: 401 | ||
|
||
- type: ref | ||
id: request_auth_token | ||
|
||
- name: Authenticated request | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors" | ||
method: GET | ||
headers: | ||
Content-Type: application/json | ||
Authorization: "Bearer {access_token}" | ||
Edc-Bpn: "default-tenant" | ||
response: | ||
status_code: 200 | ||
headers: | ||
content-type: application/json | ||
|
||
--- | ||
test_name: Test create, read, update and delete of a shell descriptor | ||
|
||
includes: | ||
- !include common.yaml | ||
- !include stage_auth.yaml | ||
|
||
stages: | ||
- type: ref | ||
id: request_auth_token | ||
|
||
- name: Create shell descriptor expect success | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors" | ||
method: POST | ||
headers: | ||
Content-Type: application/json | ||
Authorization: "Bearer {access_token}" | ||
Edc-Bpn: "default-tenant" | ||
json: | ||
id: "{decoded_shell_id:s}" | ||
idShort: twin of a break (Testing) | ||
response: | ||
status_code: 201 | ||
headers: | ||
content-type: application/json | ||
|
||
- name: Get shell descriptor by id | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors/{encoded_shell_id:s}" | ||
method: GET | ||
headers: | ||
Content-Type: application/json | ||
Authorization: "Bearer {access_token}" | ||
Edc-Bpn: "default-tenant" | ||
response: | ||
status_code: 200 | ||
headers: | ||
content-type: application/json | ||
json: | ||
description: [ ] | ||
displayName: [ ] | ||
idShort: twin of a break (Testing) | ||
id: "{decoded_shell_id:s}" | ||
specificAssetIds: [] | ||
submodelDescriptors: [] | ||
|
||
- name: Update shell descriptor by id | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors/{encoded_shell_id:s}" | ||
method: PUT | ||
headers: | ||
Content-Type: application/json | ||
Authorization: "Bearer {access_token}" | ||
Edc-Bpn: "default-tenant" | ||
json: | ||
id: "{decoded_shell_id:s}" | ||
idShort: twin of a break (Testing Update) | ||
response: | ||
status_code: 204 | ||
|
||
- name: Delete shell descriptor by id | ||
request: | ||
url: "{aas_registry_api_url:s}/api/v3.0/shell-descriptors/{encoded_shell_id:s}" | ||
method: DELETE | ||
headers: | ||
Content-Type: application/json | ||
Authorization: "Bearer {access_token}" | ||
Edc-Bpn: "default-tenant" | ||
response: | ||
status_code: 204 |
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,3 @@ | ||
pytest==7.1.2 | ||
tavern==1.23.3 | ||
pytest-html==3.1.1 |