diff --git a/local/testing/api-tests/irs-api-tests.tavern.yaml b/local/testing/api-tests/irs-api-tests.tavern.yaml index 080d435202..9d7469b656 100644 --- a/local/testing/api-tests/irs-api-tests.tavern.yaml +++ b/local/testing/api-tests/irs-api-tests.tavern.yaml @@ -1,4 +1,4 @@ -test_name: Make sure investigation job with invalid request is handled correctly with MOCK +test_name: Make sure investigation job with invalid request is handled correctly strict: - headers:off @@ -7,14 +7,13 @@ strict: stages: - name: register a BPN investigation with invalid request request: - url: "{tavern.env_vars.IRS_HOST}/ess/bpn/investigations" + url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" json: - globalAssetId111: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 -# key: -# globalAssetId111: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 -# bpn: BPNL00000003CRHK - incidentBpns11: - - BPNL00000003B6LU + key: + globalAssetId111: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 + bpn111: BPNL00000003CRHK + incidentBPNSs111: + - BPNS00000003B6LU method: POST headers: content-type: application/json @@ -34,7 +33,7 @@ stages: --- -test_name: Make sure investigation job with valid globalAssetId and BPN is processed correctly with MOCK +test_name: Make sure investigation job with valid globalAssetId and BPN is processed correctly strict: - headers:off @@ -45,14 +44,14 @@ stages: request: url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" json: -# key: -# globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 -# bpn: BPNL00000003CRHK - globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 + key: + # Tested with Vehicle A + globalAssetId: urn:uuid:0733946c-59c6-41ae-9570-cb43a6e4c79e + bpn: BPNL00000003AYRE bomLifecycle: asPlanned callbackUrl: http://testikus.com - incidentBpns: - - BPNL00000003B6LU + incidentBPNSs: + - BPNS00000003B6LU method: POST headers: content-type: application/json @@ -98,7 +97,8 @@ stages: response: status_code: 200 verify_response_with: - - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_valid_ID + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Yes + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested headers: content-type: application/json @@ -106,7 +106,7 @@ stages: --- -test_name: Make sure investigation job with valid globalAssetId for unknown BPN is processed correctly with MOCK +test_name: Make sure investigation job with valid globalAssetId for unknown BPN is processed correctly strict: - headers:off @@ -117,14 +117,14 @@ stages: request: url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" json: -# key: -# globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 -# bpn: BPNL00000003CRHK - globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e9fd3a7 + key: + # Tested with Vehicle A + globalAssetId: urn:uuid:0733946c-59c6-41ae-9570-cb43a6e4c79e + bpn: BPNL00000003AYRE bomLifecycle: asPlanned callbackUrl: http://testikus.com - incidentBpns: - - BPNL00ARBITRARY1 + incidentBPNSs: + - BPNS00ARBITRARY9 method: POST headers: content-type: application/json @@ -153,7 +153,8 @@ stages: response: status_code: 200 verify_response_with: - - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_valid_ID_in_unknown_BPN + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_No + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested headers: content-type: application/json @@ -161,7 +162,7 @@ stages: --- -test_name: Make sure investigation job with unknown globalAssetId and BPN is processed correctly with MOCK +test_name: Make sure investigation job with unknown globalAssetId and valid BPN is processed correctly strict: - headers:off @@ -172,12 +173,124 @@ stages: request: url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" json: -# key: -# globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e955555 -# bpn: BPNL00000003CRHK - globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e955555 - incidentBpns: - - BPNL00000003B6LU + key: + globalAssetId: urn:uuid:2c57b0e9-a653-411d-bdcd-64787e955555 + bpn: BPNL00000003AYRE + incidentBPNSs: + - BPNS00000003B6LU + method: POST + headers: + content-type: application/json + $ext: + function: local.testing.api-tests.tavern_helpers:create_bearer_token + response: + status_code: 201 + headers: + content-type: application/json + save: + json: + job_id: id + + - *verify_ESS_job_response_with_desired_test_steps_and_wait_up_to_15_minutes_for_COMPLETED + + - name: get response for created investigation + request: + url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations/{job_id}" + params: + returnUncompletedJob: true + method: GET + headers: + content-type: application/json + $ext: + function: local.testing.api-tests.tavern_helpers:create_bearer_token + response: + status_code: 200 + verify_response_with: + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Unknown + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested + headers: + content-type: application/json + + +--- + + +test_name: Make sure investigation job with valid globalAssetId and valid BPN but partial supply chain is processed correctly + +strict: + - headers:off + - json:off + +stages: + - name: register a BPN investigation with valid globalAssetId and valid BPN + request: + url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" + json: + key: + #tested with Vehicle D + globalAssetId: urn:uuid:3a2a1ca9-c6c1-49c7-a7ae-1dfc5fb9881f + bpn: BPNL00ARBITRARY8 + bomLifecycle: asPlanned + callbackUrl: http://testikus.com + incidentBPNSs: + - BPNS0ARBITRARY11 + method: POST + headers: + content-type: application/json + $ext: + function: local.testing.api-tests.tavern_helpers:create_bearer_token + response: + status_code: 201 + headers: + content-type: application/json + save: + json: + job_id: id + + - *verify_ESS_job_response_with_desired_test_steps_and_wait_up_to_15_minutes_for_COMPLETED + + - name: get response for created investigation + request: + url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations/{job_id}" + params: + returnUncompletedJob: true + method: GET + headers: + content-type: application/json + $ext: + function: local.testing.api-tests.tavern_helpers:create_bearer_token + response: + status_code: 200 + verify_response_with: + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Yes + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested + headers: + content-type: application/json + + + +--- + + +test_name: Make sure investigation job with valid globalAssetId and valid BPN but not reachable incidentBPN is processed correctly + +strict: + - headers:off + - json:off + +stages: + - name: register a BPN investigation with valid globalAssetId and valid BPN but not reachable incidentBPN + request: + url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" + json: + key: + #tested with Vehicle B + globalAssetId: urn:uuid:68904173-ad59-4a77-8412-3e73fcafbd8b + bpn: BPNL00000003B6LU + bomLifecycle: asPlanned + callbackUrl: http://testikus.com + incidentBPNSs: + - BPNS00000003AXS3 method: POST headers: content-type: application/json @@ -206,7 +319,8 @@ stages: response: status_code: 200 verify_response_with: - - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_unknown_ID + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Unknown + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested headers: content-type: application/json @@ -214,7 +328,7 @@ stages: --- -test_name: Make sure investigation job with several relationships for valid globalAssetId and BPN is processed correctly with MOCK +test_name: Make sure investigation job with several relationships for valid globalAssetId and BPN is processed correctly strict: - headers:off @@ -225,12 +339,12 @@ stages: request: url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" json: -# key: -# globalAssetId: urn:uuid:aad27ddb-43aa-4e42-98c2-01e529ef127c -# bpn: BPNL00000003CRHK - globalAssetId: urn:uuid:aad27ddb-43aa-4e42-98c2-01e529ef127c - incidentBpns: - - BPNL00ARBITRARY1 + key: + # Tested with Vehicle C + globalAssetId: urn:uuid:1c7a25ea-0490-4944-b9c9-d8c666d47958 + bpn: BPNL00ARBITRARY4 + incidentBPNSs: + - BPNS00ARBITRARY7 method: POST headers: content-type: application/json @@ -259,8 +373,13 @@ stages: response: status_code: 200 verify_response_with: - - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_valid_ID + - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Yes - function: local.testing.api-tests.tavern_helpers:relationships_for_BPN_investigations_contains_several_childs + - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested + - function: local.testing.api-tests.tavern_helpers:tombstones_are_empty + - function: local.testing.api-tests.tavern_helpers:relationships_are_not_empty + - function: local.testing.api-tests.tavern_helpers:submodels_are_not_empty + - function: local.testing.api-tests.tavern_helpers:check_timestamps_for_completed_jobs headers: content-type: application/json @@ -281,10 +400,12 @@ stages: # request: # url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" # json: -# globalAssetId: urn:uuid:c7a2b803-f8fe-4b79-b6fc-967ce847c9a9 +# key: +# globalAssetId: urn:uuid:c7a2b803-f8fe-4b79-b6fc-967ce847c9a9 +# bpn: BPNL00000003B0Q0 # bomLifecycle: asPlanned # callbackUrl: http://testikus.com -# incidentBpns: +# incidentBPNSs: # - BPNL00000003B0Q0 # method: POST # headers: @@ -314,66 +435,12 @@ stages: # response: # status_code: 200 # verify_response_with: -# - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_valid_ID +# - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_Yes +# - function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested # headers: # content-type: application/json # -#--- -# -# -#test_name: Make sure investigation job with valid globalAssetId and BPN is processed in submodel servers correctly in MOCK -# -#strict: -# - headers:off -# - json:off -# -#stages: -# - *authenticate_and_fetch_token -# -# - name: register a BPN investigation with valid globalAssetId for processing in submodel servers in MOCK -# request: -# url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations" -# json: -# globalAssetId: urn:uuid:1c7a25ea-0490-4944-b9c9-d8c666d47958 -# incidentBpns: -# - BPNL00ARBITRARY7 -# method: POST -# headers: -# content-type: application/json -# $ext: -# function: local.testing.api-tests.tavern_helpers:create_bearer_token -# response: -# status_code: 201 -# headers: -# content-type: application/json -# save: -# json: -# job_id: id -# -# - *verify_ESS_job_response_with_desired_test_steps_and_wait_up_to_15_minutes_for_COMPLETED -# -# - name: get response for created investigation -# request: -# url: "{tavern.env_vars.IRS_ESS_HOST}/ess/bpn/investigations/{job_id}" -# params: -# returnUncompletedJob: true -# method: GET -# headers: -# content-type: application/json -# $ext: -# function: local.testing.api-tests.tavern_helpers:create_bearer_token -# response: -# status_code: 200 -# verify_response_with: -# - function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_correct_in_submodels_for_valid_ID -# - function: local.testing.api-tests.tavern_helpers:tombstones_are_empty -# - function: local.testing.api-tests.tavern_helpers:relationships_are_not_empty -# - function: local.testing.api-tests.tavern_helpers:submodels_are_not_empty -# - function: local.testing.api-tests.tavern_helpers:check_timestamps_for_completed_jobs -# headers: -# content-type: application/json - ############################## /\ ESS Tests with T-Systems and submodel servers /\ ############################## ###### !!!!!! Commented out since there is no testdata available for the moment !!!!!! ###### --- diff --git a/local/testing/api-tests/tavern_helpers.py b/local/testing/api-tests/tavern_helpers.py index 8eded3c3bc..a9a283a139 100644 --- a/local/testing/api-tests/tavern_helpers.py +++ b/local/testing/api-tests/tavern_helpers.py @@ -5,7 +5,7 @@ import os -def supplyChainImpacted_is_correct_in_submodels_for_valid_ID(response): +def supplyChainImpacted_is_Yes(response): submodels = response.json().get("submodels") print("submodels ", submodels) assert len(submodels) <= 1 @@ -14,7 +14,7 @@ def supplyChainImpacted_is_correct_in_submodels_for_valid_ID(response): assert 'Yes' in i.get("payload").get('supplyChainImpacted') -def supplyChainImpacted_is_correct_in_submodels_for_valid_ID_in_unknown_BPN(response): +def supplyChainImpacted_is_No(response): submodels = response.json().get("submodels") print("submodels ", submodels) assert len(submodels) <= 1 @@ -23,7 +23,7 @@ def supplyChainImpacted_is_correct_in_submodels_for_valid_ID_in_unknown_BPN(resp assert 'No' in i.get("payload").get('supplyChainImpacted') -def supplyChainImpacted_is_correct_in_submodels_for_unknown_ID(response): +def supplyChainImpacted_is_Unknown(response): submodels = response.json().get("submodels") print("submodels ", submodels) assert len(submodels) <= 1 @@ -35,15 +35,30 @@ def supplyChainImpacted_is_correct_in_submodels_for_unknown_ID(response): def errors_for_invalid_investigation_request_are_correct(response): print(response.json().get("messages")) error_list = response.json().get("messages") - assert 'incidentBpns:must not be empty' in error_list - assert 'globalAssetId:must not be blank' in error_list + assert 'incidentBPNSs:must not be empty' in error_list + assert 'key.globalAssetId:must not be blank' in error_list + assert 'key.bpn:must not be blank' in error_list def relationships_for_BPN_investigations_contains_several_childs(response): relationships = response.json().get("relationships") print("relationships: ", relationships) print("Länge: ", len(relationships)) - assert len(relationships) > 1 + assert len(relationships) != 0 + +def ESS_job_parameter_are_as_requested(response): + print("Check if ESS-job parameter are as requested:") + parameter = response.json().get('job').get('parameter') + print(parameter) + assert parameter.get('bomLifecycle') == 'asPlanned' + assert parameter.get('collectAspects') is True + assert parameter.get('depth') == 1 + assert parameter.get('direction') == 'downward' + assert parameter.get('lookupBPNs') is False + #assert parameter.get('callbackUrl') == 'https://www.check123.com' + aspects_list = parameter.get("aspects") + assert 'PartSiteInformationAsPlanned' in aspects_list + assert 'PartAsPlanned' in aspects_list ############################## /\ ESS helpers /\ ##############################