conjur-cli 4.17.0 → 4.18.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 432110704aeb067fe4daed4e19defb8bcfce73ba
4
- data.tar.gz: e515bff89602f42ec641655ff89724f8ce0402c8
3
+ metadata.gz: 72781b9c56ed02155378f270c0c36ca4041870e4
4
+ data.tar.gz: babddd4db4c6af48e79f68b5efefdaef2af9ae33
5
5
  SHA512:
6
- metadata.gz: f79560aa69622e389202e12ce79d328e5d61d055dfea15660503c5684de9b9a031843d8a219f1b68e563db8fa53a7456e745cdcc5d29cf46dc23c747c767f7b3
7
- data.tar.gz: 6d0045244faab16cd1bd009ac9b1252a6d1ef950aec5bfa266531189d7109513250da60014a4037e89fbf63477ffdc02994e68f42c80888f759493e9b383dd70
6
+ metadata.gz: 02429a61b261a87cbb604fea379de4b096431dd6b385df0c3924e637a30ee4e08560867b6e28cc8de1deff349f9c1f156f4a2382ccd4de0bcf45634e1619e6e2
7
+ data.tar.gz: 26ee97af5b20b8568cac44be5f293d9fb157b80d7ffe3d87d71dd3589df43152f557d89ca71777c0cda57a99256f76e1ae7bc08af8856f17c0ac67d50e5e272c
@@ -1,6 +1,13 @@
1
+ # 4.18.0
2
+
3
+ * New `conjurize` command
4
+ * Deprecate the `host enroll` command
5
+ * `variable create` command now takes an optional value for the variable after the variable id
6
+ * Configure "permissive" netrc to allow the `conjur` Unix group to read the `.netrc` or `conjur.identity` file.
7
+
1
8
  # 4.17.0
2
9
 
3
- * Support --policy parameter in 'conjur env'
10
+ * Support --policy parameter in `conjur env`
4
11
  * Bugfix: failures on 'variable retire'
5
12
  * Raise a better error in case of missing config
6
13
 
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2013 Conjur Inc
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+
23
+ require 'active_support'
24
+ require 'conjur/conjurize'
25
+
26
+ Conjur::Conjurize.go!
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/conjur/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Rafa\305\202 Rzepecki", "Kevin Gilpin"]
6
- gem.email = ["divided.mind@gmail.com", "kgilpin@conjur.net",]
5
+ gem.authors = ["Rafal Rzepecki", "Kevin Gilpin"]
6
+ gem.email = ["rafal@conjur.net", "kgilpin@conjur.net",]
7
7
  gem.summary = %q{Conjur command line interface}
8
8
  gem.homepage = "https://github.com/conjurinc/cli-ruby"
9
9
  gem.license = 'MIT'
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
 
19
19
  gem.add_dependency 'activesupport'
20
- gem.add_dependency 'conjur-api', '>=4.10.0'
20
+ gem.add_dependency 'conjur-api', '>=4.11.0'
21
21
  gem.add_dependency 'gli', '>=2.8.0'
22
22
  gem.add_dependency 'highline'
23
23
  gem.add_dependency 'netrc'
@@ -0,0 +1,131 @@
1
+ Feature: conjurize program generates install scripts
2
+
3
+ Scenario: App just runs
4
+ When I get help for "conjurize"
5
+ Then the exit status should be 0
6
+ And the banner should be present
7
+ And the banner should document that this app takes options
8
+ And the following options should be documented:
9
+ |--version|
10
+ And the banner should document that this app takes no arguments
11
+
12
+ Scenario: Minimal conjurize script
13
+ When I conjurize ""
14
+ Then the stdout should contain exactly:
15
+ """
16
+ #!/bin/sh
17
+ set -e
18
+
19
+ # Implementation note: 'tee' is used as a sudo-friendly 'cat' to populate a file with the contents provided below.
20
+
21
+ tee /etc/conjur.conf > /dev/null << CONJUR_CONF
22
+ account: test
23
+ appliance_url: https://conjur/api
24
+ cert_file: /etc/conjur-test.pem
25
+ netrc_path: /etc/conjur.identity
26
+ plugins: []
27
+ CONJUR_CONF
28
+
29
+ tee /etc/conjur-test.pem > /dev/null << CONJUR_CERT
30
+ -----BEGIN CERTIFICATE-----
31
+ MIIDZTCCAk2gAwIBAgIJAMzfPBZBq82XMA0GCSqGSIb3DQEBBQUAMDMxMTAvBgNV
32
+ BAMTKGVjMi01NC04My05OS0xMzUuY29tcHV0ZS0xLmFtYXpvbmF3cy5jb20wHhcN
33
+ MTQxMTIxMTUxNDE0WhcNMjQxMTE4MTUxNDE0WjAzMTEwLwYDVQQDEyhlYzItNTQt
34
+ ODMtOTktMTM1LmNvbXB1dGUtMS5hbWF6b25hd3MuY29tMIIBIjANBgkqhkiG9w0B
35
+ AQEFAAOCAQ8AMIIBCgKCAQEAlkhRt1pvOkw1JTtvmfa3lHpT00g0lbBnShN5cKI3
36
+ cT1Na3aGdosPDfn0z+A6GNT2sUcdsc5RLkrZKG2+57B5hyUtdwRoJoTTBqypxJTc
37
+ vkeMpCrcaeY8Ye0zsoBNaeauXLPobtEV4I6IadJGuT2AKILTJLDYdyV4dg2/zN2z
38
+ XmW+9FsDs+aJKtWnpBIkvXcCqbaIgRZSxFNeZUF+xDrZdCRm+qkBXZaMFQzLU0BT
39
+ B239Lmpwp54zsBoTBY9JBS4Atmrwt3YE3JqcIH77GpkgXSx203bYVp0jF3vPxHLU
40
+ bSqhV9Zw7m6V8uF+jvOdrDiZ33OJN9yx6nS+c7NfOyRgGQIDAQABo3wwejB4BgNV
41
+ HREEcTBvgglsb2NhbGhvc3SCBmNvbmp1coIVY29uanVyLWRldi5jb25qdXIubmV0
42
+ ghljb25qdXItZGV2Lml0ZC5jb25qdXIubmV0gihlYzItNTQtODMtOTktMTM1LmNv
43
+ bXB1dGUtMS5hbWF6b25hd3MuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQB+alzAA3ek
44
+ o8QrnoDuWOxTqD0XIwzqux6BM/nM4dZX6drr+D0y8QtMKLZNODazvFCJWNHAWWmD
45
+ FkRudwl3G1Qs56AB+LnQ2jhL5Qf78Rl2vYvdmo8iowEpOBajvzEMLsEaRNmwmSGc
46
+ yvml0YdVSiMdTdIk58qG84pkmteSX9VYE1IF7xfWb3ji8292fm5q6cgqFLNYx2MI
47
+ 5UyfyroGMJ2ikzTGS64TpCmi/n1sjl2iM+/QmkHVc3KUIdwAY2NttyZ2pZo2J4i6
48
+ MVs0y+HobWbOKKhyfxpMT59dJxGu21QPbWfQLkHCCOlo2P4z9oku23sbvQQ7CbvS
49
+ VoykXurdaZo9
50
+ -----END CERTIFICATE-----
51
+ CONJUR_CERT
52
+
53
+ tee /etc/conjur.identity > /dev/null << CONJUR_IDENTITY
54
+ machine https://conjur/api/authn
55
+ login host/ec2/i-eaa5f700
56
+ password 3a4rb19rpjejr89h6r29kd2fb3808cpy
57
+ CONJUR_IDENTITY
58
+ chmod 0600 /etc/conjur.identity
59
+
60
+ """
61
+
62
+ Scenario: conjurize with SSH installation
63
+ When I conjurize "--ssh"
64
+ Then the stdout should contain exactly:
65
+ """
66
+ #!/bin/sh
67
+ set -e
68
+
69
+ # Implementation note: 'tee' is used as a sudo-friendly 'cat' to populate a file with the contents provided below.
70
+
71
+ tee /etc/conjur.conf > /dev/null << CONJUR_CONF
72
+ account: test
73
+ appliance_url: https://conjur/api
74
+ cert_file: /etc/conjur-test.pem
75
+ netrc_path: /etc/conjur.identity
76
+ plugins: []
77
+ CONJUR_CONF
78
+
79
+ tee /etc/conjur-test.pem > /dev/null << CONJUR_CERT
80
+ -----BEGIN CERTIFICATE-----
81
+ MIIDZTCCAk2gAwIBAgIJAMzfPBZBq82XMA0GCSqGSIb3DQEBBQUAMDMxMTAvBgNV
82
+ BAMTKGVjMi01NC04My05OS0xMzUuY29tcHV0ZS0xLmFtYXpvbmF3cy5jb20wHhcN
83
+ MTQxMTIxMTUxNDE0WhcNMjQxMTE4MTUxNDE0WjAzMTEwLwYDVQQDEyhlYzItNTQt
84
+ ODMtOTktMTM1LmNvbXB1dGUtMS5hbWF6b25hd3MuY29tMIIBIjANBgkqhkiG9w0B
85
+ AQEFAAOCAQ8AMIIBCgKCAQEAlkhRt1pvOkw1JTtvmfa3lHpT00g0lbBnShN5cKI3
86
+ cT1Na3aGdosPDfn0z+A6GNT2sUcdsc5RLkrZKG2+57B5hyUtdwRoJoTTBqypxJTc
87
+ vkeMpCrcaeY8Ye0zsoBNaeauXLPobtEV4I6IadJGuT2AKILTJLDYdyV4dg2/zN2z
88
+ XmW+9FsDs+aJKtWnpBIkvXcCqbaIgRZSxFNeZUF+xDrZdCRm+qkBXZaMFQzLU0BT
89
+ B239Lmpwp54zsBoTBY9JBS4Atmrwt3YE3JqcIH77GpkgXSx203bYVp0jF3vPxHLU
90
+ bSqhV9Zw7m6V8uF+jvOdrDiZ33OJN9yx6nS+c7NfOyRgGQIDAQABo3wwejB4BgNV
91
+ HREEcTBvgglsb2NhbGhvc3SCBmNvbmp1coIVY29uanVyLWRldi5jb25qdXIubmV0
92
+ ghljb25qdXItZGV2Lml0ZC5jb25qdXIubmV0gihlYzItNTQtODMtOTktMTM1LmNv
93
+ bXB1dGUtMS5hbWF6b25hd3MuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQB+alzAA3ek
94
+ o8QrnoDuWOxTqD0XIwzqux6BM/nM4dZX6drr+D0y8QtMKLZNODazvFCJWNHAWWmD
95
+ FkRudwl3G1Qs56AB+LnQ2jhL5Qf78Rl2vYvdmo8iowEpOBajvzEMLsEaRNmwmSGc
96
+ yvml0YdVSiMdTdIk58qG84pkmteSX9VYE1IF7xfWb3ji8292fm5q6cgqFLNYx2MI
97
+ 5UyfyroGMJ2ikzTGS64TpCmi/n1sjl2iM+/QmkHVc3KUIdwAY2NttyZ2pZo2J4i6
98
+ MVs0y+HobWbOKKhyfxpMT59dJxGu21QPbWfQLkHCCOlo2P4z9oku23sbvQQ7CbvS
99
+ VoykXurdaZo9
100
+ -----END CERTIFICATE-----
101
+ CONJUR_CERT
102
+
103
+ tee /etc/conjur.identity > /dev/null << CONJUR_IDENTITY
104
+ machine https://conjur/api/authn
105
+ login host/ec2/i-eaa5f700
106
+ password 3a4rb19rpjejr89h6r29kd2fb3808cpy
107
+ CONJUR_IDENTITY
108
+ chmod 0600 /etc/conjur.identity
109
+
110
+ curl -L https://www.opscode.com/chef/install.sh | bash
111
+ chef-solo -r https://github.com/conjur-cookbooks/conjur-ssh/releases/download/v1.2.0/conjur-ssh-v1.2.0.tar.gz -o conjur-ssh
112
+
113
+ """
114
+
115
+ Scenario: conjurize with arbitrary cookbook
116
+ When I conjurize "--conjur-cookbook-url https://example.com --conjur-run-list fry"
117
+ Then the stdout should contain "chef-solo -r https://example.com -o fry"
118
+
119
+ Scenario: conjurize with path to chef-solo
120
+ When I conjurize "--chef-executable /path/to/chef-solo --conjur-cookbook-url https://example.com --conjur-run-list fry"
121
+ Then the stdout should contain "/path/to/chef-solo -r https://example.com -o fry"
122
+ And the stdout should not contain "curl -L https://www.opscode.com/chef/install.sh"
123
+
124
+ Scenario: conjurize with sudo-ized commands
125
+ When I conjurize "--sudo --ssh"
126
+ Then the stdout should contain "sudo -n tee /etc/conjur.conf > /dev/null << CONJUR_CONF"
127
+ And the stdout should contain "sudo -n tee /etc/conjur-test.pem > /dev/null << CONJUR_CERT"
128
+ And the stdout should contain "sudo -n tee /etc/conjur.identity > /dev/null << CONJUR_IDENTITY"
129
+ And the stdout should contain "sudo -n chmod 0600 /etc/conjur.identity"
130
+ And the stdout should contain "curl -L https://www.opscode.com/chef/install.sh | sudo -n bash"
131
+
@@ -0,0 +1,5 @@
1
+ When(/^I conjurize "(.*?)"$/) do |args|
2
+ cmd = "conjurize -f ../../features/support/host.json -c ../../features/support/conjur.conf"
3
+ step %Q(I run `#{[ cmd, args ].compact.join(' ')}`)
4
+ end
5
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ account: test
3
+ plugins:
4
+ - ui
5
+ appliance_url: https://conjur/api
6
+ cert_file: ../../features/support/conjur-test.pem
@@ -1,5 +1,6 @@
1
1
  require 'simplecov'
