Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-47792

Bad HTTP response (409) sent when the subscription request is not correct

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Normal Normal
    • None
    • 4.17
    • Networking / ptp
    • Moderate
    • None
    • CNF RAN Sprint 264, CNF RAN Sprint 265
    • 2
    • False
    • Hide

      None

      Show
      None
    • N/A
    • Release Note Not Required
    • Done

      This is a clone of issue OCPBUGS-46627. The following is the description of the original issue:

      If a consumer sends a bad request to subscribe to an event using the PTP event api v2, an HTTP 409 Conflict response is received instead of a 400 Bad Request.

      Test Steps:

      1. Deploy ptp-operator with v2 event
      2. Create a valid subscription to an event.
      3. Deploy a consumer and send a specific incorrect subscribe request to the same event. The wrong request must have an incorrect field ResourceAddress. Note that it is not an incorrect value, the key field must be wrongly named.

      Result:
      First, create a valid subscription. See that the subscription is listed

      curl -v -X GET "http://${URL}/api/ocloudNotifications/v2/subscriptions" | jq .
      [
        {
          "ResourceAddress": "/cluster/node/snonode.sno-worker-01.inbound-int.se-lab.eng.rdu2.dc.redhat.com/sync/sync-status/os-clock-sync-state",
          "EndpointUri": "http://localhost:9043/api/ocloudNotifications/v2/dummy",
          "SubscriptionId": "2c027fee-30dc-4ccf-8f2a-6d20b9542317",
          "UriLocation": "http://ptp-event-publisher-service-snonode.openshift-ptp.svc.cluster.local:9043/api/ocloudNotifications/v2/subscriptions/2c027fee-30dc-4ccf-8f2a-6d20b9542317"
        }
      ]

      Now, create an invalid subscription request. Notice that the request field ResourceAddress must be incorrectly called:

      curl  -X POST "http://${URL}/api/ocloudNotifications/v2/subscriptions" --header 'Content-Type: application/json' --data '{
        "EndpointUri": "http://localhost:9043/api/ocloudNotifications/v2/dummy",
        "ResourceERROR": "/cluster/node/snonode.sno-worker-01.inbound-int.se-lab.eng.rdu2.dc.redhat.com/sync/sync-status/os-clock-sync-state"
      }' -vvvvv
      < HTTP/1.1 409 Conflict
      curl  -X POST "http://${URL}/api/ocloudNotifications/v2/subscriptions" --header 'Content-Type: application/json' --data '{
        "EndpointUri": "http://localhost:9043/api/ocloudNotifications/v2/dummy",
        "nothing": "/cluster/node/snonode.sno-worker-01.inbound-int.se-lab.eng.rdu2.dc.redhat.com/sync/sync-status/os-clock-sync-state"
      }' -vvvvv
      < HTTP/1.1 409 Conflict
      curl  -X POST "http://${URL}/api/ocloudNotifications/v2/subscriptions" --header 'Content-Type: application/json' --data '{   
         "EndpointUri": "http://localhost:9043/api/ocloudNotifications/v2/dummy",   
         "ResourceERROR": "wrong route" }' -vvvvv
      < HTTP/1.1 409 Conflict

      See that a 409 Conflict HTTP response is sent instead of a 400 Bad Request.

      Expected Result:
      An HTTP 400 Bad Request must be returned. See that if the EndpointUri field is wrong named the correct HTTP code is received:

      curl  -X POST "http://${URL}/api/ocloudNotifications/v2/subscriptions" --header 'Content-Type: application/json' --data '{
        "ndpointUri": "http://localhost:9043/api/ocloudNotifications/v2/dummy",
        "ResourceAddress": "/cluster/node/snonode.sno-worker-01.inbound-int.se-lab.eng.rdu2.dc.redhat.com/sync/sync-status/os-clock-sync-state"
      }'
      < HTTP/1.1 400 Bad Request

       

              jacding@redhat.com Jack Ding
              jacding@redhat.com Jack Ding
              Hen Shay Hassid Hen Shay Hassid
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: