Skip to content

ready? method for remote_resource.as_json is always true #83

@kamaradclimber

Description

@kamaradclimber

To reproduce, build a simple template to an endpoint that returns a 401 with json content type (such as apache marathon api with authentication). The template will be considered ready immediately.

The cause is https://github.com/criteo/consul-templaterb/blob/master/lib/consul/async/json_endpoint.rb#L205 where

enforce_json_200 && !(200..299).cover?(http.response_header.status) && http.response_header['Content-Type'] != 'application/json'

should probably be replaced by:

enforce_json_200 && !(200..299).cover?(http.response_header.status) || http.response_header['Content-Type'] != 'application/json'

The logic should be: if the response is not a 200 OK or is not advertize as json, then it's an error.

This bug leads to consider template as immediately ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions