Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d91b418963 | ||
|
|
dfb897a088 | ||
|
|
9f7898cc0b | ||
|
|
4902299cd4 |
@@ -13,6 +13,8 @@ module Zanzibar
|
|||||||
def initialize(args = {})
|
def initialize(args = {})
|
||||||
if args[:username]
|
if args[:username]
|
||||||
@@username = args[:username]
|
@@username = args[:username]
|
||||||
|
elsif ENV['ZANZIBAR_USER']
|
||||||
|
@@username = ENV['ZANZIBAR_USER']
|
||||||
else
|
else
|
||||||
@@username = ENV['USER']
|
@@username = ENV['USER']
|
||||||
end
|
end
|
||||||
@@ -22,11 +24,15 @@ module Zanzibar
|
|||||||
else
|
else
|
||||||
@@wsdl = get_wsdl_location
|
@@wsdl = get_wsdl_location
|
||||||
end
|
end
|
||||||
|
|
||||||
if args[:pwd]
|
if args[:pwd]
|
||||||
@@password = args[:pwd]
|
@@password = args[:pwd]
|
||||||
|
elsif ENV['ZANZIBAR_PASSWORD']
|
||||||
|
@@password = ENV['ZANZIBAR_PASSWORD']
|
||||||
else
|
else
|
||||||
@@password = prompt_for_password
|
@@password = prompt_for_password
|
||||||
end
|
end
|
||||||
|
|
||||||
if args[:domain]
|
if args[:domain]
|
||||||
@@domain = args[:domain]
|
@@domain = args[:domain]
|
||||||
else
|
else
|
||||||
@@ -36,6 +42,14 @@ module Zanzibar
|
|||||||
init_client(args[:globals])
|
init_client(args[:globals])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_client_username
|
||||||
|
@@username
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_client_password
|
||||||
|
@@password
|
||||||
|
end
|
||||||
|
|
||||||
## Initializes the Savon client class variable with the wdsl document location and optional global variables
|
## Initializes the Savon client class variable with the wdsl document location and optional global variables
|
||||||
# @param globals{}, optional
|
# @param globals{}, optional
|
||||||
|
|
||||||
@@ -151,6 +165,7 @@ module Zanzibar
|
|||||||
.hash[:envelope][:body][:download_file_attachment_by_item_id_response][:download_file_attachment_by_item_id_result]
|
.hash[:envelope][:body][:download_file_attachment_by_item_id_response][:download_file_attachment_by_item_id_result]
|
||||||
fail "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{response[:errors][:string]}" if response[:errors]
|
fail "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{response[:errors][:string]}" if response[:errors]
|
||||||
write_secret_to_file(path, response)
|
write_secret_to_file(path, response)
|
||||||
|
return File.join(path, response[:file_name])
|
||||||
rescue Savon::Error => err
|
rescue Savon::Error => err
|
||||||
raise "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{err}"
|
raise "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{err}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Zanzibar
|
module Zanzibar
|
||||||
VERSION = '0.1.11'
|
VERSION = '0.1.13'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,4 +110,14 @@ describe 'Zanzibar Test' do
|
|||||||
expect(File.read('attachment.txt')).to eq("I am a secret attachment\n")
|
expect(File.read('attachment.txt')).to eq("I am a secret attachment\n")
|
||||||
File.delete('attachment.txt')
|
File.delete('attachment.txt')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should use environment variables for credentials' do
|
||||||
|
ENV['ZANZIBAR_USER'] = "environment_user"
|
||||||
|
ENV['ZANZIBAR_PASSWORD'] = "environment_password"
|
||||||
|
client = Zanzibar::Zanzibar.new(domain: 'zanzitest.net', wsdl: 'spec/scrt.wsdl')
|
||||||
|
expect(client.get_client_username).to eq(ENV['ZANZIBAR_USER'])
|
||||||
|
expect(client.get_client_password).to eq(ENV['ZANZIBAR_PASSWORD'])
|
||||||
|
ENV.delete 'ZANZIBAR_PASSWORD'
|
||||||
|
ENV.delete 'ZANZIBAR_USER'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user