Commit f99ea07c authored by kzangeli's avatar kzangeli
Browse files

fix(029_03,039_04): partial notification fragment is a valid recursive-merge update (204)

A (CSR) Subscription update fragment changing only notification.format
({"notification":{"format":"keyValues"}}) is applied via TS 104-175 clause 8.4.2
"Partial update patch behaviour" — an algorithm equivalent to IETF RFC 7396
(recursive JSON Merge Patch) — so it deep-merges into the stored notification,
preserving the mandatory endpoint, and returns 204. It is not an invalid
fragment. 029_03 asserts 204; 039_04 is split so InvalidType still asserts 400
while the partial-notification case asserts 204.
parent 65ab7516
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot update a subscription: If the data types and restriction are not met by the Subscription Fragment, then an error of type BadRequestData shall be raised
Documentation       Check that a partial Subscription Fragment (changing only notification.format) is applied by recursive merge (TS 104-175 clause 8.4.2 / RFC 7396), preserving the existing notification.endpoint, and returns 204 No Content

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
@@ -16,18 +16,14 @@ ${subscription_update_fragment_file_path}= subscriptions/fragments/subscrip


*** Test Cases ***
029_03_01 Update Subscription With Invalid Fragment
    [Documentation]    Check that one cannot update a subscription: If the data types and restriction are not met by the Subscription Fragment, then an error of type BadRequestData shall be raised
029_03_01 Update Subscription With A Partial Notification Fragment
    [Documentation]    Check that a partial Subscription Fragment (changing only notification.format) is applied by recursive merge (TS 104-175 clause 8.4.2 / RFC 7396), preserving the existing notification.endpoint, and returns 204 No Content
    [Tags]    sub-update    5_8_2
    ${response}=    Update Subscription
    ...    ${subscription_id}
    ...    ${subscription_update_fragment_file_path}
    ...    ${CONTENT_TYPE_JSON}
    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
    Check Response Status Code    204    ${response.status_code}


*** Keywords ***
+14 −17
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot update a context source registration subscription with a fragment that does not meet the data types and restrictions expressed by clause 5.2.12
Documentation       Check the behaviour of updating a context source registration subscription with a fragment: a fragment changing a read-only field is rejected (BadRequestData), while a partial fragment is applied by recursive merge (TS 104-175 clause 8.4.2 / RFC 7396)

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistrationSubscription.resource
@@ -8,35 +8,32 @@ Resource ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Context Source Registration Subscriptions
Test Teardown       Delete Initial Context Source Registration Subscriptions
Test Template       Update Context Source Registration Subscription With Invalid Fragment


*** Variables ***
${subscription_payload_file_path}=      csourceSubscriptions/subscription.jsonld


*** Test Cases ***    FILEPATH
*** Test Cases ***
039_04_01 InvalidType
    [Documentation]    A fragment changing the read-only 'type' is rejected with BadRequestData.
    [Tags]    csrsub-update    5_11_3
    csourceSubscriptions/fragments/subscription-update-invalid-type.json
039_04_02 InvalidNotification
    [Tags]    csrsub-update    5_11_3
    csourceSubscriptions/fragments/subscription-update-invalid-notification.json


*** Keywords ***
Update Context Source Registration Subscription With Invalid Fragment
    [Documentation]    Check that one cannot update a context source registration subscription with a fragment that does not meet the data types and restrictions expressed by clause 5.2.12
    [Arguments]    ${filepath}
    ${subscription_update_fragment}=    Load Test Sample    ${filepath}
    ${response}=    Update Context Source Registration Subscription
    ...    ${subscription_id}
    ...    ${subscription_update_fragment}
    ${fragment}=    Load Test Sample    csourceSubscriptions/fragments/subscription-update-invalid-type.json
    ${response}=    Update Context Source Registration Subscription    ${subscription_id}    ${fragment}
    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element
    ...    response_body=${response.json()}
    ...    problem_type=${ERROR_TYPE_BAD_REQUEST_DATA}

039_04_02 PartialNotificationUpdate
    [Documentation]    A partial fragment changing only notification.format is applied by recursive merge (clause 8.4.2 / RFC 7396), preserving the existing endpoint, and returns 204 No Content.
    [Tags]    csrsub-update    5_11_3
    ${fragment}=    Load Test Sample    csourceSubscriptions/fragments/subscription-update-invalid-notification.json
    ${response}=    Update Context Source Registration Subscription    ${subscription_id}    ${fragment}
    Check Response Status Code    204    ${response.status_code}


*** Keywords ***
Setup Initial Context Source Registration Subscriptions
    ${subscription_id}=    Generate Random Subscription Id
    ${subscription_payload}=    Load Test Sample    ${subscription_payload_file_path}    ${subscription_id}