2
2
  require 'aruba/cucumber'
3
+ require 'methadone/cucumber'
3
4
  require 'cucumber/rspec/doubles'
4
5
 
5
6
  SimpleCov.start
@@ -23,6 +23,10 @@ require 'active_support/dependencies/autoload'
23
23
  require 'conjur/api'
24
24
  require 'netrc'
25
25
 
26
+ Netrc.configure do |config|
27
+ config[:allow_permissive_netrc_file] = true
28
+ end
29
+
26
30
  module Conjur::Authn
27
31
  autoload :API, 'conjur/authn-api'
28
32
  class << self
@@ -32,6 +32,7 @@ module Conjur
32
32
  autoload :Command, 'conjur/command'
33
33
  autoload :DSL, 'conjur/dsl/runner'
34
34
  autoload :DSLCommand, 'conjur/command/dsl_command'
35
+ autoload :VERSION, 'conjur/version'
35
36
 
36
37
  module Audit
37
38
  autoload :Follower, 'conjur/audit/follower'
@@ -67,7 +68,7 @@ module Conjur
67
68
  filename = "conjur-asset-#{plugin}"
68
69
  require filename
69
70
  rescue LoadError
70
- warn "Could not load plugin '#{plugin}' specified in your config file.\nMake sure you have the #{filename}-api gem installed."
71
+ warn "Could not load plugin '#{plugin}' specified in your config file.\nMake sure you have the #{filename} gem installed."
71
72
  end
72
73
  end
73
74
  end
@@ -85,6 +86,8 @@ module Conjur
85
86
 
86
87
  init!
87
88
 
89
+ version Conjur::VERSION
90
+
88
91
  pre do |global,command,options,args|
89
92
  require 'conjur/api'
90
93
 
@@ -86,9 +86,10 @@ class Conjur::Command::Hosts < Conjur::Command
86
86
  end
87
87
  end
88
88
 
89
- hosts.desc "Enroll a new host into conjur"
89
+ hosts.desc "[Deprecated] Enroll a new host into conjur"
90
90
  hosts.arg_name "host"
91
91
  hosts.command :enroll do |c|
92
+ hide_docs(c)
92
93
  c.action do |global_options, options, args|
93
94
  id = require_arg(args, 'host')
94
95
  enrollment_url = api.host(id).enrollment_url
@@ -108,4 +109,4 @@ class Conjur::Command::Hosts < Conjur::Command
108
109
  end
109
110
  end
110
111
  end
111
- end
112
+ end
@@ -26,7 +26,8 @@ require 'socket'
26
26
  class Conjur::Command::Policy < Conjur::DSLCommand
27
27
  class << self
28
28
  def default_collection_user
29
- Etc.getlogin
29
+ # More accurate than Etc.getlogin
30
+ Etc.getpwuid(Process.uid).name
30
31
  end
31
32
 
32
33
  def default_collection_hostname
@@ -23,7 +23,7 @@ class Conjur::Command::Variables < Conjur::Command
23
23
  desc "Manage variables"
24
24
  command :variable do |var|
25
25
  var.desc "Create and store a variable"
26
- var.arg_name "id"
26
+ var.arg_name "id [value]"
27
27
  var.command :create do |c|
28
28
  c.arg_name "mime_type"
29
29
  c.flag [:m, :"mime-type"], default_value: "text/plain"
@@ -32,18 +32,23 @@ class Conjur::Command::Variables < Conjur::Command
32
32
  c.flag [:k, :"kind"], default_value: "secret"
33
33
 
