forked from criteo-forks/consul-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request criteo-forks#8 from Mwea/feature/acl_retry
Merge Consul ACL Retry
- Loading branch information
Showing
4 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
~FC019 | ||
~FC028 | ||
~FC044 | ||
~FC109 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
require 'webmock/rspec' | ||
require 'diplomat' | ||
require_relative '../../../libraries/consul_acl' | ||
|
||
describe ConsulCookbook::Resource::ConsulAcl do | ||
step_into(:consul_acl) | ||
let(:chefspec_options) { { platform: 'ubuntu', version: '14.04' } } | ||
|
||
context 'when the Consul agent is not ready' do | ||
let(:info_body) do | ||
[ | ||
{ | ||
'CreateIndex' => 3, | ||
'ModifyIndex' => 3, | ||
'ID' => 'client_token', | ||
'Name' => 'Client Token', | ||
'Type' => 'client', | ||
'Rules' => { | ||
'service' => { | ||
'' => { | ||
'policy' => 'write', | ||
}, | ||
}, | ||
}, | ||
}, | ||
] | ||
end | ||
before do | ||
json = JSON.generate(info_body.first) | ||
stub_request(:get, %r{/v1/acl/info/}) | ||
.to_return(body: 'No cluster leader', status: 500).then | ||
.to_return(body: json, status: 200) | ||
stub_request(:put, %r{/v1/acl/create}) | ||
.to_return(body: json, status: 200) | ||
end | ||
|
||
recipe do | ||
consul_acl 'client_token' do | ||
acl_name 'Client Token' | ||
type 'client' | ||
auth_token 'ABC123' | ||
end | ||
end | ||
|
||
it do | ||
expect { chef_run }.to_not raise_error | ||
end | ||
end | ||
end |