zanzibar 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,90 @@
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
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # The settings below are suggested to provide a good initial experience
43
+ # with RSpec, but feel free to customize to your heart's content.
44
+ =begin
45
+ # These two settings work together to allow you to limit a spec run
46
+ # to individual examples or groups you care about by tagging them with
47
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
+ # get run.
49
+ config.filter_run :focus
50
+ config.run_all_when_everything_filtered = true
51
+
52
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
53
+ # For more details, see:
54
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
55
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
56
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
57
+ config.disable_monkey_patching!
58
+
59
+ # This setting enables warnings. It's recommended, but in some cases may
60
+ # be too noisy due to issues in dependencies.
61
+ config.warnings = true
62
+
63
+ # Many RSpec users commonly either run the entire suite or an individual
64
+ # file, and it's useful to allow more verbose output when running an
65
+ # individual spec file.
66
+ if config.files_to_run.one?
67
+ # Use the documentation formatter for detailed output,
68
+ # unless a formatter has already been configured
69
+ # (e.g. via a command-line flag).
70
+ config.default_formatter = 'doc'
71
+ end
72
+
73
+ # Print the 10 slowest examples and example groups at the
74
+ # end of the spec run, to help surface which specs are running
75
+ # particularly slow.
76
+ config.profile_examples = 10
77
+
78
+ # Run specs in random order to surface order dependencies. If you find an
79
+ # order dependency and want to debug it, you can fix the order by providing
80
+ # the seed, which is printed after each run.
81
+ # --seed 1234
82
+ config.order = :random
83
+
84
+ # Seed global randomization in this process using the `--seed` CLI option.
85
+ # Setting this allows you to use `--seed` to deterministically reproduce
86
+ # test failures related to randomization by passing the same `--seed` value
87
+ # as the one that triggered the failure.
88
+ Kernel.srand config.seed
89
+ =end
90
+ end
@@ -0,0 +1,80 @@
1
+ require '../lib/zanzibar.rb'
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
+
11
+ client = Zanzibar::Zanzibar.new(:domain => "zanzitest.net", :pwd=>'password', :wsdl => "scrt.wsdl")
12
+ auth_xml = File.read('responses/authenticate_response.xml')
13
+ secret_xml = File.read('responses/get_secret_response.xml')
14
+ secret_with_key_xml = File.read('responses/get_secret_with_keys_response.xml')
15
+ secret_with_attachment_xml = File.read('responses/get_secret_with_attachment_response.xml')
16
+ private_key_xml = File.read('responses/download_private_key_response.xml')
17
+ public_key_xml = File.read('responses/download_public_key_response.xml')
18
+ attachment_xml = File.read('responses/attachment_response.xml')
19
+
20
+
21
+ it 'should return an auth token' do
22
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
23
+ to_return(:body => auth_xml, :status => 200)
24
+
25
+ expect(client.get_token).to eq("imatoken")
26
+ end
27
+
28
+ it 'should get a secret' do
29
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
30
+ to_return(:body => auth_xml, :status => 200).then.
31
+ to_return(:body => secret_xml, :status => 200)
32
+
33
+ expect(client.get_secret(1234)[:envelope][:body][:get_secret_response][:get_secret_result][:secret][:name]).to eq("Zanzi Test Secret")
34
+ end
35
+
36
+ it 'should get a password' do
37
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
38
+ to_return(:body => auth_xml, :status => 200).then.
39
+ to_return(:body => secret_xml, :status => 200)
40
+
41
+ expect(client.get_password(1234)).to eq("zanziUserPassword")
42
+ end
43
+
44
+ it 'should download a private key' do
45
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
46
+ to_return(:body => auth_xml, :status => 200).then.
47
+ to_return(:body => secret_with_key_xml, :status => 200).then.
48
+ to_return(:body => private_key_xml, :status => 200)
49
+
50
+ client.download_private_key(:scrt_id => 2345)
51
+ expect(File.exist? 'zanzi_key')
52
+ expect(File.read('zanzi_key')).to eq("-----BEGIN RSA PRIVATE KEY -----\nzanzibarTestPassword\n-----END RSA PRIVATE KEY-----\n")
53
+ File.delete('zanzi_key')
54
+ end
55
+
56
+
57
+ it 'should download a public key' do
58
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
59
+ to_return(:body => auth_xml, :status => 200).then.
60
+ to_return(:body => secret_with_key_xml, :status => 200).then.
61
+ to_return(:body => public_key_xml, :status => 200)
62
+
63
+ client.download_public_key(:scrt_id => 2345)
64
+ expect(File.exist? 'zanzi_key.pub')
65
+ expect(File.read('zanzi_key.pub')).to eq("1234PublicKey5678==\n")
66
+ File.delete('zanzi_key.pub')
67
+ end
68
+
69
+ it 'should download an attachment' do
70
+ stub_request(:any, "https://www.zanzitest.net/webservices/sswebservice.asmx").
71
+ to_return(:body => auth_xml, :status => 200).then.
72
+ to_return(:body => secret_with_attachment_xml, :status => 200).then.
73
+ to_return(:body => attachment_xml, :status => 200)
74
+
75
+ client.download_attachment(:scrt_id => 3456)
76
+ expect(File.exist? 'attachment.txt')
77
+ expect(File.read('attachment.txt')).to eq("I am a secret attachment\n")
78
+ File.delete('attachment.txt')
79
+ end
80
+ end
data/zanzibar.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zanzibar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "zanzibar"
8
+ spec.version = Zanzibar::VERSION
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
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency "savon", "~> 2.8.0"
24
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zanzibar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Davis-Cooke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-01-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: savon
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.8.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ description: Programatically get secrets from Secret Server via the Web Service API
63
+ email:
64
+ - jdaviscooke@cimpress.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - lib/zanzibar.rb
75
+ - lib/zanzibar/version.rb
76
+ - test/.rspec
77
+ - test/responses/attachment_response.xml
78
+ - test/responses/authenticate_response.xml
79
+ - test/responses/download_private_key_response.xml
80
+ - test/responses/download_public_key_response.xml
81
+ - test/responses/get_secret_response.xml
82
+ - test/responses/get_secret_with_attachment_response.xml
83
+ - test/responses/get_secret_with_keys_response.xml
84
+ - test/scrt.wsdl
85
+ - test/spec/spec_helper.rb
86
+ - test/zanzibar_spec.rb
87
+ - zanzibar.gemspec
88
+ homepage: https://github.com/Cimpress-MCP/zanzibar
89
+ licenses:
90
+ - Apache 2.0
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.29
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Retrieve secrets from Secret Server
113
+ test_files:
114
+ - test/.rspec
115
+ - test/responses/attachment_response.xml
116
+ - test/responses/authenticate_response.xml
117
+ - test/responses/download_private_key_response.xml
118
+ - test/responses/download_public_key_response.xml
119
+ - test/responses/get_secret_response.xml
120
+ - test/responses/get_secret_with_attachment_response.xml
121
+ - test/responses/get_secret_with_keys_response.xml
122
+ - test/scrt.wsdl
123
+ - test/spec/spec_helper.rb
124
+ - test/zanzibar_spec.rb