conjur-cli 4.26.0 → 4.27.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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/acceptance-features/audit/audit_event_send.feature +104 -0
  4. data/acceptance-features/audit/send.feature +70 -0
  5. data/acceptance-features/authentication/authenticate.feature +10 -0
  6. data/acceptance-features/authentication/login.feature +14 -0
  7. data/acceptance-features/authentication/logout.feature +16 -0
  8. data/acceptance-features/authentication/whoami.feature +5 -0
  9. data/acceptance-features/authorization/resource/annotate.feature +35 -0
  10. data/acceptance-features/authorization/resource/check.feature +22 -0
  11. data/acceptance-features/authorization/resource/create.feature +19 -0
  12. data/acceptance-features/authorization/resource/deny.feature +12 -0
  13. data/acceptance-features/authorization/resource/exists.feature +16 -0
  14. data/acceptance-features/authorization/resource/give.feature +22 -0
  15. data/acceptance-features/authorization/resource/permit.feature +20 -0
  16. data/acceptance-features/authorization/resource/permitted_roles.feature +16 -0
  17. data/acceptance-features/authorization/resource/show.feature +26 -0
  18. data/acceptance-features/authorization/role/create.feature +13 -0
  19. data/acceptance-features/authorization/role/exists.feature +19 -0
  20. data/acceptance-features/authorization/role/grant_to.feature +21 -0
  21. data/acceptance-features/authorization/role/graph.feature +58 -0
  22. data/acceptance-features/authorization/role/members.feature +23 -0
  23. data/acceptance-features/authorization/role/memberships.feature +27 -0
  24. data/acceptance-features/conjurenv/check.feature +28 -0
  25. data/acceptance-features/conjurenv/run.feature +10 -0
  26. data/acceptance-features/conjurenv/template.feature +11 -0
  27. data/acceptance-features/directory/group/create.feature +20 -0
  28. data/acceptance-features/directory/group/retire.feature +54 -0
  29. data/acceptance-features/directory/host/create.feature +23 -0
  30. data/acceptance-features/directory/host/retire.feature +6 -0
  31. data/acceptance-features/directory/layer/create.feature +10 -0
  32. data/acceptance-features/directory/layer/hosts-add.feature +9 -0
  33. data/acceptance-features/directory/layer/hosts-remove.feature +10 -0
  34. data/acceptance-features/directory/user/create.feature +23 -0
  35. data/acceptance-features/directory/user/retire.feature +6 -0
  36. data/acceptance-features/directory/user/update_password.feature +16 -0
  37. data/acceptance-features/directory/variable/create.feature +14 -0
  38. data/acceptance-features/directory/variable/retire.feature +17 -0
  39. data/acceptance-features/directory/variable/value.feature +13 -0
  40. data/acceptance-features/directory/variable/values-add.feature +12 -0
  41. data/acceptance-features/global-privilege/elevate.feature +20 -0
  42. data/acceptance-features/global-privilege/reveal.privilege +20 -0
  43. data/acceptance-features/pubkeys/add.feature +20 -0
  44. data/acceptance-features/pubkeys/delete.feature +9 -0
  45. data/acceptance-features/pubkeys/names.feature +23 -0
  46. data/acceptance-features/pubkeys/show.feature +25 -0
  47. data/acceptance-features/step_definitions/cli.rb +21 -0
  48. data/acceptance-features/step_definitions/graph_steps.rb +22 -0
  49. data/acceptance-features/step_definitions/user_steps.rb +54 -0
  50. data/acceptance-features/support/env.rb +5 -0
  51. data/acceptance-features/support/hooks.rb +179 -0
  52. data/acceptance-features/support/world.rb +153 -0
  53. data/conjur.gemspec +4 -1
  54. data/features/step_definitions/graph_steps.rb +2 -2
  55. data/features/support/hooks.rb +1 -5
  56. data/lib/conjur/cli.rb +1 -1
  57. data/lib/conjur/command/bootstrap.rb +3 -2
  58. data/lib/conjur/command/elevate.rb +76 -0
  59. data/lib/conjur/command/rspec/mock_services.rb +3 -3
  60. data/lib/conjur/command.rb +15 -0
  61. data/lib/conjur/version.rb +1 -1
  62. data/spec/command/elevate_spec.rb +28 -0
  63. metadata +85 -4