34
34
  c.arg_name "value"
35
- c.desc "Initial value"
35
+ c.desc "Initial value, which may also be specified as the second command argument after the variable id"
36
36
  c.flag [:v, :"value"]
37
37
 
38
38
  acting_as_option(c)
39
39
 
40
40
  c.action do |global_options,options,args|
41
41
  id = args.shift
42
- options[:id] = id if id
43
-
44
42
  unless id
45
43
  ActiveSupport::Deprecation.warn "id argument will be required in future releases"
46
44
  end
45
+ value = args.shift unless args.empty?
46
+
47
+ raise "Received extra arguments '#{args.join(' ')}'" unless args.empty?
48
+ raise "Received conflicting value arguments" if value && options[:value]
49
+
50
+ options[:id] = id if id
51
+ options[:value] ||= value if value
47
52
 
48
53
  mime_type = options.delete(:m)
49
54
  kind = options.delete(:k)
@@ -42,7 +42,7 @@ module Conjur
42
42
 
43
43
  class ConjurVariable < CustomTag
44
44
  def evaluate value
45
- raise "variable #{id} exists but doesn't have a value" if value.nil?
45
+ raise "variable #{conjur_id} exists but doesn't have a value" if value.nil?
46
46
  value.chomp
47
47
  end
48
48
  end
