Skip to content

Commit

Permalink
Improve acl info method when the acl does not exist
Browse files Browse the repository at this point in the history
According to https://www.consul.io/docs/agent/http/acl.html, when the
acl does not exist, return value is "null" instead of nothing.

Fixes WeAreFarmGeek#71
  • Loading branch information
kamaradclimber committed Apr 13, 2016
1 parent 3cdbd1e commit 8a0f52d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/diplomat/acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def info id, options=nil, not_found=:reject, found=:return
url += use_consistency(@options)

raw = @conn_no_err.get concat_url url
if raw.status == 200 and raw.body
if raw.status == 200 and raw.body != "null"
case found
when :reject
raise Diplomat::AclAlreadyExists, @id
when :return
@raw = raw
return parse_body
end
elsif raw.status == 200 and !raw.body
elsif raw.status == 200 and raw.body == "null"
case not_found
when :reject
raise Diplomat::AclNotFound, @id
Expand Down
2 changes: 1 addition & 1 deletion spec/acl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
end

it "returns does not return acl" do
json = nil
json = 'null'

url = key_url + '/info/' + 'none'
expect(faraday).to receive(:get).with(/#{url}/).and_return(OpenStruct.new({ body: json, status: 200}))
Expand Down

0 comments on commit 8a0f52d

Please sign in to comment.