zanzibar 0.1.24 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzJiNTg4OTE0YjFlYjViZTIyYWRmMWU2MDExZmM0NzVkMWVkYTkwMQ==
4
+ OGUxZDk3YjZhOTljMGI5NGRjMjIyZGI2M2ZjN2Y3ZGM1NmY5ODllZg==
5
5
  data.tar.gz: !binary |-
6
- MWFjNjRkM2U3YWNhMjA2YTcyMzg5NTYzMTA4MGJkZGM4ODkxZDQ5OQ==
6
+ MTkwY2NhNDVkNmE3Y2I0NDk2NmNmZWZlNzE2MDUzYzFhNDA0OTBlOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzBmZTYyMmE0MmNkNzU0MDc1ZmU1YjI0YmNmMzhmYTVkMDliYjNkMTRhZDlm
10
- YTY2ZDgxYjczZmUwMDNlMjgyMjUyOTE1M2ZmMmY3M2FlZTJlM2NhYjVhZmQ5
11
- ZDliYjQ4ZDgzYzMwOWExNjUzZjllMTIxZDVjOWQ1ZWI0NTVkYTU=
9
+ ZDliNjVkMzA2NDU4NDAwYmJhNDliMGI1ZTEwYzZjYmM2ZmIwYTE4NjUyZTQ2
10
+ NTQzMTdkZDRmNjE0Mzg5NDk3NmM3YmQzYTJhNDdjZDlhMTQ1NGQ4ZTJjNjVk
11
+ Y2NjOTY0MDQwYTNhZWI5ZmY1NGNmMTU5NDdjYmFiYjc4MDMxYzQ=
12
12
  data.tar.gz: !binary |-
13
- MjFmMDQ4NWM1ZDliZDU1ZTYyZGNkMGEzNzc2NDkwODExYWFlOTNhYjE1YTBm
14
- MjA0ZTQ3OGM4MWUwNGNkM2RkMDE4YTM4OWM4MWQyOWQ1MzRjMDVlNjhjYWM2
15
- ODA3ZjIyYzYyYWM2YjczYWM3MjlkMzc3NzAwMzJiZGI4ZDU1ZWM=
13
+ YTU2N2E5YzM0Zjc1NDY0NjZiNmM1MzdhMjIyYmI5ODY1YjI5N2E1MzM5NmE2
14
+ MmM5YmFkYzlmMzlhNDQzNTY3NWQ3NmM4NWJiNzQ5Zjk5NjcwNjFhNjQ2OGJj
15
+ MzNiOGNhMGJjNzc5MWJkZWYyYzk1ZGRiNWI2OGQxZWVmNThlMjQ=
@@ -113,17 +113,25 @@ module Zanzibar
113
113
  raise "There was an error getting the secret with id #{scrt_id}: #{err}"
114
114
  end
115
115
 
116
- ## Retrieve a simple password from a secret
116
+ ## Retrieve the value from a field label of a secret
117
117
  # Will raise an error if there are any issues
118
118
  # @param [Integer] the secret id
119
- # @return [String] the password for the given secret
120
-
121
- def get_password(scrt_id)
119
+ # @param [String] the field label to get, defaults to Password
120
+ # @return [String] the value for the given field label
121
+ def get_fieldlabel_value(scrt_id, fieldlabel = 'Password')
122
122
  secret = get_secret(scrt_id)
123
123
  secret_items = secret[:secret][:items][:secret_item]
124
- return get_secret_item_by_field_name(secret_items, 'Password')[:value]
124
+ return get_secret_item_by_field_name(secret_items, fieldlabel)[:value]
125
125
  rescue Savon::Error => err
126
- raise "There was an error getting the password for secret #{scrt_id}: #{err}"
126
+ raise "There was an error getting '#{fieldlabel}' for secret #{scrt_id}: #{err}"
127
+ end
128
+
129
+ ## Retrieve a simple password from a secret
130
+ # Calls get get_fieldlabel_value()
131
+ # @param [Integer] the secret id
132
+ # @return [String] the password for the given secret
133
+ def get_password(scrt_id)
134
+ return get_fieldlabel_value(scrt_id)
127
135
  end
128
136
 
129
137
  ## Get the password, save it to a file, and return the path to the file.
@@ -20,18 +20,19 @@ module Zanzibar
20
20
  construct_options
21
21
  ensure_options
22
22
 
23
- fetch_secret(@scrt_id, options['filelabel'])
23
+ fetch_secret(@scrt_id)
24
24
  end
25
25
 
26
- def fetch_secret(scrt_id, label = nil)
26
+ def fetch_secret(scrt_id)
27
27
  scrt = ::Zanzibar::Zanzibar.new(@zanzibar_options)
28
28
 
29
- if label
29
+ if @zanzibar_options[:filelabel]
30
30
  scrt.download_secret_file(scrt_id: scrt_id,
31
- type: label)
31
+ type: @zanzibar_options[:filelabel])
32
32
  else
33
- scrt.get_password(scrt_id)
33
+ scrt.get_fieldlabel_value(scrt_id, @zanzibar_options[:fieldlabel])
34
34
  end
35
+
35
36
  end
36
37
 
37
38
  def construct_options
@@ -40,6 +41,8 @@ module Zanzibar
40
41
  @zanzibar_options[:domain] = options['domain']
41
42
  @zanzibar_options[:username] = options['username'] unless options['username'].nil?
42
43
  @zanzibar_options[:domain] = options['domain'] ? options['domain'] : 'local'
44
+ @zanzibar_options[:fieldlabel] = options['fieldlabel'] || 'Password'
45
+ @zanzibar_options[:filelabel] = options['filelabel'] if options['filelabel']
43
46
  end
44
47
 
45
48
  def construct_wsdl
@@ -76,6 +76,8 @@ module Zanzibar
76
76
  desc: 'Don\'t verify Secret Server\'s SSL certificate'
77
77
  option 'filelabel', type: :string, aliases: :f,
78
78
  desc: 'Specify a file (by label) to download'
79
+ option 'fieldlabel', type: :string, aliases: :l,
80
+ desc: 'Specify a field (by label) to get'
79
81
  option 'username', type: :string, aliases: :u
80
82
  option 'password', type: :string, aliases: :p
81
83
  def get(scrt_id)
@@ -1,4 +1,4 @@
1
1
  # The version of the gem
2
2
  module Zanzibar
3
- VERSION = '0.1.24'
3
+ VERSION = '0.1.27'
4
4
  end
@@ -47,6 +47,11 @@ describe Zanzibar::Cli do
47
47
  expect { subject.get(1234) }.to raise_error.with_message(/#{Zanzibar::NO_WSDL_ERROR}/)
48
48
  end
49
49
 
50
+ it 'should be able to get a field value' do
51
+ subject.options = { 'domain' => 'zanzitest.net', 'wsdl' => 'scrt.wsdl', 'fieldlabel' => 'Username' }
52
+ expect { subject.get(1234) }.to output(/ZanziUser/).to_stdout
53
+ end
54
+
50
55
  it 'should be able to download files' do
51
56
  WebMock.reset!
52
57
  stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zanzibar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Davis-Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler