hawkular / hawkular-client-ruby

Ruby client for Hawkular
http://hawkular.org/
Apache License 2.0
8 stars 28 forks source link

Catch html auth failures and return sensible values to the caller #58

Closed pilhuhn closed 8 years ago

pilhuhn commented 8 years ago

If you run

    it 'Should err on bad credentials' do
      @creds = {
          username: '-XX-X-jdoe-X',
          password: 'password'
      }
      @client = Hawkular::Inventory::InventoryClient.create(credentials: @creds)

      @client.list_feeds

    end

Then you will see that the exception on console is some html crap from WF, that does not honor the supplied accept header.

We need to catch that and return something that makes sense. Similar if we run in a connection exception (wrong port, host unreachable, ... )

See https://github.com/ManageIQ/manageiq/issues/8239

jkremser commented 8 years ago

right, it can be replicated also with curl

curl --user jdoea:password -s -H "Accept: application/json" -H "Content-Type: application/json" 'http://localhost:8080/hawkular/inventory/feeds/' | less

It's probably Keycloak, not the inventory itself, I can look into it. Other option would be to have some kind of interceptor in the ruby gem layer.

pilhuhn commented 8 years ago

Let's leave this open for the moment and revisit once Hawkular-services has transitioned to use JAAS

jpkrohling commented 8 years ago

This is not Keycloak-specific, this is returned by Wildfly itself. So, this will still be true for a JAAS scenario. Ideally, the party making the HTTP call would check the HTTP status code before trying to parse the response body.