zanzibar 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile +2 -1
- data/README.md +10 -10
- data/Rakefile +11 -8
- data/bin/zamioculcas +1 -69
- data/bin/zanzibar +70 -0
- data/lib/zanzibar.rb +27 -40
- data/lib/zanzibar/version.rb +1 -1
- data/spec/spec/spec_helper.rb +95 -97
- data/spec/zanzibar_spec.rb +113 -116
- data/zanzibar.gemspec +13 -12
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MjRjNDk1YTE4MDIxYWNlNDljZGYzN2YyYWNhMzQ1ZTgwZTE2YjkzNg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
ZTI3YjhhNzNiMmZiZTkzMTI3MmRlZTYxYjBlZTVkZDVjODZmZmQwZg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
YjZmMWMwNTgyMGI0NzllNGY3MzhmMTA5YzllOTU4NTliMDFhNWVlYTk5Nzlm
|
|
10
|
+
MjViYWI2MDY5YTMzNzA5OTEzZGZlNDI1MmRkZjE3MDY1M2I4NGFkMjU1YmZm
|
|
11
|
+
MjdiMzBhYzJjZTE0YzYxZDQwYmRmNjI5ZjcwMzIzYTM3MzViYzc=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Y2RkYTQ4NjQ3ZTBlZjEzZTY4NjU1ZDNkNTJjZjMyYTQzNDFlZDBlNmNmZjlm
|
|
14
|
+
MDA3ZjVmOWE5Njg0MjIzZDdjNWI1OTc0NzNiMjllNTNkZDg1ZGUzNGI5MDE0
|
|
15
|
+
NTdhNTJmMDIyYTUwOGJiODU0NGI3ZjM1NjZiNWFkYTFmYjc1NmU=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -38,29 +38,29 @@ secrets = Zanzibar::Zanzibar.new(:domain => 'mydomain.net', :wsdl => "https://my
|
|
|
38
38
|
# Zanzibar::Zanzibar.new(:domain => 'mydomain.net', :wsdl => "https://my.scrt.server/webservices/sswebservice.asmx?wsdl", :globals => {:ssl_verify_mode => :none})
|
|
39
39
|
|
|
40
40
|
## Simple password -> takes secret id as argument
|
|
41
|
-
secrets.
|
|
41
|
+
secrets.get_password(1234)
|
|
42
42
|
|
|
43
|
-
## Private Key -> takes hash as argument, requires :scrt_id, optional :scrt_item_id, :path
|
|
44
|
-
secrets.
|
|
43
|
+
## Private Key -> takes hash as argument, requires :scrt_id, :type, optional :scrt_item_id, :path
|
|
44
|
+
secrets.download_secret_file(:scrt_id => 2345, :path => 'secrets/', :type => "Private Key")
|
|
45
45
|
|
|
46
|
-
## Public Key -> takes hash as argument, requires :scrt_id, optional :scrt_item_id, :path
|
|
47
|
-
secrets.
|
|
46
|
+
## Public Key -> takes hash as argument, requires :scrt_id, :type, optional :scrt_item_id, :path
|
|
47
|
+
secrets.download_secret_file(:scrt_id => 2345, :path => 'secrets/', :type => "Public Key")
|
|
48
48
|
|
|
49
|
-
## Attachment; only supports secrets with single attachment -> takes hash as argument, requires :scrt_id, optional :scrt_item_id, :path
|
|
50
|
-
secrets.
|
|
49
|
+
## Attachment; only supports secrets with single attachment -> takes hash as argument, requires :scrt_id, :path, optional :scrt_item_id, :path
|
|
50
|
+
secrets.download_secret_file(:scrt_id => 2345, :path => 'secrets/', :type => "Attachment")
|
|
51
51
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### Command Line
|
|
55
55
|
|
|
56
|
-
Zanzibar comes bundled with the
|
|
56
|
+
Zanzibar comes bundled with the `zanzibar` command-line utility that can be used for fetching passwords and downloading keys from outside of Ruby.
|
|
57
57
|
|
|
58
|
-
`
|
|
58
|
+
`zanzibar` supports most actions provided by Zanzibar itself. Because it operates on the command-line, it can be used as part of a pipeline or within a bash script.
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
61
|
# if you don't pipe in a password, you will be prompted to enter one.
|
|
62
62
|
# this will download the private key from secret 1984 to the current directory
|
|
63
|
-
cat ./local-password |
|
|
63
|
+
cat ./local-password | zanzibar 1984 -s server.example.com -d example.com -t privatekey
|
|
64
64
|
|
|
65
65
|
ssh user@someremote -i ./private_key
|
|
66
66
|
```
|
data/Rakefile
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require 'rspec/core/rake_task'
|
|
4
|
-
require 'zanzibar/version'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'bundler/setup' # load up our gem environment (incl. local zanzibar)
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
require 'zanzibar/version'
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
|
+
|
|
7
|
+
task default: [:test]
|
|
8
|
+
|
|
9
|
+
RSpec::Core::RakeTask.new(:test)
|
|
10
|
+
|
|
11
|
+
RuboCop::RakeTask.new
|
data/bin/zamioculcas
CHANGED
|
@@ -1,70 +1,2 @@
|
|
|
1
1
|
#! ruby
|
|
2
|
-
|
|
3
|
-
require 'zanzibar'
|
|
4
|
-
require 'optparse'
|
|
5
|
-
|
|
6
|
-
options = {
|
|
7
|
-
:domain => 'local'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
OptionParser.new do |opts|
|
|
11
|
-
opts.banner = "Usage: zamioculcas -d domain [-w wsdl] [-k] [-p] [secret_id]"
|
|
12
|
-
|
|
13
|
-
opts.on("-d", "--domain DOMAIN", "Specify domain") do |v|
|
|
14
|
-
options[:domain] = v
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
opts.on("-w", "--wsdl WSDL", "Specify WSDL location") do |v|
|
|
18
|
-
options[:wsdl] = v
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
opts.on("-s", "--server SERVER", "Secret server hostname or IP") do |v|
|
|
22
|
-
options[:server] = v
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
opts.on("-k", "--no-check-certificate", "Don't run SSL certificate checks") do |v|
|
|
26
|
-
options[:globals] = {:ssl_verify_mode => :none}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
opts.on("-p", "--password PASSWORD", "Specify password") do |v|
|
|
30
|
-
options[:pwd] = v
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
opts.on("-t", "--type TYPE", "Specify the type of secret") do |v|
|
|
34
|
-
options[:type] = v
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
opts.on("-u", "--user USER", "Specify the username") do |v|
|
|
38
|
-
options[:username] = v
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end.parse!
|
|
42
|
-
|
|
43
|
-
raise OptionParser::MissingArgument if options[:server].nil?
|
|
44
|
-
options[:type] = "password" if options[:type].nil?
|
|
45
|
-
|
|
46
|
-
unless STDIN.tty? || options[:pwd]
|
|
47
|
-
options[:pwd] = $stdin.read.strip
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
secret_id = Integer(ARGV.pop)
|
|
51
|
-
if(!secret_id)
|
|
52
|
-
fail "no secret!"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
unless options[:wsdl] || options[:server].nil?
|
|
56
|
-
options[:wsdl] = "https://#{options[:server]}/webservices/sswebservice.asmx?wsdl"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
scrt = Zanzibar::Zanzibar.new(options)
|
|
60
|
-
|
|
61
|
-
case options[:type]
|
|
62
|
-
when "password"
|
|
63
|
-
$stdout.write "#{scrt.get_password(secret_id)}\n"
|
|
64
|
-
when "privatekey"
|
|
65
|
-
scrt.download_private_key(:scrt_id=>secret_id)
|
|
66
|
-
when "publickey"
|
|
67
|
-
scrt.download_public_key(:scrt_id=>secret_id)
|
|
68
|
-
else
|
|
69
|
-
$stderr.write "#{options[:type]} is not a known type."
|
|
70
|
-
end
|
|
2
|
+
system("zanzibar #{ARGV.join(" ")}")
|
data/bin/zanzibar
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#! ruby
|
|
2
|
+
|
|
3
|
+
require 'zanzibar'
|
|
4
|
+
require 'optparse'
|
|
5
|
+
|
|
6
|
+
options = {
|
|
7
|
+
:domain => 'local'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
OptionParser.new do |opts|
|
|
11
|
+
opts.banner = "Usage: zamioculcas -d domain [-w wsdl] [-k] [-p] [secret_id]"
|
|
12
|
+
|
|
13
|
+
opts.on("-d", "--domain DOMAIN", "Specify domain") do |v|
|
|
14
|
+
options[:domain] = v
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
opts.on("-w", "--wsdl WSDL", "Specify WSDL location") do |v|
|
|
18
|
+
options[:wsdl] = v
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
opts.on("-s", "--server SERVER", "Secret server hostname or IP") do |v|
|
|
22
|
+
options[:server] = v
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
opts.on("-k", "--no-check-certificate", "Don't run SSL certificate checks") do |v|
|
|
26
|
+
options[:globals] = {:ssl_verify_mode => :none}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
opts.on("-p", "--password PASSWORD", "Specify password") do |v|
|
|
30
|
+
options[:pwd] = v
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
opts.on("-t", "--type TYPE", "Specify the type of secret") do |v|
|
|
34
|
+
options[:type] = v
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
opts.on("-u", "--user USER", "Specify the username") do |v|
|
|
38
|
+
options[:username] = v
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end.parse!
|
|
42
|
+
|
|
43
|
+
raise OptionParser::MissingArgument if options[:server].nil?
|
|
44
|
+
options[:type] = "password" if options[:type].nil?
|
|
45
|
+
|
|
46
|
+
unless STDIN.tty? || options[:pwd]
|
|
47
|
+
options[:pwd] = $stdin.read.strip
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
secret_id = Integer(ARGV.pop)
|
|
51
|
+
if(!secret_id)
|
|
52
|
+
fail "no secret!"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
unless options[:wsdl] || options[:server].nil?
|
|
56
|
+
options[:wsdl] = "https://#{options[:server]}/webservices/sswebservice.asmx?wsdl"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
scrt = Zanzibar::Zanzibar.new(options)
|
|
60
|
+
|
|
61
|
+
case options[:type]
|
|
62
|
+
when "password"
|
|
63
|
+
$stdout.write "#{scrt.get_password(secret_id)}\n"
|
|
64
|
+
when "privatekey"
|
|
65
|
+
scrt.download_private_key(:scrt_id=>secret_id)
|
|
66
|
+
when "publickey"
|
|
67
|
+
scrt.download_public_key(:scrt_id=>secret_id)
|
|
68
|
+
else
|
|
69
|
+
$stderr.write "#{options[:type]} is not a known type."
|
|
70
|
+
end
|
data/lib/zanzibar.rb
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'zanzibar/version'
|
|
2
2
|
require 'savon'
|
|
3
3
|
require 'io/console'
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
|
|
6
6
|
module Zanzibar
|
|
7
|
-
|
|
8
7
|
##
|
|
9
8
|
# Class for interacting with Secret Server
|
|
10
9
|
class Zanzibar
|
|
11
|
-
|
|
12
10
|
##
|
|
13
11
|
# @param args{:domain, :wsdl, :pwd, :username, :globals{}}
|
|
14
12
|
|
|
15
13
|
def initialize(args = {})
|
|
16
|
-
|
|
17
14
|
if args[:username]
|
|
18
15
|
@@username = args[:username]
|
|
19
16
|
else
|
|
@@ -26,7 +23,7 @@ module Zanzibar
|
|
|
26
23
|
@@wsdl = get_wsdl_location
|
|
27
24
|
end
|
|
28
25
|
if args[:pwd]
|
|
29
|
-
|
|
26
|
+
@@password = args[:pwd]
|
|
30
27
|
else
|
|
31
28
|
@@password = prompt_for_password
|
|
32
29
|
end
|
|
@@ -43,7 +40,7 @@ module Zanzibar
|
|
|
43
40
|
# @param globals{}, optional
|
|
44
41
|
|
|
45
42
|
def init_client(globals = {})
|
|
46
|
-
globals = {} if globals
|
|
43
|
+
globals = {} if globals.nil?
|
|
47
44
|
@@client = Savon.client(globals) do
|
|
48
45
|
wsdl @@wsdl
|
|
49
46
|
end
|
|
@@ -54,39 +51,36 @@ module Zanzibar
|
|
|
54
51
|
|
|
55
52
|
def prompt_for_password
|
|
56
53
|
puts "Please enter password for #{@@username}:"
|
|
57
|
-
|
|
54
|
+
STDIN.noecho(&:gets).chomp
|
|
58
55
|
end
|
|
59
56
|
|
|
60
57
|
## Gets the wsdl document location if none is provided in the constructor
|
|
61
58
|
# @return [String] the location of the WDSL document
|
|
62
59
|
|
|
63
60
|
def prompt_for_wsdl_location
|
|
64
|
-
puts
|
|
65
|
-
|
|
61
|
+
puts 'Enter the URL of the Secret Server WSDL:'
|
|
62
|
+
STDIN.gets.chomp
|
|
66
63
|
end
|
|
67
64
|
|
|
68
65
|
## Gets the domain of the Secret Server installation if none is provided in the constructor
|
|
69
66
|
# @return [String] the domain of the secret server installation
|
|
70
67
|
|
|
71
68
|
def prompt_for_domain
|
|
72
|
-
puts
|
|
73
|
-
|
|
69
|
+
puts 'Enter the domain of your Secret Server:'
|
|
70
|
+
STDIN.gets.chomp
|
|
74
71
|
end
|
|
75
72
|
|
|
76
|
-
|
|
77
73
|
## Get an authentication token for interacting with Secret Server. These are only good for about 10 minutes so just get a new one each time.
|
|
78
74
|
# Will raise an error if there is an issue with the authentication.
|
|
79
75
|
# @return the authentication token for the current user.
|
|
80
76
|
|
|
81
77
|
def get_token
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
raise "There was an error generating the authentiaton token for user #{@@username}: #{err}"
|
|
89
|
-
end
|
|
78
|
+
response = @@client.call(:authenticate, message: { username: @@username, password: @@password, organization: '', domain: @@domain })
|
|
79
|
+
.hash[:envelope][:body][:authenticate_response][:authenticate_result]
|
|
80
|
+
fail "Error generating the authentication token for user #{@@username}: #{response[:errors][:string]}" if response[:errors]
|
|
81
|
+
response[:token]
|
|
82
|
+
rescue Savon::Error => err
|
|
83
|
+
raise "There was an error generating the authentiaton token for user #{@@username}: #{err}"
|
|
90
84
|
end
|
|
91
85
|
|
|
92
86
|
## Get a secret returned as a hash
|
|
@@ -95,13 +89,11 @@ module Zanzibar
|
|
|
95
89
|
# @return [Hash] the secret hash retrieved from the wsdl
|
|
96
90
|
|
|
97
91
|
def get_secret(scrt_id, token = nil)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
raise "There was an error getting the secret with id #{scrt_id}: #{err}"
|
|
104
|
-
end
|
|
92
|
+
secret = @@client.call(:get_secret, message: { token: token || get_token, secretId: scrt_id }).hash[:envelope][:body][:get_secret_response][:get_secret_result]
|
|
93
|
+
fail "There was an error getting secret #{scrt_id}: #{secret[:errors][:string]}" if secret[:errors]
|
|
94
|
+
return secret
|
|
95
|
+
rescue Savon::Error => err
|
|
96
|
+
raise "There was an error getting the secret with id #{scrt_id}: #{err}"
|
|
105
97
|
end
|
|
106
98
|
|
|
107
99
|
## Retrieve a simple password from a secret
|
|
@@ -110,13 +102,11 @@ module Zanzibar
|
|
|
110
102
|
# @return [String] the password for the given secret
|
|
111
103
|
|
|
112
104
|
def get_password(scrt_id)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
raise "There was an error getting the password for secret #{scrt_id}: #{err}"
|
|
119
|
-
end
|
|
105
|
+
secret = get_secret(scrt_id)
|
|
106
|
+
secret_items = secret[:secret][:items][:secret_item]
|
|
107
|
+
return get_secret_item_by_field_name(secret_items, 'Password')[:value]
|
|
108
|
+
rescue Savon::Error => err
|
|
109
|
+
raise "There was an error getting the password for secret #{scrt_id}: #{err}"
|
|
120
110
|
end
|
|
121
111
|
|
|
122
112
|
def write_secret_to_file(path, secret_response)
|
|
@@ -151,23 +141,21 @@ module Zanzibar
|
|
|
151
141
|
# Raise on error
|
|
152
142
|
# @param [Hash] args, :scrt_id, :type (one of "Private Key", "Public Key", "Attachment"), :scrt_item_id - optional, :path - optional
|
|
153
143
|
|
|
154
|
-
|
|
155
144
|
def download_secret_file(args = {})
|
|
156
145
|
token = get_token
|
|
157
146
|
FileUtils.mkdir_p(args[:path]) if args[:path]
|
|
158
147
|
path = args[:path] ? args[:path] : '.' ## The File.join below doesn't handle nils well, so let's take that possibility away.
|
|
159
148
|
begin
|
|
160
149
|
response = @@client.call(:download_file_attachment_by_item_id, message:
|
|
161
|
-
{ token: token, secretId: args[:scrt_id], secretItemId: args[:scrt_item_id] || get_scrt_item_id(args[:scrt_id], args[:type], token)})
|
|
162
|
-
|
|
163
|
-
|
|
150
|
+
{ token: token, secretId: args[:scrt_id], secretItemId: args[:scrt_item_id] || get_scrt_item_id(args[:scrt_id], args[:type], token) })
|
|
151
|
+
.hash[:envelope][:body][:download_file_attachment_by_item_id_response][:download_file_attachment_by_item_id_result]
|
|
152
|
+
fail "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{response[:errors][:string]}" if response[:errors]
|
|
164
153
|
write_secret_to_file(path, response)
|
|
165
154
|
rescue Savon::Error => err
|
|
166
155
|
raise "There was an error getting the #{args[:type]} for secret #{args[:scrt_id]}: #{err}"
|
|
167
156
|
end
|
|
168
157
|
end
|
|
169
158
|
|
|
170
|
-
|
|
171
159
|
## Methods to maintain backwards compatibility
|
|
172
160
|
def download_private_key(args = {})
|
|
173
161
|
args[:type] = 'Private Key'
|
|
@@ -183,6 +171,5 @@ module Zanzibar
|
|
|
183
171
|
args[:type] = 'Attachment'
|
|
184
172
|
download_secret_file(args)
|
|
185
173
|
end
|
|
186
|
-
|
|
187
174
|
end
|
|
188
175
|
end
|
data/lib/zanzibar/version.rb
CHANGED
data/spec/spec/spec_helper.rb
CHANGED
|
@@ -1,97 +1,95 @@
|
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
|
5
|
-
#
|
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
9
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
|
10
|
-
# a separate helper file that requires the additional dependencies and performs
|
|
11
|
-
# the additional setup, and require it from the spec files that actually need it.
|
|
12
|
-
#
|
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
14
|
-
# users commonly want.
|
|
15
|
-
#
|
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
17
|
-
require 'webmock/rspec'
|
|
18
|
-
require
|
|
19
|
-
CodeClimate::TestReporter.start
|
|
20
|
-
|
|
21
|
-
RSpec.configure do |config|
|
|
22
|
-
# rspec-expectations config goes here. You can use an alternate
|
|
23
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
24
|
-
# assertions if you prefer.
|
|
25
|
-
config.expect_with :rspec do |expectations|
|
|
26
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
27
|
-
# and `failure_message` of custom matchers include text for helper methods
|
|
28
|
-
# defined using `chain`, e.g.:
|
|
29
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
|
30
|
-
# # => "be bigger than 2 and smaller than 4"
|
|
31
|
-
# ...rather than:
|
|
32
|
-
# # => "be bigger than 2"
|
|
33
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
|
37
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
38
|
-
config.mock_with :rspec do |mocks|
|
|
39
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
|
40
|
-
# a real object. This is generally recommended, and will default to
|
|
41
|
-
# `true` in RSpec 4.
|
|
42
|
-
mocks.verify_partial_doubles = true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
config.after(:suite) do
|
|
46
|
-
WebMock.disable_net_connect!(:
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# The settings below are suggested to provide a good initial experience
|
|
50
|
-
# with RSpec, but feel free to customize to your heart's content.
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
config.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
# - http://
|
|
62
|
-
# - http://
|
|
63
|
-
#
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
|
|
96
|
-
=end
|
|
97
|
-
end
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
|
5
|
+
#
|
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
|
12
|
+
#
|
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
14
|
+
# users commonly want.
|
|
15
|
+
#
|
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
17
|
+
require 'webmock/rspec'
|
|
18
|
+
require 'codeclimate-test-reporter'
|
|
19
|
+
CodeClimate::TestReporter.start
|
|
20
|
+
|
|
21
|
+
RSpec.configure do |config|
|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
24
|
+
# assertions if you prefer.
|
|
25
|
+
config.expect_with :rspec do |expectations|
|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
28
|
+
# defined using `chain`, e.g.:
|
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
31
|
+
# ...rather than:
|
|
32
|
+
# # => "be bigger than 2"
|
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
38
|
+
config.mock_with :rspec do |mocks|
|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
40
|
+
# a real object. This is generally recommended, and will default to
|
|
41
|
+
# `true` in RSpec 4.
|
|
42
|
+
mocks.verify_partial_doubles = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
config.after(:suite) do
|
|
46
|
+
WebMock.disable_net_connect!(allow: 'codeclimate.com')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The settings below are suggested to provide a good initial experience
|
|
50
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
51
|
+
# # These two settings work together to allow you to limit a spec run
|
|
52
|
+
# # to individual examples or groups you care about by tagging them with
|
|
53
|
+
# # `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
54
|
+
# # get run.
|
|
55
|
+
# config.filter_run :focus
|
|
56
|
+
# config.run_all_when_everything_filtered = true
|
|
57
|
+
#
|
|
58
|
+
# # Limits the available syntax to the non-monkey patched syntax that is recommended.
|
|
59
|
+
# # For more details, see:
|
|
60
|
+
# # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
61
|
+
# # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
62
|
+
# # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
63
|
+
# config.disable_monkey_patching!
|
|
64
|
+
#
|
|
65
|
+
# # This setting enables warnings. It's recommended, but in some cases may
|
|
66
|
+
# # be too noisy due to issues in dependencies.
|
|
67
|
+
# config.warnings = true
|
|
68
|
+
#
|
|
69
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
|
70
|
+
# # file, and it's useful to allow more verbose output when running an
|
|
71
|
+
# # individual spec file.
|
|
72
|
+
# if config.files_to_run.one?
|
|
73
|
+
# # Use the documentation formatter for detailed output,
|
|
74
|
+
# # unless a formatter has already been configured
|
|
75
|
+
# # (e.g. via a command-line flag).
|
|
76
|
+
# config.default_formatter = 'doc'
|
|
77
|
+
# end
|
|
78
|
+
#
|
|
79
|
+
# # Print the 10 slowest examples and example groups at the
|
|
80
|
+
# # end of the spec run, to help surface which specs are running
|
|
81
|
+
# # particularly slow.
|
|
82
|
+
# config.profile_examples = 10
|
|
83
|
+
#
|
|
84
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
|
85
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
|
86
|
+
# # the seed, which is printed after each run.
|
|
87
|
+
# # --seed 1234
|
|
88
|
+
# config.order = :random
|
|
89
|
+
#
|
|
90
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
|
91
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
|
92
|
+
# # test failures related to randomization by passing the same `--seed` value
|
|
93
|
+
# # as the one that triggered the failure.
|
|
94
|
+
# Kernel.srand config.seed
|
|
95
|
+
end
|
data/spec/zanzibar_spec.rb
CHANGED
|
@@ -1,116 +1,113 @@
|
|
|
1
|
-
require 'zanzibar'
|
|
2
|
-
require 'savon'
|
|
3
|
-
require 'webmock'
|
|
4
|
-
require 'rspec'
|
|
5
|
-
require 'webmock/rspec'
|
|
6
|
-
|
|
7
|
-
include WebMock::API
|
|
8
|
-
|
|
9
|
-
describe
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
to_return(:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
File.delete('attachment.txt')
|
|
115
|
-
end
|
|
116
|
-
end
|
|
1
|
+
require 'zanzibar'
|
|
2
|
+
require 'savon'
|
|
3
|
+
require 'webmock'
|
|
4
|
+
require 'rspec'
|
|
5
|
+
require 'webmock/rspec'
|
|
6
|
+
|
|
7
|
+
include WebMock::API
|
|
8
|
+
|
|
9
|
+
describe 'Zanzibar Test' do
|
|
10
|
+
client = Zanzibar::Zanzibar.new(domain: 'zanzitest.net', pwd: 'password', wsdl: 'spec/scrt.wsdl')
|
|
11
|
+
auth_xml = File.read('spec/responses/authenticate_response.xml')
|
|
12
|
+
secret_xml = File.read('spec/responses/get_secret_response.xml')
|
|
13
|
+
secret_with_key_xml = File.read('spec/responses/get_secret_with_keys_response.xml')
|
|
14
|
+
secret_with_attachment_xml = File.read('spec/responses/get_secret_with_attachment_response.xml')
|
|
15
|
+
private_key_xml = File.read('spec/responses/download_private_key_response.xml')
|
|
16
|
+
public_key_xml = File.read('spec/responses/download_public_key_response.xml')
|
|
17
|
+
attachment_xml = File.read('spec/responses/attachment_response.xml')
|
|
18
|
+
|
|
19
|
+
it 'should return an auth token' do
|
|
20
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
21
|
+
.to_return(body: auth_xml, status: 200)
|
|
22
|
+
|
|
23
|
+
expect(client.get_token).to eq('imatoken')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should get a secret' do
|
|
27
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
28
|
+
.to_return(body: auth_xml, status: 200).then
|
|
29
|
+
.to_return(body: secret_xml, status: 200)
|
|
30
|
+
|
|
31
|
+
expect(client.get_secret(1234)[:secret][:name]).to eq('Zanzi Test Secret')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'should get a password' do
|
|
35
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
36
|
+
.to_return(body: auth_xml, status: 200).then
|
|
37
|
+
.to_return(body: secret_xml, status: 200)
|
|
38
|
+
|
|
39
|
+
expect(client.get_password(1234)).to eq('zanziUserPassword')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should download a private key' do
|
|
43
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
44
|
+
.to_return(body: auth_xml, status: 200).then
|
|
45
|
+
.to_return(body: secret_with_key_xml, status: 200).then
|
|
46
|
+
.to_return(body: private_key_xml, status: 200)
|
|
47
|
+
|
|
48
|
+
client.download_secret_file(scrt_id: 2345, type: 'Private Key')
|
|
49
|
+
expect(File.exist? 'zanzi_key')
|
|
50
|
+
expect(File.read('zanzi_key')).to eq("-----BEGIN RSA PRIVATE KEY -----\nzanzibarTestPassword\n-----END RSA PRIVATE KEY-----\n")
|
|
51
|
+
File.delete('zanzi_key')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should download a private key legacy' do
|
|
55
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
56
|
+
.to_return(body: auth_xml, status: 200).then
|
|
57
|
+
.to_return(body: secret_with_key_xml, status: 200).then
|
|
58
|
+
.to_return(body: private_key_xml, status: 200)
|
|
59
|
+
|
|
60
|
+
client.download_private_key(scrt_id: 2345)
|
|
61
|
+
expect(File.exist? 'zanzi_key')
|
|
62
|
+
expect(File.read('zanzi_key')).to eq("-----BEGIN RSA PRIVATE KEY -----\nzanzibarTestPassword\n-----END RSA PRIVATE KEY-----\n")
|
|
63
|
+
File.delete('zanzi_key')
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should download a public key' do
|
|
67
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
68
|
+
.to_return(body: auth_xml, status: 200).then
|
|
69
|
+
.to_return(body: secret_with_key_xml, status: 200).then
|
|
70
|
+
.to_return(body: public_key_xml, status: 200)
|
|
71
|
+
|
|
72
|
+
client.download_secret_file(scrt_id: 2345, type: 'Public Key')
|
|
73
|
+
expect(File.exist? 'zanzi_key.pub')
|
|
74
|
+
expect(File.read('zanzi_key.pub')).to eq("1234PublicKey5678==\n")
|
|
75
|
+
File.delete('zanzi_key.pub')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'should download a public key legacy' do
|
|
79
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
80
|
+
.to_return(body: auth_xml, status: 200).then
|
|
81
|
+
.to_return(body: secret_with_key_xml, status: 200).then
|
|
82
|
+
.to_return(body: public_key_xml, status: 200)
|
|
83
|
+
|
|
84
|
+
client.download_public_key(scrt_id: 2345)
|
|
85
|
+
expect(File.exist? 'zanzi_key.pub')
|
|
86
|
+
expect(File.read('zanzi_key.pub')).to eq("1234PublicKey5678==\n")
|
|
87
|
+
File.delete('zanzi_key.pub')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'should download an attachment' do
|
|
91
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
92
|
+
.to_return(body: auth_xml, status: 200).then
|
|
93
|
+
.to_return(body: secret_with_attachment_xml, status: 200).then
|
|
94
|
+
.to_return(body: attachment_xml, status: 200)
|
|
95
|
+
|
|
96
|
+
client.download_secret_file(scrt_id: 3456, type: 'Attachment')
|
|
97
|
+
expect(File.exist? 'attachment.txt')
|
|
98
|
+
expect(File.read('attachment.txt')).to eq("I am a secret attachment\n")
|
|
99
|
+
File.delete('attachment.txt')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should download an attachment legacy' do
|
|
103
|
+
stub_request(:any, 'https://www.zanzitest.net/webservices/sswebservice.asmx')
|
|
104
|
+
.to_return(body: auth_xml, status: 200).then
|
|
105
|
+
.to_return(body: secret_with_attachment_xml, status: 200).then
|
|
106
|
+
.to_return(body: attachment_xml, status: 200)
|
|
107
|
+
|
|
108
|
+
client.download_attachment(scrt_id: 3456)
|
|
109
|
+
expect(File.exist? 'attachment.txt')
|
|
110
|
+
expect(File.read('attachment.txt')).to eq("I am a secret attachment\n")
|
|
111
|
+
File.delete('attachment.txt')
|
|
112
|
+
end
|
|
113
|
+
end
|
data/zanzibar.gemspec
CHANGED
|
@@ -4,22 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'zanzibar/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
7
|
+
spec.name = 'zanzibar'
|
|
8
8
|
spec.version = Zanzibar::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
11
|
-
spec.summary =
|
|
12
|
-
spec.description =
|
|
13
|
-
spec.homepage =
|
|
14
|
-
spec.license =
|
|
9
|
+
spec.authors = ['Jason Davis-Cooke']
|
|
10
|
+
spec.email = ['jdaviscooke@cimpress.com']
|
|
11
|
+
spec.summary = 'Retrieve secrets from Secret Server'
|
|
12
|
+
spec.description = 'Programatically get secrets from Secret Server via the Web Service API'
|
|
13
|
+
spec.homepage = 'https://github.com/Cimpress-MCP/zanzibar'
|
|
14
|
+
spec.license = 'Apache 2.0'
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
-
spec.require_paths = [
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
spec.add_dependency
|
|
22
|
-
spec.add_development_dependency
|
|
23
|
-
spec.add_development_dependency
|
|
24
|
-
spec.
|
|
21
|
+
spec.add_dependency 'rubyntlm', '~> 0.4.0'
|
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
|
+
spec.add_development_dependency 'rubocop', '~>0.18.1'
|
|
25
|
+
spec.add_runtime_dependency 'savon', '~> 2.8.0'
|
|
25
26
|
end
|
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.
|
|
4
|
+
version: 0.1.11
|
|
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-01-
|
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubyntlm
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - ~>
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.18.1
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ~>
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.18.1
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: savon
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,6 +85,7 @@ email:
|
|
|
71
85
|
- jdaviscooke@cimpress.com
|
|
72
86
|
executables:
|
|
73
87
|
- zamioculcas
|
|
88
|
+
- zanzibar
|
|
74
89
|
extensions: []
|
|
75
90
|
extra_rdoc_files: []
|
|
76
91
|
files:
|
|
@@ -82,6 +97,7 @@ files:
|
|
|
82
97
|
- README.md
|
|
83
98
|
- Rakefile
|
|
84
99
|
- bin/zamioculcas
|
|
100
|
+
- bin/zanzibar
|
|
85
101
|
- lib/zanzibar.rb
|
|
86
102
|
- lib/zanzibar/version.rb
|
|
87
103
|
- spec/responses/attachment_response.xml
|