conjur-cli 4.28.2 → 4.29.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 +4 -4
- data/.dockerignore +8 -0
- data/.gitignore +2 -0
- data/.overcommit.yml +10 -0
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +16 -0
- data/Dockerfile +10 -0
- data/Gemfile +2 -0
- data/Rakefile +1 -1
- data/acceptance-features/audit/audit_event_send.feature +46 -43
- data/acceptance-features/audit/send.feature +0 -19
- data/acceptance-features/authentication/login.feature +0 -2
- data/acceptance-features/authentication/logout.feature +0 -3
- data/acceptance-features/authorization/resource/check.feature +6 -4
- data/acceptance-features/authorization/resource/create.feature +4 -2
- data/acceptance-features/authorization/resource/exists.feature +8 -6
- data/acceptance-features/authorization/resource/give.feature +3 -1
- data/acceptance-features/authorization/resource/show.feature +3 -1
- data/acceptance-features/authorization/role/graph.feature +0 -1
- data/acceptance-features/conjurenv/check.feature +3 -10
- data/acceptance-features/conjurenv/run.feature +3 -3
- data/acceptance-features/conjurenv/template.feature +1 -1
- data/acceptance-features/directory/hostfactory/create.feature +13 -0
- data/acceptance-features/directory/hostfactory/tokens.feature +16 -0
- data/acceptance-features/directory/layer/retire.feature +43 -0
- data/acceptance-features/directory/user/update_password.feature +0 -1
- data/acceptance-features/directory/variable/value.feature +3 -2
- data/acceptance-features/dsl/policy_owner.feature +21 -7
- data/acceptance-features/dsl/resource_owner.feature +4 -4
- data/acceptance-features/pubkeys/add.feature +4 -2
- data/acceptance-features/pubkeys/names.feature +6 -3
- data/acceptance-features/pubkeys/show.feature +4 -2
- data/acceptance-features/step_definitions/{cli.rb → cli_steps.rb} +18 -4
- data/acceptance-features/step_definitions/user_steps.rb +13 -12
- data/acceptance-features/support/env.rb +0 -1
- data/acceptance-features/support/hooks.rb +11 -14
- data/acceptance-features/support/world.rb +16 -18
- data/build-deb.sh +19 -0
- data/ci/test.sh +19 -0
- data/conjur.gemspec +9 -12
- data/debify.sh +4 -0
- data/distrib/bin/_conjur +3 -0
- data/distrib/bin/conjur +3 -0
- data/distrib/bin/conjurize +3 -0
- data/distrib/bin/jsonfield +3 -0
- data/features/conjurize.feature +25 -25
- data/features/support/env.rb +5 -1
- data/features/support/hooks.rb +0 -1
- data/jenkins.sh +29 -1
- data/lib/conjur/cli.rb +27 -4
- data/lib/conjur/command.rb +36 -0
- data/lib/conjur/command/audit.rb +12 -0
- data/lib/conjur/command/bootstrap.rb +5 -9
- data/lib/conjur/command/host_factories.rb +187 -0
- data/lib/conjur/command/hosts.rb +82 -2
- data/lib/conjur/command/layers.rb +28 -0
- data/lib/conjur/command/resources.rb +1 -0
- data/lib/conjur/command/rspec/mock_services.rb +1 -1
- data/lib/conjur/command/server.rb +67 -0
- data/lib/conjur/command/users.rb +67 -12
- data/lib/conjur/command/variables.rb +101 -14
- data/lib/conjur/conjurize.rb +25 -69
- data/lib/conjur/conjurize/script.rb +133 -0
- data/lib/conjur/version.rb +1 -1
- data/publish.sh +6 -0
- data/spec/command/elevate_spec.rb +1 -1
- data/spec/command/host_factories_spec.rb +38 -0
- data/spec/command/hosts_spec.rb +86 -22
- data/spec/command/users_spec.rb +51 -3
- data/spec/command/variable_expiration_spec.rb +174 -0
- data/spec/command/variables_spec.rb +1 -1
- data/spec/conjurize_spec.rb +70 -0
- metadata +61 -64
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Feature: Create a Host Factory
|
|
2
|
+
Background:
|
|
3
|
+
Given I successfully run `conjur layer create --as-group $ns/security_admin $ns/layer`
|
|
4
|
+
|
|
5
|
+
Scenario: Create a host factory successfully
|
|
6
|
+
When I successfully run `conjur hostfactory create --as-group $ns/security_admin --layer $ns/layer $ns/hostfactory`
|
|
7
|
+
Then the JSON should have "deputy_api_key"
|
|
8
|
+
|
|
9
|
+
Scenario: Host factory owner must have admin on layer
|
|
10
|
+
Given I successfully run `conjur user create unprivileged@$ns`
|
|
11
|
+
When I run `conjur hostfactory create --as-role user:unprivileged@$ns --layer $ns/layer $ns/hostfactory`
|
|
12
|
+
Then the stderr should contain "must be an admin of layer"
|
|
13
|
+
And the stdout should not contain anything
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Host factory tokens
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given I successfully run `conjur layer create --as-group $ns/security_admin $ns/layer`
|
|
5
|
+
And I successfully run `conjur hostfactory create --as-group $ns/security_admin --layer $ns/layer $ns/hostfactory`
|
|
6
|
+
|
|
7
|
+
Scenario: create a host factory token
|
|
8
|
+
When I successfully run `conjur hostfactory token create $ns/hostfactory`
|
|
9
|
+
Then the JSON should have "0/token"
|
|
10
|
+
|
|
11
|
+
Scenario: create a host using a token
|
|
12
|
+
When I successfully run `conjur hostfactory token create $ns/hostfactory`
|
|
13
|
+
And I keep the JSON response at "0/token" as "TOKEN"
|
|
14
|
+
Then I successfully run `conjur hostfactory host create %{TOKEN} $ns/host`
|
|
15
|
+
And the JSON should have "api_key"
|
|
16
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Feature: Retire a layer
|
|
2
|
+
Background:
|
|
3
|
+
When I successfully run `conjur layer create $ns/applayer`
|
|
4
|
+
|
|
5
|
+
Scenario: Basic retirement
|
|
6
|
+
Then I successfully run `conjur layer retire -d user:attic@$ns $ns/applayer`
|
|
7
|
+
|
|
8
|
+
Scenario: Retiring a non-existent thing propagates the 404
|
|
9
|
+
Then I run `conjur layer retire -d user:attic@$ns $ns/foobar`
|
|
10
|
+
Then the exit status should be 1
|
|
11
|
+
And the stderr should contain "Resource Not Found"
|
|
12
|
+
|
|
13
|
+
Scenario: A foreign user can't retire a layer
|
|
14
|
+
Given I login as a new user
|
|
15
|
+
And I run `conjur layer retire -d user:attic@$ns $ns/applayer`
|
|
16
|
+
Then the exit status should be 1
|
|
17
|
+
And the stderr should contain "You can't administer this record"
|
|
18
|
+
|
|
19
|
+
Scenario: Can't retire to a non-existant role
|
|
20
|
+
And I run `conjur layer retire -d user:foobar $ns/applayer`
|
|
21
|
+
Then the exit status should be 1
|
|
22
|
+
And the output should match /error: Destination role/
|
|
23
|
+
And the output should match /doesn't exist$/
|
|
24
|
+
|
|
25
|
+
Scenario: I can retire a layer which I've granted to a group
|
|
26
|
+
Given I successfully run `conjur group create $ns/admin`
|
|
27
|
+
And I successfully run `conjur role grant_to layer:$ns/applayer group:$ns/admin`
|
|
28
|
+
Then I successfully run `conjur layer retire -d user:attic@$ns $ns/applayer`
|
|
29
|
+
|
|
30
|
+
Scenario: I can retire a layer which I've given to a group that I can admin
|
|
31
|
+
Given I successfully run `conjur group create $ns/admin`
|
|
32
|
+
And I successfully run `conjur resource give layer:$ns/applayer group:$ns/admin`
|
|
33
|
+
Then I successfully run `conjur layer retire -d user:attic@$ns $ns/applayer`
|
|
34
|
+
|
|
35
|
+
Scenario: I can't retire a layer if I can't admin the layer's role
|
|
36
|
+
Given I successfully run `conjur group create $ns/admin`
|
|
37
|
+
And I successfully run `conjur role grant_to layer:$ns/applayer group:$ns/admin`
|
|
38
|
+
Given I create a new user named "alice@$ns"
|
|
39
|
+
And I successfully run `conjur group members add -a $ns/admin alice@$ns`
|
|
40
|
+
And I login as "alice@$ns"
|
|
41
|
+
And I run `conjur layer retire -d user:attic@$ns $ns/applayer`
|
|
42
|
+
Then the exit status should be 1
|
|
43
|
+
And the stderr should contain "You can't administer this record"
|
|
@@ -7,7 +7,6 @@ Feature: Update the password of the logged-in user
|
|
|
7
7
|
And I run `conjur user update_password` interactively
|
|
8
8
|
Then I can type and confirm a new password
|
|
9
9
|
|
|
10
|
-
@announce
|
|
11
10
|
Scenario: The new password can be used to login
|
|
12
11
|
And I run `conjur user update_password` interactively
|
|
13
12
|
And I type and confirm a new password
|
|
@@ -3,11 +3,12 @@ Feature: Obtain value from variable
|
|
|
3
3
|
Background:
|
|
4
4
|
Given I successfully run `conjur variable create $ns/secret secretvalue`
|
|
5
5
|
And I successfully run `conjur variable values add $ns/secret updatedvalue`
|
|
6
|
+
And I reset the command list
|
|
6
7
|
|
|
7
8
|
Scenario: Recent value is obtained by default
|
|
8
9
|
When I run `conjur variable value $ns/secret`
|
|
9
|
-
Then the
|
|
10
|
+
Then the stdout should contain exactly "updatedvalue"
|
|
10
11
|
|
|
11
12
|
Scenario: Previous values can be obtained by version
|
|
12
13
|
When I run `conjur variable value -v 1 $ns/secret`
|
|
13
|
-
Then the
|
|
14
|
+
Then the stdout should contain exactly "secretvalue"
|
|
@@ -8,24 +8,38 @@ policy 'test-policy-1.0' do
|
|
|
8
8
|
user "test_user"
|
|
9
9
|
end
|
|
10
10
|
"""
|
|
11
|
+
And I reset the command list
|
|
11
12
|
|
|
12
13
|
Scenario: --as-group works
|
|
13
14
|
When I run `conjur policy load --as-group $ns/admin --collection $ns` interactively
|
|
14
15
|
And I pipe in the file "policy.rb"
|
|
15
|
-
And the
|
|
16
|
+
And the command completes successfully
|
|
17
|
+
And I reset the command list
|
|
16
18
|
When I run `conjur role members policy:$ns/test-policy-1.0`
|
|
17
|
-
Then the
|
|
19
|
+
Then the JSON should be:
|
|
20
|
+
"""
|
|
21
|
+
[
|
|
22
|
+
"cucumber:group:%{NAMESPACE}/admin"
|
|
23
|
+
]
|
|
24
|
+
"""
|
|
18
25
|
|
|
19
26
|
Scenario: --as-role works
|
|
20
27
|
When I run `conjur policy load --as-role group:$ns/admin --collection $ns` interactively
|
|
21
28
|
And I pipe in the file "policy.rb"
|
|
22
|
-
And the
|
|
29
|
+
And the command completes successfully
|
|
30
|
+
And I reset the command list
|
|
23
31
|
When I run `conjur role members policy:$ns/test-policy-1.0`
|
|
24
|
-
Then the
|
|
32
|
+
Then the JSON should be:
|
|
33
|
+
"""
|
|
34
|
+
[
|
|
35
|
+
"cucumber:group:%{NAMESPACE}/admin"
|
|
36
|
+
]
|
|
37
|
+
"""
|
|
25
38
|
|
|
26
39
|
Scenario: --as-group doesn't interfere with policy ownership of other resources
|
|
27
40
|
When I run `conjur policy load --as-group $ns/admin --collection $ns` interactively
|
|
28
41
|
And I pipe in the file "policy.rb"
|
|
29
|
-
And the
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
And the command completes successfully
|
|
43
|
+
And I reset the command list
|
|
44
|
+
When I run `conjur resource show user:test_user@$ns-test-policy-1-0`
|
|
45
|
+
Then the JSON at "owner" should be "cucumber:policy:%{NAMESPACE}/test-policy-1.0"
|
|
@@ -11,7 +11,7 @@ end
|
|
|
11
11
|
Scenario: resource is create with correct ownership
|
|
12
12
|
When I run `conjur policy load --collection $ns` interactively
|
|
13
13
|
And I pipe in the file "policy.rb"
|
|
14
|
-
And the
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
And the command completes successfully
|
|
15
|
+
And I reset the command list
|
|
16
|
+
When I run `conjur resource show webservice:$ns/test-policy-1.0/web1`
|
|
17
|
+
Then the JSON at "owner" should be "cucumber:policy:%{NAMESPACE}/test-policy-1.0"
|
|
@@ -3,6 +3,7 @@ Feature: Register a public key
|
|
|
3
3
|
Background:
|
|
4
4
|
Given I successfully run `conjur user create alice@$ns`
|
|
5
5
|
And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
|
|
6
|
+
And I reset the command list
|
|
6
7
|
|
|
7
8
|
Scenario: Register a public key file for a user
|
|
8
9
|
When I run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
@@ -11,10 +12,11 @@ Feature: Register a public key
|
|
|
11
12
|
Scenario: You can't accidentally register the private key
|
|
12
13
|
When I run `conjur pubkeys add alice@$ns @id_alice_$ns`
|
|
13
14
|
Then the exit status should be 1
|
|
14
|
-
And the stderr
|
|
15
|
+
And the stderr should contain "Unprocessable Entity"
|
|
15
16
|
|
|
16
17
|
Scenario: Unauthorized users cannot modify public keys
|
|
17
18
|
Given I login as new user "bob@$ns"
|
|
19
|
+
And I reset the command list
|
|
18
20
|
And I run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
19
21
|
Then the exit status should be 1
|
|
20
|
-
And the stderr
|
|
22
|
+
And the stderr should contain "Forbidden"
|
|
@@ -3,15 +3,17 @@ Feature: List known public key names for a user
|
|
|
3
3
|
Background:
|
|
4
4
|
Given I successfully run `conjur user create alice@$ns`
|
|
5
5
|
And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
|
|
6
|
+
And I reset the command list
|
|
6
7
|
|
|
7
8
|
Scenario: Initial key names list is empty
|
|
8
9
|
When I run `conjur pubkeys names alice@$ns`
|
|
9
|
-
Then the stdout
|
|
10
|
+
Then the stdout should contain exactly ""
|
|
10
11
|
|
|
11
12
|
Scenario: After adding a key, the key name is shown
|
|
12
13
|
Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
14
|
+
And I reset the command list
|
|
13
15
|
And I run `conjur pubkeys names alice@$ns`
|
|
14
|
-
Then the stdout
|
|
16
|
+
Then the stdout should contain exactly:
|
|
15
17
|
"""
|
|
16
18
|
laptop\n
|
|
17
19
|
"""
|
|
@@ -19,5 +21,6 @@ Feature: List known public key names for a user
|
|
|
19
21
|
Scenario: After deleting the key, the key names list is empty again
|
|
20
22
|
Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
21
23
|
And I successfully run `conjur pubkeys delete alice@$ns laptop`
|
|
24
|
+
And I reset the command list
|
|
22
25
|
And I run `conjur pubkeys names alice@$ns`
|
|
23
|
-
Then the stdout
|
|
26
|
+
Then the stdout should contain exactly ""
|
|
@@ -3,10 +3,11 @@ Feature: Show public keys for a user
|
|
|
3
3
|
Background:
|
|
4
4
|
Given I successfully run `conjur user create alice@$ns`
|
|
5
5
|
And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
|
|
6
|
+
And I reset the command list
|
|
6
7
|
|
|
7
8
|
Scenario: Initial key list is empty
|
|
8
9
|
When I run `conjur pubkeys show alice@$ns`
|
|
9
|
-
Then the stdout
|
|
10
|
+
Then the stdout should contain exactly "\n"
|
|
10
11
|
|
|
11
12
|
Scenario: After adding a key, the key is shown
|
|
12
13
|
Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
@@ -16,8 +17,9 @@ Feature: Show public keys for a user
|
|
|
16
17
|
Scenario: After deleting the key, the key list is empty again
|
|
17
18
|
Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
18
19
|
And I successfully run `conjur pubkeys delete alice@$ns laptop`
|
|
20
|
+
And I reset the command list
|
|
19
21
|
And I run `conjur pubkeys show alice@$ns`
|
|
20
|
-
Then the stdout
|
|
22
|
+
Then the stdout should contain exactly "\n"
|
|
21
23
|
|
|
22
24
|
Scenario: Public keys can be listed using cURL, without authentication
|
|
23
25
|
Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
Then /^I
|
|
2
|
-
|
|
1
|
+
Then /^I reset the command list/ do
|
|
2
|
+
aruba.command_monitor.clear
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
When /^the command completes successfully/ do
|
|
6
|
+
last_command_started.wait
|
|
7
|
+
last_command_started.terminate
|
|
8
|
+
expect(last_command_started.exit_status).to eq(0)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Then /^I send the audit event:/ do |event|
|
|
12
|
+
event = event.gsub('$ns',@namespace)
|
|
13
|
+
step "I run `env RESTCLIENT_LOG=stderr conjur audit send` interactively"
|
|
14
|
+
last_command_started.write event
|
|
15
|
+
last_command_started.close_io :stdin
|
|
16
|
+
step "the command completes successfully"
|
|
3
17
|
end
|
|
4
18
|
|
|
5
19
|
# this is step copypasted from https://github.com/cucumber/aruba/blob/master/lib/aruba/cucumber.rb#L24
|
|
@@ -14,9 +28,9 @@ Given(/^a file named "([^"]*?)" with namespace substitution:$/) do |file_name, f
|
|
|
14
28
|
end
|
|
15
29
|
|
|
16
30
|
Then /^it prints the path to temporary file which contains: '(.*)'$/ do |content|
|
|
17
|
-
filename =
|
|
31
|
+
filename = last_command_started.stdout.strip
|
|
18
32
|
tempfiles << filename
|
|
19
|
-
actual_content=File.read(filename)
|
|
33
|
+
actual_content = File.read(filename)
|
|
20
34
|
expect(actual_content).to match(content)
|
|
21
35
|
end
|
|
22
36
|
|
|
@@ -9,23 +9,23 @@ end
|
|
|
9
9
|
|
|
10
10
|
Given(/^I create a new user named "(.*?)"$/) do |username|
|
|
11
11
|
username_ns = username.gsub('$ns',@namespace)
|
|
12
|
-
password = find_or_create_password(username_ns)
|
|
13
12
|
|
|
14
|
-
step "I run `conjur user create --as-role user:admin@#{@namespace}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
step "I successfully run `conjur user create --as-role user:admin@#{@namespace} #{username_ns}`"
|
|
14
|
+
|
|
15
|
+
user_info = JSON.parse(last_command_started.stdout)
|
|
16
|
+
save_password username_ns, user_info['api_key']
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
Given(/^I create a new host with id "(.*?)"$/) do |hostid|
|
|
21
20
|
step "I successfully run `conjur host create #{@namespace}/monitoring/server`"
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
host = JSON.parse(last_json)
|
|
22
|
+
@host_id = host['id']
|
|
23
|
+
@host_api_key = host['api_key']
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
Given(/^I login as
|
|
27
|
-
step
|
|
28
|
-
step
|
|
26
|
+
Given(/^I login as the new host/) do
|
|
27
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "host/#{@host_id}")
|
|
28
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{@host_api_key}")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
Given(/^I login as new user "(.*?)"$/) do |username|
|
|
@@ -36,9 +36,10 @@ end
|
|
|
36
36
|
|
|
37
37
|
Given(/^I login as "(.*?)"$/) do |username|
|
|
38
38
|
username_ns = username.gsub('$ns',@namespace)
|
|
39
|
-
password =
|
|
39
|
+
password = find_password(username_ns)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{username_ns}")
|
|
42
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{password}")
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
Then(/^I(?: can)? type and confirm a new password/) do
|
|
@@ -6,41 +6,42 @@ require 'conjur/authn'
|
|
|
6
6
|
netrc = Conjur::Authn.netrc
|
|
7
7
|
username, password = Conjur::Authn.get_credentials
|
|
8
8
|
raise "Not logged in to Conjur" unless username && password
|
|
9
|
-
puts "
|
|
9
|
+
puts "Performing acceptance tests as root-ish user '#{username}'"
|
|
10
10
|
|
|
11
11
|
# Future Aruba
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Aruba.configure do |config|
|
|
13
|
+
config.exit_timeout = 15
|
|
14
|
+
config.io_wait_timeout = 2
|
|
15
|
+
end
|
|
15
16
|
|
|
16
17
|
Before('@conjurapi-log') do
|
|
17
18
|
set_env 'CONJURAPI_LOG', 'stderr'
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
Before do
|
|
21
|
-
|
|
22
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{username}")
|
|
23
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{password}")
|
|
22
24
|
|
|
23
25
|
@admin_api = conjur_api = Conjur::Authn.connect
|
|
24
26
|
|
|
25
27
|
@namespace = conjur_api.create_variable("text/plain", "id").id
|
|
26
28
|
user = conjur_api.create_user "admin@#{@namespace}", ownerid: "#{Conjur.configuration.account}:user:#{username}"
|
|
27
29
|
|
|
28
|
-
netrc[Conjur::Authn.host] = [ "admin@#{@namespace}", user.api_key ]
|
|
29
|
-
netrc.save
|
|
30
|
-
|
|
31
30
|
conjur_api = Conjur::Authn.connect
|
|
32
31
|
@security_admin = conjur_api.create_group [ @namespace, "security_admin" ].join('/')
|
|
33
32
|
@security_admin.add_member user, admin_option: true
|
|
34
33
|
|
|
35
34
|
JsonSpec.memorize "MY_ROLEID", %Q("#{user.roleid}")
|
|
35
|
+
JsonSpec.memorize "NAMESPACE", @namespace
|
|
36
36
|
|
|
37
37
|
@admin_api.group("pubkeys-1.0/key-managers").add_member @security_admin
|
|
38
38
|
@admin_api.resource('!:!:conjur').permit 'elevate', user, grant_option: true
|
|
39
39
|
@admin_api.resource('!:!:conjur').permit 'reveal', user, grant_option: true
|
|
40
40
|
|
|
41
41
|
conjur_api.create_user "attic@#{@namespace}"
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{user.login}")
|
|
44
|
+
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{user.api_key}")
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
After do
|
|
@@ -50,10 +51,6 @@ After do
|
|
|
50
51
|
tempfiles.each { |tempfile| File.unlink(tempfile) unless tempfile.nil? }
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
at_exit do
|
|
54
|
-
Conjur::Authn.save_credentials username: username, password: password
|
|
55
|
-
end
|
|
56
|
-
|
|
57
54
|
require 'ostruct'
|
|
58
55
|
|
|
59
56
|
class MockAPI
|
|
@@ -5,13 +5,25 @@ module ConjurCLIWorld
|
|
|
5
5
|
include Aruba::Api
|
|
6
6
|
|
|
7
7
|
def last_json
|
|
8
|
-
|
|
8
|
+
process_cmd last_command_started.stdout
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def
|
|
11
|
+
def passwords
|
|
12
12
|
@passwords ||= {}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def save_password username, password
|
|
16
|
+
raise "Found existing password for user '#{username}'" if passwords[username]
|
|
17
|
+
passwords[username] = password
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def find_password username
|
|
21
|
+
passwords[username] or raise "No password for user '#{username}'"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def find_or_create_password(username)
|
|
25
|
+
unless password = passwords[username]
|
|
26
|
+
password = passwords[username] = SecureRandom.hex(12)
|
|
15
27
|
end
|
|
16
28
|
password
|
|
17
29
|
end
|
|
@@ -24,21 +36,8 @@ module ConjurCLIWorld
|
|
|
24
36
|
def run(cmd, *args)
|
|
25
37
|
# it's a thunk now so it should be returned. puts can be added back as block if we want to
|
|
26
38
|
super process_cmd(cmd), *args
|
|
27
|
-
|
|
28
|
-
#puts stderr_from(cmd)
|
|
29
|
-
#puts stdout_from(cmd)
|
|
30
39
|
end
|
|
31
40
|
|
|
32
|
-
def stderr_from(cmd)
|
|
33
|
-
super process_cmd(cmd)
|
|
34
|
-
end
|
|
35
|
-
def stdout_from(cmd)
|
|
36
|
-
super process_cmd(cmd)
|
|
37
|
-
end
|
|
38
|
-
def output_from(cmd)
|
|
39
|
-
super process_cmd(cmd)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
41
|
# Substitute the namespace for marker $ns
|
|
43
42
|
def unescape(string)
|
|
44
43
|
string = super
|
|
@@ -60,7 +59,6 @@ module ConjurCLIWorld
|
|
|
60
59
|
cmd.gsub!("$ns", namespace)
|
|
61
60
|
cmd.gsub!("$pubkeys_url", Conjur.configuration.pubkeys_url)
|
|
62
61
|
|
|
63
|
-
@last_cmd = cmd
|
|
64
62
|
JsonSpec.memory.each do |k,v|
|
|
65
63
|
cmd.gsub!("%{#{k}}", v)
|
|
66
64
|
end
|