Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
804d044632 | ||
|
|
813b171d26 | ||
|
|
7a0ce1c04d | ||
|
|
49ea9ab9fa | ||
|
|
60e0d52ab4 | ||
|
|
e3ec56210b | ||
|
|
315d3d6499 | ||
|
|
0763265be1 | ||
|
|
8126deded5 | ||
|
|
60545c5b7b | ||
|
|
8b06192aa1 | ||
|
|
244b9178b8 |
@@ -1,7 +1,10 @@
|
|||||||
|
sudo: false
|
||||||
language: ruby
|
language: ruby
|
||||||
rvm:
|
rvm:
|
||||||
- 1.9.3
|
- 1.9.3
|
||||||
- 2.0.0
|
- 2.0.0
|
||||||
|
- 2.1.7
|
||||||
|
- 2.2.3
|
||||||
addons:
|
addons:
|
||||||
code_climate:
|
code_climate:
|
||||||
repo_token:
|
repo_token:
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ When it downloads a file, it gets added to `Zanzifile.resolved`. And next time
|
|||||||
`resolved` file, it will not attempt to re-download. `zanzibar update` will attempt
|
`resolved` file, it will not attempt to re-download. `zanzibar update` will attempt
|
||||||
to re-download all secrets.
|
to re-download all secrets.
|
||||||
|
|
||||||
|
Subdirectories under the root directory `secret_dir` can be created for individual keys by specifying a `prefix` path for that secret. Secrets will default to be downloaded to the root `secret_dir` directory otherwise.
|
||||||
|
|
||||||
Note: `zanzibar get` can fetch passwords or files, but `zanzibar bundle` can
|
Note: `zanzibar get` can fetch passwords or files, but `zanzibar bundle` can
|
||||||
only operate on secret files.
|
only operate on secret files.
|
||||||
|
|
||||||
@@ -114,6 +116,7 @@ secrets:
|
|||||||
ssh_key:
|
ssh_key:
|
||||||
id: 249
|
id: 249
|
||||||
label: Private Key
|
label: Private Key
|
||||||
|
prefix: ssh/
|
||||||
encryption_key:
|
encryption_key:
|
||||||
id: 483
|
id: 483
|
||||||
label: Attachment
|
label: Attachment
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ module Zanzibar
|
|||||||
def prompt_for_password
|
def prompt_for_password
|
||||||
puts "Please enter password for #{@@username}:"
|
puts "Please enter password for #{@@username}:"
|
||||||
STDIN.noecho(&:gets).chomp
|
STDIN.noecho(&:gets).chomp
|
||||||
|
puts "Using password to login..."
|
||||||
end
|
end
|
||||||
|
|
||||||
## Gets the wsdl document location if none is provided in the constructor
|
## Gets the wsdl document location if none is provided in the constructor
|
||||||
|
|||||||
@@ -47,12 +47,14 @@ module Zanzibar
|
|||||||
## Make sure the directory exists and that a .gitignore is there to ignore it
|
## Make sure the directory exists and that a .gitignore is there to ignore it
|
||||||
if @settings['secret_dir']
|
if @settings['secret_dir']
|
||||||
FileUtils.mkdir_p(@settings['secret_dir'])
|
FileUtils.mkdir_p(@settings['secret_dir'])
|
||||||
|
if !File.exist? "#{@settings['secret_dir']}/.gitignore"
|
||||||
File.open("#{@settings['secret_dir']}/.gitignore", 'w') do |file|
|
File.open("#{@settings['secret_dir']}/.gitignore", 'w') do |file|
|
||||||
file.puts '*'
|
file.puts '*'
|
||||||
file.puts '!.gitignore'
|
file.puts '!.gitignore'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def resolved_file?
|
def resolved_file?
|
||||||
File.exist? RESOLVED_NAME
|
File.exist? RESOLVED_NAME
|
||||||
@@ -92,9 +94,10 @@ module Zanzibar
|
|||||||
|
|
||||||
downloaded_secrets = {}
|
downloaded_secrets = {}
|
||||||
remote_secrets.each do |key, secret|
|
remote_secrets.each do |key, secret|
|
||||||
|
full_path = secret.has_key?('prefix') ? File.join(@settings['secret_dir'], secret['prefix']) : @settings['secret_dir']
|
||||||
downloaded_secrets[key] = download_one_secret(secret['id'],
|
downloaded_secrets[key] = download_one_secret(secret['id'],
|
||||||
secret['label'],
|
secret['label'],
|
||||||
@settings['secret_dir'],
|
full_path,
|
||||||
args,
|
args,
|
||||||
secret['name'] || "#{secret['id']}_password")
|
secret['name'] || "#{secret['id']}_password")
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ module Zanzibar
|
|||||||
def fetch_secret(scrt_id, label = nil)
|
def fetch_secret(scrt_id, label = nil)
|
||||||
scrt = ::Zanzibar::Zanzibar.new(@zanzibar_options)
|
scrt = ::Zanzibar::Zanzibar.new(@zanzibar_options)
|
||||||
|
|
||||||
puts @zanzibar_options
|
|
||||||
|
|
||||||
if label
|
if label
|
||||||
scrt.download_secret_file(scrt_id: scrt_id,
|
scrt.download_secret_file(scrt_id: scrt_id,
|
||||||
type: label)
|
type: label)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# The version of the gem
|
# The version of the gem
|
||||||
module Zanzibar
|
module Zanzibar
|
||||||
VERSION = '0.1.18'
|
VERSION = '0.1.21'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ settings:
|
|||||||
domain: zanzitest.net
|
domain: zanzitest.net
|
||||||
secret_dir: secrets/
|
secret_dir: secrets/
|
||||||
ignore_ssl: true
|
ignore_ssl: true
|
||||||
secrets:
|
|
||||||
secrets:
|
secrets:
|
||||||
ssh_key:
|
ssh_key:
|
||||||
id: 2345
|
id: 2345
|
||||||
label: Private Key
|
label: Private Key
|
||||||
|
prefix_ssh_key:
|
||||||
|
id: 2345
|
||||||
|
label: Private Key
|
||||||
|
prefix: ssh/
|
||||||
|
|||||||
@@ -24,9 +24,12 @@ describe Zanzibar::Cli do
|
|||||||
FakeFS::FileSystem.clone files
|
FakeFS::FileSystem.clone files
|
||||||
|
|
||||||
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
||||||
.to_return(body: AUTH_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: SECRET_WITH_KEY_XML, status: 200}).then
|
||||||
.to_return(body: PRIVATE_KEY_XML, status: 200)
|
.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')
|
Dir.chdir File.join(source_root, 'spec', 'files')
|
||||||
end
|
end
|
||||||
@@ -50,6 +53,12 @@ describe Zanzibar::Cli do
|
|||||||
expect(FakeFS::FileTest.file? File.join('secrets', 'zanzi_key')).to be(true)
|
expect(FakeFS::FileTest.file? File.join('secrets', 'zanzi_key')).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should download a file to a prefix' do
|
||||||
|
expect(FakeFS::FileTest.file? File.join('secrets/ssh', 'zanzi_key')).to be(false)
|
||||||
|
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
|
||||||
|
expect(FakeFS::FileTest.file? File.join('secrets/ssh', 'zanzi_key')).to be(true)
|
||||||
|
end
|
||||||
|
|
||||||
it 'should create a .gitignore' do
|
it 'should create a .gitignore' do
|
||||||
expect(FakeFS::FileTest.file? File.join('secrets', '.gitignore')).to be(false)
|
expect(FakeFS::FileTest.file? File.join('secrets', '.gitignore')).to be(false)
|
||||||
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
|
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
|
||||||
@@ -64,7 +73,7 @@ describe Zanzibar::Cli do
|
|||||||
|
|
||||||
it 'should not redownload files it already has' do
|
it 'should not redownload files it already has' do
|
||||||
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
|
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!
|
WebMock.reset!
|
||||||
|
|
||||||
@@ -74,16 +83,19 @@ describe Zanzibar::Cli do
|
|||||||
|
|
||||||
it 'should redownload on update action' do
|
it 'should redownload on update action' do
|
||||||
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
|
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!
|
WebMock.reset!
|
||||||
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
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: AUTH_XML, status: 200).then
|
||||||
.to_return(body: SECRET_WITH_KEY_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: PRIVATE_KEY_XML, status: 200)
|
||||||
|
|
||||||
expect { subject.update }.to output(/Finished downloading secrets/).to_stdout
|
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
|
end
|
||||||
|
|
||||||
it 'should reject a malformed Zanzifile' do
|
it 'should reject a malformed Zanzifile' do
|
||||||
|
|||||||
Reference in New Issue
Block a user