@@ -0,0 +1,106 @@
1
+ require 'methadone'
2
+ require 'json'
3
+ require 'conjur/version.rb'
4
+
5
+ module Conjur
6
+ class Conjurize
7
+ include Methadone::Main
8
+ include Methadone::CLILogging
9
+
10
+ description <<-DESC
11
+ Generate a script to install Conjur onto a machine. "conjurize" is designed to be used
12
+ in a piped execution, along with "conjur host create" and "ssh". For example:
13
+
14
+ conjur host create myhost.example.com | tee host.json | conjurize --ssh | ssh myhost.example.com
15
+ DESC
16
+
17
+ version Conjur::VERSION
18
+
19
+ main do
20
+ input = if input_file = options[:f]
21
+ File.read(input_file)
22
+ else
23
+ STDIN.read
24
+ end
25
+ host = JSON.parse input
26
+
27
+ login = host['id'] or raise "No 'id' field in host JSON"
28
+ api_key = host['api_key'] or raise "No 'api_key' field in host JSON"
29
+
30
+ require 'conjur/cli'
31
+ if conjur_config = options[:c]
32
+ Conjur::Config.load [ conjur_config ]
33
+ else
34
+ Conjur::Config.load
35
+ end
36
+ Conjur::Config.apply
37
+
38
+ conjur_cookbook_url = conjur_run_list = nil
39
+
40
+ conjur_run_list = options[:"conjur-run-list"]
41
+ conjur_cookbook_url = options[:"conjur-cookbook-url"]
42
+ chef_executable = options[:"chef-executable"]
43
+
44
+ if options[:ssh]
45
+ conjur_run_list ||= "conjur-ssh"
46
+ conjur_cookbook_url ||= "https://github.com/conjur-cookbooks/conjur-ssh/releases/download/v1.2.0/conjur-ssh-v1.2.0.tar.gz"
47
+ end
48
+
49
+ sudo = lambda{|str|
50
+ [ options[:sudo] ? "sudo -n" : nil, str ].compact.join(" ")
51
+ }
52
+
53
+ header = <<-HEADER
54
+ #!/bin/sh
55
+ set -e
56
+
57
+ # Implementation note: 'tee' is used as a sudo-friendly 'cat' to populate a file with the contents provided below.
58
+ HEADER
59
+
60
+ configure_conjur = <<-CONFIGURE
61
+ #{sudo.call 'tee'} /etc/conjur.conf > /dev/null << CONJUR_CONF
62
+ account: #{Conjur.configuration.account}
63
+ appliance_url: #{Conjur.configuration.appliance_url}
64
+ cert_file: /etc/conjur-#{Conjur.configuration.account}.pem
65
+ netrc_path: /etc/conjur.identity
66
+ plugins: []
67
+ CONJUR_CONF
68
+
69
+ #{sudo.call 'tee'} /etc/conjur-#{Conjur.configuration.account}.pem > /dev/null << CONJUR_CERT
70
+ #{File.read(Conjur.configuration.cert_file).strip}
71
+ CONJUR_CERT
72
+
73
+ #{sudo.call 'tee'} /etc/conjur.identity > /dev/null << CONJUR_IDENTITY
74
+ machine #{Conjur.configuration.appliance_url}/authn
75
+ login host/#{login}
76
+ password #{api_key}
77
+ CONJUR_IDENTITY
78
+ #{sudo.call 'chmod'} 0600 /etc/conjur.identity
79
+ CONFIGURE
80
+
81
+ install_chef = if conjur_cookbook_url && !chef_executable
82
+ %Q(curl -L https://www.opscode.com/chef/install.sh | #{sudo.call 'bash'})
83
+ else
84
+ nil
85
+ end
86
+
87
+ chef_executable ||= "chef-solo"
88
+
89
+ run_chef = if conjur_cookbook_url
90
+ %Q(#{sudo.call "#{chef_executable} -r #{conjur_cookbook_url} -o #{conjur_run_list}"})
91
+ else
92
+ nil
93
+ end
94
+
95
+ puts [ header, configure_conjur, install_chef, run_chef ].compact.join("\n")
96
+ end
97
+
98
+ on("-c CONJUR_CONFIG_FILE", "Overrides defaults (CONJURRC env var, ~/.conjurrc, /etc/conjur.conf).")
99
+ on("-f HOST_JSON_FILE", "Host login and API key can be read from the output emitted from 'conjur host create'. This data can be obtained from stdin, or from a file.")
100
+ on("--chef-executable PATH", "If specified, the designated chef-solo executable is used, otherwise Chef is installed on the target machine.")
101
+ on("--ssh", "Indicates that Conjur SSH should be installed.")
102
+ on("--sudo", "Indicates that all commands should be run via 'sudo'.")
103
+ on("--conjur-cookbook-url NAME", "Overrides the default Chef cookbook URL for Conjur SSH.")
104
+ on("--conjur-run-list RUNLIST", "Overrides the default Chef run list for Conjur SSH.")
105
+ end
106
+ end
@@ -20,7 +20,7 @@ module Conjur
20
20
  @context['env'] = Conjur.env unless Conjur.env == 'production'
21
21
  @context['stack'] = Conjur.stack unless Conjur.stack == 'v4'
22
22
  @context['appliance_url'] = Conjur.configuration.appliance_url unless Conjur.configuration.appliance_url.nil?
23
- @context['ssl_certificate'] = File.read(Conjur::Config[:cert_file]) unless Conjur::Config[:cert_file].nil?
23
+ @context['ssl_certificate'] = File.read(Conjur.configuration.cert_file) unless Conjur.configuration.cert_file.nil?
24
24
 
25
25
  @script = script
26
26
  @filename = filename
@@ -19,6 +19,6 @@
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
21
  module Conjur
22
- VERSION = "4.17.0"
22
+ VERSION = "4.18.0"
23
23
  ::Version=VERSION
24
24
  end
@@ -22,6 +22,8 @@ describe Conjur::Command::Policy do
22
22
  double("resource", exists?: true).as_null_object
23
23
  end
24
24
  before {
25
+ allow(File).to receive(:read).and_call_original
26
+ allow(File).to receive(:exists?).and_call_original
25
27
  allow(File).to receive(:exists?).with("policy.rb").and_return true
26
28
  allow(File).to receive(:read).with("policy.rb").and_return "{}"
27
29
  allow_any_instance_of(Conjur::DSL::Runner).to receive(:api).and_return api
@@ -2,21 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe Conjur::Command::Variables, logged_in: true do
4
4
  let(:collection_url) { "https://core.example.com/variables" }
5
-
6
5
  let(:base_payload) { { mime_type: 'text/json', kind: 'password' } }
6
+ let(:id) { 'the-id' }
7
+ let(:variable) { post_response(id) }
7
8
 
8
9
  describe_command "variable:create -m text/json -k password" do
10
+ let(:id) { 'assigned-id' }
9
11
  it "lets the server assign the id" do
10
12
  expect(RestClient::Request).to receive(:execute).with(
11
13
  method: :post,
12
14
  url: collection_url,
13
15
  headers: {},
14
16
  payload: base_payload
15
- ).and_return(post_response('assigned-id'))
17
+ ).and_return(variable)
16
18
 
17
19
  expect { invoke }.to write({ id: 'assigned-id' }).to(:stdout)
18
20
  end
19
21
  end
22
+
20
23
  describe_command "variable:create -m text/json -k password the-id" do
21
24
  it "propagates the user-assigned id" do
22
25
  expect(RestClient::Request).to receive(:execute).with(
@@ -24,13 +27,37 @@ describe Conjur::Command::Variables, logged_in: true do
24
27
  url: collection_url,
25
28
  headers: {},
26
29
  payload: base_payload.merge({ id: 'the-id' })
27
- ).and_return(post_response('the-id'))
30
+ ).and_return(variable)
28
31
 
29
32
  expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
30
33
  end
31
34
  end
32
35
 
36
+ describe_command "variable:create -m text/json -k password the-id the-value" do
37
+ it "propagates the user-assigned id and value" do
38
+ expect(RestClient::Request).to receive(:execute).with(
39
+ method: :post,
40
+ url: collection_url,
41
+ headers: {},
42
+ payload: base_payload.merge({ id: 'the-id', value: 'the-value' })
43
+ ).and_return(variable)
33
44
 
45
+ expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
46
+ end
47
+ end
48
+
49
+ describe_command "variable:create -v the-value-1 the-id the-value-2" do
50
+ it "complains about conflicting values" do
51
+ expect { invoke }.to raise_error("Received conflicting value arguments")
52
+ end
53
+ end
54
+
55
+ describe_command "variable:create the-id -v the-value" do
56
+ it "complains about extra arguments" do
57
+ expect { invoke }.to raise_error("Received extra arguments 'the-value'")
58
+ end
59
+ end
60
+
34
61
  describe_command "variable:create" do
35
62
  it "provides default values for optional parameters mime_type and kind" do
36
63
  expect(RestClient::Request).to receive(:execute).with(
@@ -38,10 +65,8 @@ describe Conjur::Command::Variables, logged_in: true do
38
65
  url: collection_url,
39
66
  headers: {},
40
67
  payload: { mime_type: 'text/plain', kind: 'secret'}
41
- ).and_return(post_response('the-id'))
68
+ ).and_return(variable)
42
69
  expect { invoke }.to write # invoke_silently
43
70
  end
44
71
  end
45
-
46
-
47
72
  end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'conjur/authn'
2
3
  require 'conjur/config'
3
4
  require 'conjur/command/rspec/output_matchers'
@@ -107,13 +108,23 @@ describe Conjur::Config do
107
108
  end
108
109
  end
109
110
  describe "#apply" do
110
- before { allow(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file) }
111
-
112
- let(:cert_file) { "/path/to/cert.pem" }
113
- it "trusts the cert_file" do
114
- Conjur::Config.class_variable_set("@@attributes", { 'cert_file' => cert_file })
115
- expect(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file).with cert_file
116
- Conjur::Config.apply
111
+ before {
112
+ allow(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file)
113
+ }
114
+ context "cert_file" do
115
+ let(:cert_file) { "/path/to/cert.pem" }
116
+ before {
117
+ Conjur::Config.class_variable_set("@@attributes", { 'cert_file' => cert_file })
118
+ }
119
+
120
+ it "trusts the cert_file" do
121
+ expect(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file).with cert_file
122
+ Conjur::Config.apply
123
+ end
124
+ it "propagates the cert_file to Configuration.cert_file" do
125
+ Conjur::Config.apply
126
+ expect(Conjur.configuration.cert_file).to eq(cert_file)
127
+ end
117
128
  end
118
129
 
119
130
  it "shadows rc with envars" do
@@ -121,7 +132,7 @@ describe Conjur::Config do
121
132
  ENV['CONJUR_APPLIANCE_URL'] = url
122
133
  load!
123
134
  Conjur::Config.apply
124
- expect(Conjur.configuration.appliance_url).to eq url
135
+ expect(Conjur.configuration.appliance_url).to eq(url)
125
136
  end
126
137
  end
127
138
  end
@@ -2,6 +2,12 @@ require 'spec_helper'
2
2
  require 'conjur/conjurenv'
3
3
 
4
4
  describe Conjur::Env do
5
+ describe Conjur::Env::ConjurVariable do
6
+ it "reports a missing value" do
7
+ var = Conjur::Env::ConjurVariable.new('the-id')
8
+ expect { var.evaluate nil }.to raise_error "variable the-id exists but doesn't have a value"
9
+ end
10
+ end
5
11
 
6
12
  describe "#initialize" do
7
13
 
@@ -43,4 +43,29 @@ shared_context "fresh config" do
43
43
  Conjur::Config.clear
44
44
  Conjur.configuration = @configuration
45
45
  }