@@ -0,0 +1,28 @@
1
+ Feature: Check an environment
2
+
3
+ Background:
4
+ Given I run `conjur variable create $ns/access_key ABCDEF`
5
+ And I run `conjur variable create $ns/secret_key XYZQWER`
6
+ And I run `conjur variable create $ns/ssh_private_key PRIVATE_KEY_BODY`
7
+ And I run `conjur user create -p alice@$ns` interactively
8
+ And I type "foobar"
9
+ And I type "foobar"
10
+ And the exit status should be 0
11
+ And I run `conjur resource permit variable:$ns/access_key user:alice@$ns execute`
12
+ And I run `conjur resource permit variable:$ns/secret_key user:alice@$ns execute`
13
+ And I run `conjur authn login -u alice@$ns` interactively
14
+ And I type "foobar"
15
+ And the exit status should be 0
16
+
17
+
18
+ Scenario: Check against permitted variables
19
+
20
+ When I run `conjur env check --yaml '{ aws_access_key: !var $ns/access_key , aws_secret_key: !var $ns/secret_key }'`
21
+ Then the exit status should be 0
22
+ And the stdout should contain "aws_access_key: available\naws_secret_key: available\n"
23
+
24
+ Scenario: Check against restricted variables
25
+ When I run `conjur env check --yaml '{ aws_access_key: !var $ns/access_key , ssh_private_key: !var $ns/ssh_private_key }'`
26
+ Then the exit status should be 1
27
+ And the stdout should contain "aws_access_key: available\nssh_private_key: unavailable\n"
28
+
@@ -0,0 +1,10 @@
1
+ Feature: Run command in an environment populated from Conjur variables
2
+
3
+ Background:
4
+ Given I run `conjur variable create $ns/access_key ABCDEF`
5
+ And I run `conjur variable create $ns/secret_key XYZQWER`
6
+
7
+ Scenario:
8
+ When I run `conjur env run --yaml '{ cloud_access_key: !var $ns/access_key , cloud_secret_key: !var $ns/secret_key }' -- printenv CLOUD_ACCESS_KEY CLOUD_SECRET_KEY`
9
+ Then the stdout should contain "ABCDEF\nXYZQWER"
10
+
@@ -0,0 +1,11 @@
1
+ Feature: Embed values of Conjur variables into ERB template
2
+
3
+ Background:
4
+ Given a file named "template.erb" with: 'aws credentials: [<%= conjurenv["aws_access_key"] %>, <%= conjurenv["aws_secret_key"] %>]'
5
+ And I run `conjur variable create $ns/access_key ABCDEF`
6
+ And I run `conjur variable create $ns/secret_key XYZQWER`
7
+
8
+ Scenario:
9
+ When I run `conjur env template --yaml '{ aws_access_key: !var $ns/access_key , aws_secret_key: !var $ns/secret_key }' template.erb `
10
+ Then it prints the path to temporary file which contains: 'aws credentials: [ABCDEF, XYZQWER]'
11
+
@@ -0,0 +1,20 @@
1
+ Feature: Create a group
2
+
3
+ Scenario: Create a new group
4
+ When I successfully run `conjur group create $ns/ops`
5
+ Then the JSON response should have the following:
6
+ | id |
7
+ | ownerid |
8
+ | resource_identifier |
9
+ | roleid |
10
+ And the JSON response at "id" should include "/ops"
11
+
12
+ Scenario: Add a user to the group and show the list of members
13
+ Given I successfully run `conjur user create bob@$ns`
14
+ And I successfully run `conjur group create $ns/ops`
15
+ And I successfully run `conjur group members add $ns/ops user:bob@$ns`
16
+ When I successfully run `conjur group members list $ns/ops`
17
+ Then the JSON response should have 2 entries
18
+ And the JSON response at "0" should include "admin@"
19
+ And the JSON response at "1" should include "bob@"
20
+
@@ -0,0 +1,54 @@
1
+ Feature: Retire a group
2
+ Background:
3
+ When I successfully run `conjur group create $ns/ops`
4
+
5
+ Scenario: Basic retirement
6
+ Then I successfully run `conjur group retire -d user:attic@$ns $ns/ops`
7
+
8
+ Scenario: Retiring a non-existent thing propagates the 404
9
+ Then I run `conjur group 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 group
14
+ Given I login as a new user
15
+ And I run `conjur group retire -d user:attic@$ns $ns/ops`
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 group retire -d user:foobar $ns/ops`
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 group which I've granted to another group
26
+ Given I successfully run `conjur group create $ns/admin`
27
+ And I successfully run `conjur role grant_to group:$ns/ops group:$ns/admin`
28
+ Then I successfully run `conjur group retire -d user:attic@$ns $ns/ops`
29
+
30
+ Scenario: I can retire a group 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 group:$ns/ops group:$ns/admin`
33
+ Then I successfully run `conjur group retire -d user:attic@$ns $ns/ops`
34
+
35
+ Scenario: I can't retire a group if I can't admin the group's role
36
+ Given I successfully run `conjur group create $ns/admin`
37
+ And I successfully run `conjur role grant_to group:$ns/ops 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 group retire -d user:attic@$ns $ns/ops`
42
+ Then the exit status should be 1
43
+ And the stderr should contain "You can't administer this record"
44
+
45
+ Scenario: I can't retire a group if I can't admin the group's record
46
+ Given I successfully run `conjur group create $ns/admin`
47
+ And I successfully run `conjur role grant_to -a group:$ns/ops group:$ns/admin`
48
+ Given I create a new user named "alice@$ns"
49
+ And I successfully run `conjur group members add -a $ns/admin alice@$ns`
50
+ And I login as "alice@$ns"
51
+ And I run `conjur group retire -d user:attic@$ns $ns/ops`
52
+ Then the exit status should be 1
53
+ And the stderr should contain "You don't own the record"
54
+
@@ -0,0 +1,23 @@
1
+ Feature: Create a Host
2
+
3
+ Scenario: Create a host with automatically generated ID
4
+ When I successfully run `conjur host create`
5
+ And the JSON should have "api_key"
6
+ And the JSON should have "id"
7
+
8
+ Scenario: Create a host with explicit ID
9
+ When I successfully run `conjur host create $ns.myhost.example.com`
10
+ And the JSON should have "api_key"
11
+ And I keep the JSON response at "id" as "ID"
12
+ Then the output should contain "myhost.example.com"
13
+
14
+ Scenario: Create a host owned by the security_admin group
15
+ When I successfully run `conjur host create --as-group $ns/security_admin`
16
+ And I keep the JSON response at "ownerid" as "OWNERID"
17
+ Then the output should contain "/security_admin"
18
+
19
+ Scenario: Host does not belong to any layers by default
20
+ When I successfully run `conjur host create $ns.myhost.example.com`
21
+ And I successfully run `conjur host layers $ns.myhost.example.com`
22
+ And the JSON should be []
23
+
@@ -0,0 +1,6 @@
1
+ Feature: Retire a host
2
+ Background:
3
+ When I successfully run `conjur host create $ns/host`
4
+
5
+ Scenario: Basic retirement
6
+ Then I successfully run `conjur host retire -d user:attic@$ns $ns/host`
@@ -0,0 +1,10 @@
1
+ Feature: Create a layer
2
+
3
+ Scenario: Create a layer
4
+ When I successfully run `conjur layer create $ns/test_layer`
5
+ Then the JSON response at "id" should include "test_layer"
6
+ And the JSON response at "hosts" should be []
7
+
8
+ Scenario: Create a layer owned by the security_admin group
9
+ When I successfully run `conjur layer create --as-group $ns/security_admin $ns/test_layer`
10
+ Then the JSON response at "ownerid" should include "security_admin"
@@ -0,0 +1,9 @@
1
+ Feature: Add hosts to layer
2
+
3
+ Background:
4
+ Given I run `conjur layer create $ns/testlayer`
5
+ And I run `conjur host create $ns.example.com`
6
+
7
+ Scenario: Add host to layer
8
+ When I successfully run `conjur layer hosts add $ns/testlayer $ns.example.com`
9
+ Then the output should contain "Host added"
@@ -0,0 +1,10 @@
1
+ Feature: Remove hosts from layer
2
+
3
+ Background:
4
+ Given I run `conjur layer create $ns/testlayer`
5
+ And I run `conjur host create $ns.example.com`
6
+ And I run `conjur layer hosts add $ns/testlayer $ns.example.com`
7
+
8
+ Scenario: Remove host from layer
9
+ When I successfully run `conjur layer hosts remove $ns/testlayer $ns.example.com`
10
+ Then the output should contain "Host removed"
@@ -0,0 +1,23 @@
1
+ Feature: Create a User
2
+
3
+ Scenario: Create a passwordless user
4
+ When I successfully run `conjur user create alice-without-password@$ns`
5
+ And the JSON should have "api_key"
6
+
7
+ Scenario: Create a user with a password
8
+ When I run `conjur user create -p alice-with-password@$ns` interactively
9
+ And I type "foobar"
10
+ And I type "foobar"
11
+ Then the exit status should be 0
12
+ And the JSON should have "api_key"
13
+
14
+ Scenario: Create a user owned by the security_admin group
15
+ When I successfully run `conjur user create --as-group $ns/security_admin alice-without-password@$ns`
16
+ And I keep the JSON response at "ownerid" as "OWNERID"
17
+ Then the output should contain "/security_admin"
18
+
19
+ Scenario: Some characters are disallowed in user ids, such as /
20
+ When I run `conjur user create alice/$ns`
21
+ Then the exit status should be 1
22
+ And the stderr should contain "error: 403 Forbidden"
23
+ And the stdout should not contain anything
@@ -0,0 +1,6 @@
1
+ Feature: Retire a user
2
+ Background:
3
+ When I successfully run `conjur user create --as-role user:admin@$ns alice@$ns`
4
+
5
+ Scenario: Basic retirement
6
+ Then I successfully run `conjur user retire -d user:attic@$ns alice@$ns`
@@ -0,0 +1,16 @@
1
+ Feature: Update the password of the logged-in user
2
+
3
+ Background:
4
+ Given I login as a new user
5
+
6
+ Scenario: A user can update her own password
7
+ And I run `conjur user update_password` interactively
8
+ Then I can type and confirm a new password
9
+
10
+ @announce
11
+ Scenario: The new password can be used to login
12
+ And I run `conjur user update_password` interactively
13
+ And I type and confirm a new password
14
+ And I run `conjur authn login alice@$ns` interactively
15
+ And I enter the password
16
+ Then the exit status should be 0
@@ -0,0 +1,14 @@
1
+ Feature: create an empty variable
2
+
3
+ Background:
4
+ Given I successfully run `conjur variable create $ns/secret`
5
+
6
+ Scenario: Variable is created and responds to metadata
7
+ When I run `conjur variable show $ns/secret`
8
+ Then the JSON should have "id"
9
+ And the JSON should have "ownerid"
10
+ And the JSON at "version_count" should be 0
11
+
12
+ Scenario: Variable keeps no value
13
+ When I run `conjur variable value $ns/secret`
14
+ Then the exit status should be 1
@@ -0,0 +1,17 @@
1
+ Feature: Retire a variable
2
+ Background:
3
+ Given I successfully run `conjur variable create $ns/secret the-value`
4
+
5
+ Scenario: Basic retirement
6
+ Then I successfully run `conjur variable retire -d user:attic@$ns $ns/secret`
7
+
8
+ Scenario: A foreign user can't retire a secret
9
+ Given I login as a new user
10
+ And I run `conjur variable retire -d user:attic@$ns $ns/secret`
11
+ Then the exit status should be 1
12
+ And the stderr should contain "You don't own the record"
13
+
14
+ Scenario: I can retire a variable which I've given to a group that I can admin
15
+ Given I successfully run `conjur group create $ns/admin`
16
+ And I successfully run `conjur resource give variable:$ns/secret group:$ns/admin`
17
+ Then I successfully run `conjur variable retire -d user:attic@$ns $ns/secret`
@@ -0,0 +1,13 @@
1
+ Feature: Obtain value from variable
2
+
3
+ Background:
4
+ Given I successfully run `conjur variable create $ns/secret secretvalue`
5
+ And I successfully run `conjur variable values add $ns/secret updatedvalue`
6
+
7
+ Scenario: Recent value is obtained by default
8
+ When I run `conjur variable value $ns/secret`
9
+ Then the output should match /updatedvalue$/
10
+
11
+ Scenario: Previous values can be obtained by version
12
+ When I run `conjur variable value -v 1 $ns/secret`
13
+ Then the output should match /secretvalue$/
@@ -0,0 +1,12 @@
1
+ Feature: Populate variable with values
2
+
3
+ Background:
4
+ Given I successfully run `conjur variable create $ns/secret initialvalue`
5
+
6
+ Scenario: Value provided via command-line parameter
7
+ When I run `conjur variable values add $ns/secret secretvalue`
8
+ Then the output should contain "Value added"
9
+
10
+ Scenario: Value provided via stdin
11
+ When I run `bash -c 'echo "secretvalue" | conjur variable values add $ns/secret'`
12
+ Then the output should contain "Value added"
@@ -0,0 +1,20 @@
1
+ Feature: 'elevate' can be used to activate root-like privileges
2
+
3
+ Background:
4
+ Given I successfully run `conjur variable create $ns/secret secretvalue`
5
+ And I create a new user named "alice@$ns"
6
+
7
+ Scenario: The secret value is not accessible without 'elevate' privilege
8
+ Given I login as "alice@$ns"
9
+ When I run `conjur variable value $ns/secret`
10
+ Then the exit status should be 1
11
+
12
+ Scenario: 'elevate' can't be used without permission
13
+ Given I login as "alice@$ns"
14
+ When I run `conjur elevate variable show $ns/secret`
15
+ Then the exit status should be 1
16
+
17
+ Scenario: The secret value is accessible with 'elevate' privilege
18
+ Given I successfully run `conjur resource permit '!:!:conjur' user:alice@$ns elevate`
19
+ And I login as "alice@$ns"
20
+ Then I successfully run `conjur elevate variable value $ns/secret`
@@ -0,0 +1,20 @@
1
+ Feature: 'reveal' can be used to see all records
2
+
3
+ Background:
4
+ Given I successfully run `conjur variable create $ns/secret secretvalue`
5
+ And I create a new user named "alice@$ns"
6
+
7
+ Scenario: The secret value is not accessible without 'reveal' privilege
8
+ Given I login as "alice@$ns"
9
+ When I run `conjur variable show $ns/secret`
10
+ Then the exit status should be 1
11
+
12
+ Scenario: 'reveal' can't be used without permission
13
+ Given I login as "alice@$ns"
14
+ When I run `conjur reveal variable show $ns/secret`
15
+ Then the exit status should be 1
16
+
17
+ Scenario: The secret value is accessible with 'reveal' privilege
18
+ Given I successfully run `conjur resource permit '!:!:conjur' user:alice@$ns reveal`
19
+ And I login as "alice@$ns"
20
+ Then I successfully run `conjur reveal variable show $ns/secret`
@@ -0,0 +1,20 @@
1
+ Feature: Register a public key
2
+
3
+ Background:
4
+ Given I successfully run `conjur user create alice@$ns`
5
+ And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
6
+
7
+ Scenario: Register a public key file for a user
8
+ When I run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
9
+ Then the exit status should be 0
10
+
11
+ Scenario: You can't accidentally register the private key
12
+ When I run `conjur pubkeys add alice@$ns @id_alice_$ns`
13
+ Then the exit status should be 1
14
+ And the stderr from "conjur pubkeys add alice@$ns @id_alice_$ns" should contain "Unprocessable Entity"
15
+
16
+ Scenario: Unauthorized users cannot modify public keys
17
+ Given I login as new user "bob@$ns"
18
+ And I run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
19
+ Then the exit status should be 1
20
+ And the stderr from "conjur pubkeys add alice@$ns @id_alice_$ns.pub" should contain "Forbidden"
@@ -0,0 +1,9 @@
1
+ Feature: Remove a public key
2
+
3
+ Background:
4
+ Given I successfully run `conjur user create alice@$ns`
5
+ And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
6
+
7
+ Scenario: To remove a public key, use the user's login name and the key name (-C option to ssh-keygen)
8
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
9
+ Then I successfully run `conjur pubkeys delete alice@$ns laptop`
@@ -0,0 +1,23 @@
1
+ Feature: List known public key names for a user
2
+
3
+ Background:
4
+ Given I successfully run `conjur user create alice@$ns`
5
+ And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
6
+
7
+ Scenario: Initial key names list is empty
8
+ When I run `conjur pubkeys names alice@$ns`
9
+ Then the stdout from "conjur pubkeys names alice@$ns" should contain exactly ""
10
+
11
+ Scenario: After adding a key, the key name is shown
12
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
13
+ And I run `conjur pubkeys names alice@$ns`
14
+ Then the stdout from "conjur pubkeys names alice@$ns" should contain exactly:
15
+ """
16
+ laptop\n
17
+ """
18
+
19
+ Scenario: After deleting the key, the key names list is empty again
20
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
21
+ And I successfully run `conjur pubkeys delete alice@$ns laptop`
22
+ And I run `conjur pubkeys names alice@$ns`
23
+ Then the stdout from "conjur pubkeys names alice@$ns" should contain exactly ""
@@ -0,0 +1,25 @@
1
+ Feature: Show public keys for a user
2
+
3
+ Background:
4
+ Given I successfully run `conjur user create alice@$ns`
5
+ And I successfully run `ssh-keygen -t rsa -C "laptop" -N "" -f ./id_alice_$ns`
6
+
7
+ Scenario: Initial key list is empty
8
+ When I run `conjur pubkeys show alice@$ns`
9
+ Then the stdout from "conjur pubkeys show alice@$ns" should contain exactly "\n"
10
+
11
+ Scenario: After adding a key, the key is shown
12
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
13
+ And I run `conjur pubkeys show alice@$ns`
14
+ And the output should match /^ssh-rsa .* laptop$/
15
+
16
+ Scenario: After deleting the key, the key list is empty again
17
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
18
+ And I successfully run `conjur pubkeys delete alice@$ns laptop`
19
+ And I run `conjur pubkeys show alice@$ns`
20
+ Then the stdout from "conjur pubkeys show alice@$ns" should contain exactly "\n"
21
+
22
+ Scenario: Public keys can be listed using cURL, without authentication
23
+ Given I successfully run `conjur pubkeys add alice@$ns @id_alice_$ns.pub`
24
+ When I successfully run `curl -k $pubkeys_url/alice@$ns`
25
+ Then the output should match /^ssh-rsa .* laptop$/
@@ -0,0 +1,21 @@
1
+ Then /^I show the output$/ do
2
+ puts all_output
3
+ end
4
+
5
+ # this is step copypasted from https://github.com/cucumber/aruba/blob/master/lib/aruba/cucumber.rb#L24
6
+ # original has typo in regexp, which is fixed here
7
+ Given(/^a file named "([^"]*?)" with: '(.*?)'$/) do |file_name, file_content|
8
+ file_content.gsub!('$ns',@namespace)
9
+ write_file(file_name, file_content)
10
+ end
11
+
12
+ Given(/^a file named "([^"]*?)" with namespace substitution:$/) do |file_name, file_content|
13
+ step "a file named \"#{file_name}\" with:", file_content.gsub('$ns',@namespace)
14
+ end
15
+
16
+ Then /^it prints the path to temporary file which contains: '(.*)'$/ do |content|
17
+ filename = all_output.split("\n").last
18
+ tempfiles << filename
19
+ actual_content=File.read(filename) rescue ""
20
+ expect(actual_content).to match(content)
21
+ end
@@ -0,0 +1,22 @@
1
+
2
+ Given /^a graph with edges$/ do |table|
3
+ graph table.raw
4
+ end
5
+
6
+ Then %r{^the graph JSON should be:$} do |json|
7
+ json = expand_roles json
8
+ last_graph = extract_filtered_graph json
9
+ expect(last_graph.to_json).to be_json_eql(json)
10
+ end
11
+
12
+ When(/^I( successfully)? run with role expansion "(.*)"$/) do |successfully, cmd|
13
+ role_id_map.each do |role, expanded_role|
14
+ cmd.gsub! role, expanded_role
15
+ end
16
+ self.last_cmd = cmd
17
+ if successfully
18
+ step "I successfully run `#{cmd}`"
19
+ else
20
+ step "I run `#{cmd}`"
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ Given(/^I login as a new user$/) do
2
+ @username_index ||= 0
3
+ username = %w(alice bob charles dave edward)[@username_index]
4
+ raise "I'm out of usernames!" unless username
5
+ @username_index += 1
6
+ @username = "#{username}@$ns"
7
+ step %Q(I login as new user "#{@username}")
8
+ end
9
+
10
+ Given(/^I create a new user named "(.*?)"$/) do |username|
11
+ username_ns = username.gsub('$ns',@namespace)
12
+ password = find_or_create_password(username_ns)
13
+
14
+ step "I run `conjur user create --as-role user:admin@#{@namespace} -p #{username_ns}` interactively"
15
+ step %Q(I type "#{password}")
16
+ step %Q(I type "#{password}")
17
+ step "the exit status should be 0"
18
+ end
19
+
20
+ Given(/^I create a new host with id "(.*?)"$/) do |hostid|
21
+ step "I successfully run `conjur host create #{@namespace}/monitoring/server`"
22
+ step 'I keep the JSON response at "api_key" as "API_KEY"'
23
+ step 'I keep the JSON response at "id" as "HOST_ID"'
24
+ end
25
+
26
+ Given(/^I login as a new host/) do
27
+ step "I run `conjur authn login -u host/%{HOST_ID} -p %{API_KEY}` interactively"
28
+ step "the exit status should be 0"
29
+ end
30
+
31
+ Given(/^I login as new user "(.*?)"$/) do |username|
32
+ username_ns = username.gsub('$ns',@namespace)
33
+ step %Q(I create a new user named "#{username_ns}")
34
+ step %Q(I login as "#{username_ns}")
35
+ end
36
+
37
+ Given(/^I login as "(.*?)"$/) do |username|
38
+ username_ns = username.gsub('$ns',@namespace)
39
+ password = find_or_create_password(username_ns)
40
+
41
+ Conjur::Authn.save_credentials username: username_ns, password: password
42
+ end
43
+
44
+ Then(/^I(?: can)? type and confirm a new password/) do
45
+ @password = SecureRandom.hex(12)
46
+ step %Q(I type "#{@password}")
47
+ step %Q(I type "#{@password}")
48
+ step "the exit status should be 0"
49
+ end
50
+
51
+ When(/^I enter the password/) do
52
+ raise "No current password" unless @password
53
+ step %Q(I type "#{@password}")
54
+ end
@@ -0,0 +1,5 @@
1
+ require "aruba/cucumber"
2
+ require "json_spec/cucumber"
3
+ require "conjur-asset-audit-send"
4
+
5
+ $LOAD_PATH.unshift File.expand_path('../..', File.dirname(__FILE__))