diff --git a/lib/zanzibar/actions/bundle.rb b/lib/zanzibar/actions/bundle.rb index b615b48..0ed019d 100644 --- a/lib/zanzibar/actions/bundle.rb +++ b/lib/zanzibar/actions/bundle.rb @@ -92,7 +92,7 @@ module Zanzibar downloaded_secrets = {} remote_secrets.each do |key, secret| - full_path = secret['prefix'] ? File.join(@setting['secret_dir'], secret['prefix']) : @setting['secret_dir'] + full_path = secret.has_key?('prefix') ? File.join(@settings['secret_dir'], secret['prefix']) : @settings['secret_dir'] downloaded_secrets[key] = download_one_secret(secret['id'], secret['label'], full_path, diff --git a/spec/files/Zanzifile b/spec/files/Zanzifile index 39c1fe3..ef01ff5 100644 --- a/spec/files/Zanzifile +++ b/spec/files/Zanzifile @@ -4,7 +4,6 @@ settings: domain: zanzitest.net secret_dir: secrets/ ignore_ssl: true -secrets: secrets: ssh_key: id: 2345 @@ -12,4 +11,4 @@ secrets: prefix_ssh_key: id: 2345 label: Private Key - prefix: ssh + prefix: ssh/ diff --git a/spec/lib/zanzibar/actions/bundle_spec.rb b/spec/lib/zanzibar/actions/bundle_spec.rb index 936b861..7dca6c0 100644 --- a/spec/lib/zanzibar/actions/bundle_spec.rb +++ b/spec/lib/zanzibar/actions/bundle_spec.rb @@ -24,9 +24,12 @@ describe Zanzibar::Cli do FakeFS::FileSystem.clone files stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx') - .to_return(body: AUTH_XML, status: 200).then - .to_return(body: SECRET_WITH_KEY_XML, status: 200).then - .to_return(body: PRIVATE_KEY_XML, status: 200) + .to_return({body: AUTH_XML, status: 200}).then + .to_return({body: SECRET_WITH_KEY_XML, status: 200}).then + .to_return({body: PRIVATE_KEY_XML, status: 200}).then + .to_return({body: AUTH_XML, status: 200}).then + .to_return({body: SECRET_WITH_KEY_XML, status: 200}).then + .to_return({body: PRIVATE_KEY_XML, status: 200}) Dir.chdir File.join(source_root, 'spec', 'files') end @@ -70,7 +73,7 @@ describe Zanzibar::Cli do it 'should not redownload files it already has' do expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout - expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(3) + expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(6) WebMock.reset! @@ -80,16 +83,19 @@ describe Zanzibar::Cli do it 'should redownload on update action' do expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout - expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(3) + expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(6) WebMock.reset! stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx') + .to_return({body: AUTH_XML, status: 200}).then + .to_return({body: SECRET_WITH_KEY_XML, status: 200}).then + .to_return({body: PRIVATE_KEY_XML, status: 200}).then .to_return(body: AUTH_XML, status: 200).then .to_return(body: SECRET_WITH_KEY_XML, status: 200).then .to_return(body: PRIVATE_KEY_XML, status: 200) expect { subject.update }.to output(/Finished downloading secrets/).to_stdout - expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(3) + expect(WebMock).to have_requested(:post, 'https://www.zanzitest.net/webservices/sswebservice.asmx').times(6) end it 'should reject a malformed Zanzifile' do