46
- end
46
+ end
47
+
48
+ RSpec::Core::DSL.change_global_dsl do
49
+ def describe_conjurize *argv, &block
50
+ describe *argv do
51
+ let(:command) { Conjur::Conjurize }
52
+ let(:invoke) do
53
+ command.go!
54
+ end
55
+ before {
56
+ require 'methadone'
57
+
58
+ option_parser = OptionParser.new
59
+ expect(option_parser).to receive(:parse!).with(no_args) do |*args|
60
+ option_parser.parse! argv
61
+ end
62
+ allow(option_parser).to receive(:parse!).and_call_original
63
+ option_parser_proxy = nil
64
+ expect(Conjur::Conjurize).to receive(:opts) do |*args|
65
+ option_parser_proxy ||= Methadone::OptionParserProxy.new(option_parser, command.options)
66
+ end
67
+ }
68
+ instance_eval &block
69
+ end
70
+ end
71
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.0
4
+ version: 4.18.0
5
5
  platform: ruby
6
6
  authors:
7
- - Rafał Rzepecki
7
+ - Rafal Rzepecki
8
8
  - Kevin Gilpin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-28 00:00:00.000000000 Z
12
+ date: 2014-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - '>='
33
33
  - !ruby/object:Gem::Version
34
- version: 4.10.0
34
+ version: 4.11.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '>='
40
40
  - !ruby/object:Gem::Version
41
- version: 4.10.0
41
+ version: 4.11.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: gli
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -223,12 +223,13 @@ dependencies:
223
223
  version: 0.0.1
224
224
  description:
225
225
  email:
226
- - divided.mind@gmail.com
226
+ - rafal@conjur.net
227
227
  - kgilpin@conjur.net
228
228
  executables:
229
229
  - _conjur_completions
230
230
  - _conjur_completions.yaml
231
231
  - conjur
232
+ - conjurize
232
233
  - jsonfield
233
234
  extensions: []
234
235
  extra_rdoc_files: []
@@ -245,8 +246,10 @@ files:
245
246
  - bin/_conjur_completions
246
247
  - bin/_conjur_completions.yaml
247
248
  - bin/conjur
249
+ - bin/conjurize
248
250
  - bin/jsonfield
249
251
  - conjur.gemspec
252
+ - features/conjurize.feature
250
253
  - features/dsl_context.feature
251
254
  - features/dsl_host_create.feature
252
255
  - features/dsl_ownership.feature
@@ -255,9 +258,13 @@ files:
255
258
  - features/dsl_role_create.feature
256
259
  - features/dsl_user_create.feature
257
260
  - features/jsonfield.feature
261
+ - features/step_definitions/conjurize_steps.rb
258
262
  - features/step_definitions/dsl_steps.rb
263
+ - features/support/conjur-test.pem
264
+ - features/support/conjur.conf
259
265
  - features/support/env.rb
260
266
  - features/support/hooks.rb
267
+ - features/support/host.json
261
268
  - lib/conjur.rb
262
269
  - lib/conjur/audit/follower.rb
263
270
  - lib/conjur/authn.rb
@@ -290,6 +297,7 @@ files:
290
297
  - lib/conjur/command/variables.rb
291
298
  - lib/conjur/config.rb
292
299
  - lib/conjur/conjurenv.rb
300
+ - lib/conjur/conjurize.rb
293
301
  - lib/conjur/dsl/runner.rb
294
302
  - lib/conjur/identifier_manipulation.rb
295
303
  - lib/conjur/version.rb
@@ -340,6 +348,7 @@ signing_key:
340
348
  specification_version: 4
341
349
  summary: Conjur command line interface
342
350
  test_files:
351
+ - features/conjurize.feature
343
352
  - features/dsl_context.feature
344
353
  - features/dsl_host_create.feature
345
354
  - features/dsl_ownership.feature
@@ -348,9 +357,13 @@ test_files:
348
357
  - features/dsl_role_create.feature
349
358
  - features/dsl_user_create.feature
350
359
  - features/jsonfield.feature
360
+ - features/step_definitions/conjurize_steps.rb
351
361
  - features/step_definitions/dsl_steps.rb
362
+ - features/support/conjur-test.pem
363
+ - features/support/conjur.conf
352
364
  - features/support/env.rb
353
365
  - features/support/hooks.rb
366
+ - features/support/host.json
354
367
  - spec/authn_spec.rb
355
368
  - spec/command/assets_spec.rb
356
369
  - spec/command/audit_spec.rb