Uploaded image for project: 'Hybrid Cloud Console'
  1. Hybrid Cloud Console
  2. RHCLOUD-21906

Notifications API - There's no validation if endpoint already exist when adding endpoint to an event_type

XMLWordPrintable

    • False
    • False
    • Unset
    • None
    • Undefined

      I was able to run the same request twice, it resulted in replicated endpoint for an event_type.

      Example of the request that I ran twice: 

      curl -XPUT -i -u insights-qa:redhat https://qa.cloud.redhat.com/api/notifications/v1.0/notifications/eventTypes/d8be5c7b-1a3b-4aaf-b0e2-6d02b8198d5f/82622b10-c995-4c1d-9c1f-2469af4a9a51
      HTTP/1.1 200 OK
      X-Powered-By: Express
      x-fakamai-env: qa
      x-fakamai-app-hint: API
      x-fakamai-downstream-host: https://api-gateway-qa.5a9f.insights-dev.openshiftapps.com
      server: openresty/1.13.6.1
      date: Mon, 10 May 2021 13:09:35 GMT
      content-type: text/plain
      x-rh-insights-request-id: 4e9e58f35e9f470da7222a89c4afabb1
      x-content-type-options: nosniff
      set-cookie: a549c90418df47840900855e57bbdfae=658bfb05386bb1cc98730d68634f5b51; path=/; HttpOnly; Secure
      connection: keep-alive
      Transfer-Encoding: chunked

       See screenshot from the UI after adding the same webhook.

      The result as you can see, the same endpoint appears twice:

      curl -XGET -i -u insights-qa:redhat https://qa.cloud.redhat.com/api/notifications/v1.0/notifications/eventTypes/d8be5c7b-1a3b-4aaf-b0e2-6d02b8198d5f
      HTTP/1.1 200 OK
      X-Powered-By: Express
      x-fakamai-env: qa
      x-fakamai-app-hint: API
      x-fakamai-downstream-host: https://api-gateway-qa.5a9f.insights-dev.openshiftapps.com
      server: openresty/1.13.6.1
      date: Mon, 10 May 2021 13:14:08 GMT
      content-type: application/json
      x-rh-insights-request-id: af7ea09e727c4d5c84425540420065cf
      x-content-type-options: nosniff
      set-cookie: a549c90418df47840900855e57bbdfae=658bfb05386bb1cc98730d68634f5b51; path=/; HttpOnly; Secure
      cache-control: private
      connection: keep-alive
      Transfer-Encoding: chunked
      [{"created":"2021-05-10T13:05:45.944323","id":"82622b10-c995-4c1d-9c1f-2469af4a9a51","name":"QA testing","description":"","enabled":true,"type":"webhook","properties":{"url":"https://1.1.1.1","method":"POST","disable_ssl_verification":false,"secret_token":null,"basic_authentication":null}},{"created":"2021-05-10T13:05:45.944323","id":"82622b10-c995-4c1d-9c1f-2469af4a9a51","name":"QA testing","description":"","enabled":true,"type":"webhook","properties":{"url":"https://1.1.1.1","method":"POST","disable_ssl_verification":false,"secret_token":null,"basic_authentication":null}}]
      

       

      And of course when deleting one of them it delete both, because they have the same id:

      Delete:

      curl -XDELETE -i -u insights-qa:redhat https://qa.cloud.redhat.com/api/notifications/v1.0/notifications/eventTypes/d8be5c7b-1a3b-4aaf-b0e2-6d02b8198d5f/82622b10-c995-4c1d-9c1f-2469af4a9a51
      HTTP/1.1 204 No Content
      X-Powered-By: Express
      x-fakamai-env: qa
      x-fakamai-app-hint: API
      x-fakamai-downstream-host: https://api-gateway-qa.5a9f.insights-dev.openshiftapps.com
      server: openresty/1.13.6.1
      date: Mon, 10 May 2021 13:15:23 GMT
      content-type: text/plain
      x-rh-insights-request-id: 75c985b5d3854167ad59d97d9f8c57eb
      x-content-type-options: nosniff
      set-cookie: a549c90418df47840900855e57bbdfae=192fa80f2225f09dde614bfa6ff2a652; path=/; HttpOnly; Secure
      connection: keep-alive

      Get: 

      curl -XGET -i -u insights-qa:redhat https://qa.cloud.redhat.com/api/notifications/v1.0/notifications/eventTypes/d8be5c7b-1a3b-4aaf-b0e2-6d02b8198d5f
      HTTP/1.1 200 OK
      X-Powered-By: Express
      x-fakamai-env: qa
      x-fakamai-app-hint: API
      x-fakamai-downstream-host: https://api-gateway-qa.5a9f.insights-dev.openshiftapps.com
      server: openresty/1.13.6.1
      date: Mon, 10 May 2021 13:16:01 GMT
      content-type: application/json
      x-rh-insights-request-id: a120b244e6ed41b6aa30a67e7cfac434
      x-content-type-options: nosniff
      set-cookie: a549c90418df47840900855e57bbdfae=192fa80f2225f09dde614bfa6ff2a652; path=/; HttpOnly; Secure
      cache-control: private
      connection: keep-alive
      Transfer-Encoding: chunked
      []
      

       

              pilhuhn Heiko Rupp
              ylahav Yuval Lahav
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: