conjur-api 5.3.8.pre.8 → 5.3.8.pre.194
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +10 -0
- data/.dockerignore +1 -0
- data/.github/CODEOWNERS +10 -0
- data/.gitignore +32 -0
- data/.gitleaks.toml +219 -0
- data/.overcommit.yml +16 -0
- data/.project +18 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_settings.yml +86 -0
- data/.rubocop_todo.yml +709 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +435 -0
- data/CONTRIBUTING.md +141 -0
- data/Dockerfile +16 -0
- data/Gemfile +7 -0
- data/Jenkinsfile +168 -0
- data/LICENSE +202 -0
- data/README.md +162 -0
- data/Rakefile +47 -0
- data/SECURITY.md +42 -0
- data/VERSION +1 -1
- data/bin/parse-changelog.sh +12 -0
- data/ci/configure_v4.sh +12 -0
- data/ci/configure_v5.sh +14 -0
- data/ci/submit-coverage +36 -0
- data/conjur-api.gemspec +40 -0
- data/dev/Dockerfile.dev +12 -0
- data/dev/docker-compose.yml +56 -0
- data/dev/start +22 -0
- data/dev/stop +5 -0
- data/docker-compose.yml +76 -0
- data/example/demo_v4.rb +49 -0
- data/example/demo_v5.rb +57 -0
- data/features/authenticators.feature +33 -0
- data/features/authn_local.feature +32 -0
- data/features/exists.feature +37 -0
- data/features/group.feature +11 -0
- data/features/host.feature +50 -0
- data/features/host_factory_create_host.feature +28 -0
- data/features/host_factory_token.feature +63 -0
- data/features/load_policy.feature +61 -0
- data/features/members.feature +51 -0
- data/features/new_api.feature +36 -0
- data/features/permitted.feature +70 -0
- data/features/permitted_roles.feature +30 -0
- data/features/public_keys.feature +11 -0
- data/features/resource_fields.feature +53 -0
- data/features/role_fields.feature +15 -0
- data/features/rotate_api_key.feature +13 -0
- data/features/step_definitions/api_steps.rb +18 -0
- data/features/step_definitions/policy_steps.rb +75 -0
- data/features/step_definitions/result_steps.rb +7 -0
- data/features/support/env.rb +18 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/world.rb +12 -0
- data/features/update_password.feature +14 -0
- data/features/user.feature +58 -0
- data/features/variable_fields.feature +20 -0
- data/features/variable_value.feature +60 -0
- data/features_v4/authn_local.feature +27 -0
- data/features_v4/exists.feature +29 -0
- data/features_v4/host.feature +18 -0
- data/features_v4/host_factory_token.feature +49 -0
- data/features_v4/members.feature +39 -0
- data/features_v4/permitted.feature +15 -0
- data/features_v4/permitted_roles.feature +8 -0
- data/features_v4/resource_fields.feature +47 -0
- data/features_v4/rotate_api_key.feature +13 -0
- data/features_v4/step_definitions/api_steps.rb +17 -0
- data/features_v4/step_definitions/result_steps.rb +3 -0
- data/features_v4/support/env.rb +23 -0
- data/features_v4/support/policy.yml +34 -0
- data/features_v4/support/world.rb +12 -0
- data/features_v4/variable_fields.feature +11 -0
- data/features_v4/variable_value.feature +54 -0
- data/lib/conjur/acts_as_resource.rb +123 -0
- data/lib/conjur/acts_as_role.rb +142 -0
- data/lib/conjur/acts_as_rolsource.rb +32 -0
- data/lib/conjur/acts_as_user.rb +68 -0
- data/lib/conjur/api/authenticators.rb +35 -0
- data/lib/conjur/api/authn.rb +125 -0
- data/lib/conjur/api/host_factories.rb +71 -0
- data/lib/conjur/api/ldap_sync.rb +38 -0
- data/lib/conjur/api/policies.rb +56 -0
- data/lib/conjur/api/pubkeys.rb +53 -0
- data/lib/conjur/api/resources.rb +109 -0
- data/lib/conjur/api/roles.rb +98 -0
- data/lib/conjur/api/router/v4.rb +206 -0
- data/lib/conjur/api/router/v5.rb +248 -0
- data/lib/conjur/api/variables.rb +59 -0
- data/lib/conjur/api.rb +105 -0
- data/lib/conjur/base.rb +355 -0
- data/lib/conjur/base_object.rb +57 -0
- data/lib/conjur/build_object.rb +47 -0
- data/lib/conjur/cache.rb +26 -0
- data/lib/conjur/cert_utils.rb +63 -0
- data/lib/conjur/cidr.rb +71 -0
- data/lib/conjur/configuration.rb +460 -0
- data/lib/conjur/escape.rb +129 -0
- data/lib/conjur/exceptions.rb +4 -0
- data/lib/conjur/group.rb +41 -0
- data/lib/conjur/has_attributes.rb +98 -0
- data/lib/conjur/host.rb +27 -0
- data/lib/conjur/host_factory.rb +75 -0
- data/lib/conjur/host_factory_token.rb +78 -0
- data/lib/conjur/id.rb +71 -0
- data/lib/conjur/layer.rb +9 -0
- data/lib/conjur/log.rb +72 -0
- data/lib/conjur/log_source.rb +60 -0
- data/lib/conjur/policy.rb +34 -0
- data/lib/conjur/policy_load_result.rb +61 -0
- data/lib/conjur/query_string.rb +12 -0
- data/lib/conjur/resource.rb +29 -0
- data/lib/conjur/role.rb +29 -0
- data/lib/conjur/role_grant.rb +85 -0
- data/lib/conjur/routing.rb +29 -0
- data/lib/conjur/user.rb +40 -0
- data/lib/conjur/variable.rb +208 -0
- data/lib/conjur/webservice.rb +30 -0
- data/lib/conjur-api/version.rb +24 -0
- data/lib/conjur-api.rb +2 -0
- data/publish.sh +5 -0
- data/spec/api/host_factories_spec.rb +34 -0
- data/spec/api_spec.rb +254 -0
- data/spec/base_object_spec.rb +13 -0
- data/spec/cert_utils_spec.rb +173 -0
- data/spec/cidr_spec.rb +34 -0
- data/spec/configuration_spec.rb +330 -0
- data/spec/has_attributes_spec.rb +63 -0
- data/spec/helpers/errors_matcher.rb +34 -0
- data/spec/helpers/request_helpers.rb +10 -0
- data/spec/id_spec.rb +29 -0
- data/spec/ldap_sync_spec.rb +21 -0
- data/spec/log_source_spec.rb +13 -0
- data/spec/log_spec.rb +42 -0
- data/spec/roles_spec.rb +24 -0
- data/spec/spec_helper.rb +113 -0
- data/spec/ssl_spec.rb +109 -0
- data/spec/uri_escape_spec.rb +21 -0
- data/test.sh +73 -0
- data/tmp/.keep +0 -0
- metadata +191 -21
@@ -0,0 +1,51 @@
|
|
1
|
+
Feature: Display role members and memberships.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.load_policy 'root', <<-POLICY
|
7
|
+
- !group everyone
|
8
|
+
- !group developers
|
9
|
+
- !grant
|
10
|
+
role: !group everyone
|
11
|
+
member: !group developers
|
12
|
+
POLICY
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Show a role's members.
|
16
|
+
When I run the code:
|
17
|
+
"""
|
18
|
+
$conjur.role('cucumber:group:everyone').members.map(&:as_json)
|
19
|
+
"""
|
20
|
+
Then the JSON should be:
|
21
|
+
"""
|
22
|
+
[
|
23
|
+
{
|
24
|
+
"admin_option": false,
|
25
|
+
"member": "cucumber:group:developers",
|
26
|
+
"role": "cucumber:group:everyone"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"admin_option": true,
|
30
|
+
"member": "cucumber:user:admin",
|
31
|
+
"role": "cucumber:group:everyone"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
"""
|
35
|
+
|
36
|
+
Scenario: Show a role's memberships.
|
37
|
+
When I run the code:
|
38
|
+
"""
|
39
|
+
$conjur.role('cucumber:group:developers').memberships.map(&:as_json)
|
40
|
+
"""
|
41
|
+
Then the JSON should be:
|
42
|
+
"""
|
43
|
+
[
|
44
|
+
{
|
45
|
+
"id": "cucumber:group:developers"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"id": "cucumber:group:everyone"
|
49
|
+
}
|
50
|
+
]
|
51
|
+
"""
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Constructing a new API object.
|
2
|
+
Background:
|
3
|
+
Given a new host
|
4
|
+
|
5
|
+
Scenario: From API key.
|
6
|
+
Then I run the code:
|
7
|
+
"""
|
8
|
+
api = Conjur::API.new_from_key "host/#{@host_id}", @host_api_key
|
9
|
+
expect(api.token).to be_instance_of(Hash)
|
10
|
+
expect($conjur.resource("cucumber:host:#{@host_id}")).to exist
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: From access token.
|
14
|
+
Given I run the code:
|
15
|
+
"""
|
16
|
+
@token = Conjur::API.new_from_key("host/#{@host_id}", @host_api_key).token
|
17
|
+
"""
|
18
|
+
Then I run the code:
|
19
|
+
"""
|
20
|
+
api = Conjur::API.new_from_token @token
|
21
|
+
expect($conjur.resource("cucumber:host:#{@host_id}")).to exist
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: From access token file.
|
25
|
+
Given I run the code:
|
26
|
+
"""
|
27
|
+
token = Conjur::API.new_from_key("host/#{@host_id}", @host_api_key).token
|
28
|
+
@temp_file = Tempfile.new("token.json")
|
29
|
+
@temp_file.write(token.to_json)
|
30
|
+
@temp_file.flush
|
31
|
+
"""
|
32
|
+
Then I run the code:
|
33
|
+
"""
|
34
|
+
api = Conjur::API.new_from_token_file @temp_file.path
|
35
|
+
expect($conjur.resource("cucumber:host:#{@host_id}")).to exist
|
36
|
+
"""
|
@@ -0,0 +1,70 @@
|
|
1
|
+
Feature: Check if a role has permission on a resource.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
@host_id = "app-#{random_hex}"
|
7
|
+
@test_user = "user$#{random_hex}"
|
8
|
+
@test_host = "host?#{random_hex}"
|
9
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
10
|
+
- !variable db-password
|
11
|
+
|
12
|
+
- !layer myapp
|
13
|
+
|
14
|
+
- !host #{@host_id}
|
15
|
+
|
16
|
+
- !permit
|
17
|
+
role: !layer myapp
|
18
|
+
privilege: execute
|
19
|
+
resource: !variable db-password
|
20
|
+
|
21
|
+
- !policy
|
22
|
+
id: test
|
23
|
+
body:
|
24
|
+
- !user #{@test_user}
|
25
|
+
- !host #{@test_host}
|
26
|
+
|
27
|
+
- !permit
|
28
|
+
role: !user #{@test_user}@test
|
29
|
+
privilege: execute
|
30
|
+
resource: !variable db-password
|
31
|
+
POLICY
|
32
|
+
@host_api_key = response.created_roles["cucumber:host:#{@host_id}"]['api_key']
|
33
|
+
expect(@host_api_key).to be
|
34
|
+
"""
|
35
|
+
|
36
|
+
Scenario: Check if the current user has the privilege.
|
37
|
+
When I run the code:
|
38
|
+
"""
|
39
|
+
$conjur.resource('cucumber:variable:db-password').permitted? 'execute'
|
40
|
+
"""
|
41
|
+
Then the result should be "true"
|
42
|
+
|
43
|
+
Scenario: Check if a different user has the privilege.
|
44
|
+
When I run the code:
|
45
|
+
"""
|
46
|
+
$conjur.resource('cucumber:variable:db-password').permitted? 'execute', role: "cucumber:host:#{@host_id}"
|
47
|
+
"""
|
48
|
+
Then the result should be "false"
|
49
|
+
|
50
|
+
Scenario: Check if a different user from subpolicy has the privilege.
|
51
|
+
When I run the code:
|
52
|
+
"""
|
53
|
+
$conjur.resource('cucumber:variable:db-password').permitted? 'execute', role: "cucumber:user:#{@test_user}@test"
|
54
|
+
"""
|
55
|
+
Then the result should be "true"
|
56
|
+
|
57
|
+
Scenario: Check if a different host from subpolicy has the privilege.
|
58
|
+
When I run the code:
|
59
|
+
"""
|
60
|
+
$conjur.resource('cucumber:variable:db-password').permitted? 'execute', role: "cucumber:host:test/#{@test_host}"
|
61
|
+
"""
|
62
|
+
Then the result should be "false"
|
63
|
+
|
64
|
+
Scenario: Check if a different user has the privilege, while logged in as that user.
|
65
|
+
When I run the code:
|
66
|
+
"""
|
67
|
+
host_api = Conjur::API.new_from_key "host/#{@host_id}", @host_api_key
|
68
|
+
host_api.resource('cucumber:variable:db-password').permitted? 'execute'
|
69
|
+
"""
|
70
|
+
Then the result should be "false"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Enumerate roles which have a permission on a resource.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.load_policy 'root', <<-POLICY
|
7
|
+
- !variable db-password
|
8
|
+
|
9
|
+
- !layer myapp
|
10
|
+
|
11
|
+
- !permit
|
12
|
+
role: !layer myapp
|
13
|
+
privilege: execute
|
14
|
+
resource: !variable db-password
|
15
|
+
POLICY
|
16
|
+
"""
|
17
|
+
|
18
|
+
@wip
|
19
|
+
Scenario: Permitted roles can be enumerated.
|
20
|
+
When I run the code:
|
21
|
+
"""
|
22
|
+
$conjur.resource('cucumber:variable:db-password').permitted_roles 'execute'
|
23
|
+
"""
|
24
|
+
Then the JSON should be:
|
25
|
+
"""
|
26
|
+
[
|
27
|
+
"cucumber:layer:myapp",
|
28
|
+
"cucumber:user:admin"
|
29
|
+
]
|
30
|
+
"""
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Feature: Display basic resource fields.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.load_policy 'root', <<-POLICY
|
7
|
+
- !group
|
8
|
+
id: developers
|
9
|
+
annotations:
|
10
|
+
gidnumber: 2000
|
11
|
+
POLICY
|
12
|
+
"""
|
13
|
+
|
14
|
+
Scenario: Resource exposes id, kind, identifier, and attributes.
|
15
|
+
When I run the code:
|
16
|
+
"""
|
17
|
+
resource = $conjur.resource('cucumber:group:developers')
|
18
|
+
[ resource.id, resource.account, resource.kind, resource.identifier, resource.attributes ]
|
19
|
+
"""
|
20
|
+
Then the JSON should be:
|
21
|
+
"""
|
22
|
+
[
|
23
|
+
"cucumber:group:developers",
|
24
|
+
"cucumber",
|
25
|
+
"group",
|
26
|
+
"developers",
|
27
|
+
{
|
28
|
+
"annotations": [
|
29
|
+
{
|
30
|
+
"name": "gidnumber",
|
31
|
+
"policy": "cucumber:policy:root",
|
32
|
+
"value": "2000"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"owner": "cucumber:user:admin",
|
36
|
+
"permissions": [
|
37
|
+
],
|
38
|
+
"policy": "cucumber:policy:root"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
"""
|
42
|
+
|
43
|
+
Scenario: Resource#owner is the owner object
|
44
|
+
When I run the code:
|
45
|
+
"""
|
46
|
+
$conjur.resource('cucumber:group:developers').owner.id
|
47
|
+
"""
|
48
|
+
Then the result should be "cucumber:user:admin"
|
49
|
+
And I run the code:
|
50
|
+
"""
|
51
|
+
$conjur.resource('cucumber:group:developers').class
|
52
|
+
"""
|
53
|
+
Then the result should be "Conjur::Group"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Display basic role fields.
|
2
|
+
|
3
|
+
Scenario: Login of a user is the login name.
|
4
|
+
When I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.role('cucumber:user:alice').login
|
7
|
+
"""
|
8
|
+
Then the result should be "alice"
|
9
|
+
|
10
|
+
Scenario: Login of a non-user is prefixed with the role kind.
|
11
|
+
When I run the code:
|
12
|
+
"""
|
13
|
+
$conjur.role('cucumber:host:myapp').login
|
14
|
+
"""
|
15
|
+
Then the result should be "host/myapp"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Rotate the API key.
|
2
|
+
|
3
|
+
Scenario: Logged-in user can rotate the API key.
|
4
|
+
When I run the code:
|
5
|
+
"""
|
6
|
+
Conjur::API.rotate_api_key 'admin', $api_key
|
7
|
+
"""
|
8
|
+
Then I can run the code:
|
9
|
+
"""
|
10
|
+
$api_key = @result.strip
|
11
|
+
$conjur = Conjur::API.new_from_key $username, @result
|
12
|
+
$conjur.token
|
13
|
+
"""
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Then(/^I(?: can)? run the code:$/) do |code|
|
2
|
+
@result = eval(code).tap do |result|
|
3
|
+
puts result if ENV['DEBUG']
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
Then(/^this code should fail with "([^"]*)"$/) do |error_msg, code|
|
8
|
+
begin
|
9
|
+
@result = eval(code)
|
10
|
+
rescue Exception => exc
|
11
|
+
if not exc.message =~ %r{#{error_msg}}
|
12
|
+
fail "'#{error_msg}' was not found in '#{exc.message}'"
|
13
|
+
end
|
14
|
+
else
|
15
|
+
puts @result if ENV['DEBUG']
|
16
|
+
fail "The provided block did not raise an error"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
Given(/^a new user$/) do
|
2
|
+
@user_id = "user-#{random_hex}"
|
3
|
+
@public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDd/PAcCL9rW/zAS7DRns/KYiAvRAEKxBu/0IF32z7x6YiMFcA2hmH4DMYaIY45Xlj7L9uTZamUlRZNjSS9Xm6Lhh7XGceIX2067/MDnH+or9xh5LZs6gb3x7QVtNz26Au5h5kP0xoJ+wpVxvY707BeSax/WQZI8akqd0fD1IqOoafWkcX0ucu5iIgDh08R7zq3vrDHEK7+SoYo9ncHfmOUJ5lmImGiU/WMqM0OzN3RsgxJi/aaHjW1IASTY8TmAtTtjEsxbQXxRVUCAP9vWUZg7p3aqIB6sEP8skgncCUtHBQxUtE1XN8Q8NeFOzau6+9sQTXlPl8c/L4Jc4K96C75 #{@user_id}@example.com"
|
4
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
5
|
+
- !user
|
6
|
+
id: #{@user_id}
|
7
|
+
uidnumber: 1000
|
8
|
+
public_keys:
|
9
|
+
- #{@public_key}
|
10
|
+
POLICY
|
11
|
+
@user = $conjur.resource("cucumber:user:#{@user_id}")
|
12
|
+
@user_api_key = response.created_roles["cucumber:user:#{@user_id}"]['api_key']
|
13
|
+
expect(@user_api_key).to be
|
14
|
+
end
|
15
|
+
|
16
|
+
Given(/^a new delegated user$/) do
|
17
|
+
# Create a new host that is owned by that user
|
18
|
+
step 'a new user'
|
19
|
+
@user_owner = @user
|
20
|
+
@user_owner_id = @user_id
|
21
|
+
@user_owner_api_key = @user_api_key
|
22
|
+
|
23
|
+
# Create a new user that is owned by the user created earlier
|
24
|
+
@user_id = "user-#{random_hex}"
|
25
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
26
|
+
- !user
|
27
|
+
id: #{@user_id}
|
28
|
+
owner: !user #{@user_owner_id}
|
29
|
+
POLICY
|
30
|
+
@user = $conjur.resource("cucumber:user:#{@user_id}")
|
31
|
+
@user_api_key = response.created_roles["cucumber:user:#{@user_id}"]['api_key']
|
32
|
+
expect(@user_api_key).to be
|
33
|
+
end
|
34
|
+
|
35
|
+
Given(/^a new group$/) do
|
36
|
+
@group_id = "group-#{random_hex}"
|
37
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
38
|
+
- !group
|
39
|
+
id: #{@group_id}
|
40
|
+
gidnumber: 1000
|
41
|
+
POLICY
|
42
|
+
@group = $conjur.resource("cucumber:group:#{@group_id}")
|
43
|
+
end
|
44
|
+
|
45
|
+
Given(/^a new host$/) do
|
46
|
+
@host_id = "app-#{random_hex}"
|
47
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
48
|
+
- !host #{@host_id}
|
49
|
+
POLICY
|
50
|
+
@host_api_key = response.created_roles["cucumber:host:#{@host_id}"]['api_key']
|
51
|
+
expect(@host_api_key).to be
|
52
|
+
@host = $conjur.resource("cucumber:host:#{@host_id}")
|
53
|
+
@host.attributes['api_key'] = @host_api_key
|
54
|
+
end
|
55
|
+
|
56
|
+
Given(/^a new delegated host$/) do
|
57
|
+
# Create an owner user
|
58
|
+
step 'a new user'
|
59
|
+
@host_owner = @user
|
60
|
+
@host_owner_id = @user_id
|
61
|
+
@host_owner_api_key = @user_api_key
|
62
|
+
|
63
|
+
# Create a new host that is owned by that user
|
64
|
+
@host_id = "app-#{random_hex}"
|
65
|
+
response = $conjur.load_policy 'root', <<-POLICY
|
66
|
+
- !host
|
67
|
+
id: #{@host_id}
|
68
|
+
owner: !user #{@host_owner_id}
|
69
|
+
POLICY
|
70
|
+
|
71
|
+
@host_api_key = response.created_roles["cucumber:host:#{@host_id}"]['api_key']
|
72
|
+
expect(@host_api_key).to be
|
73
|
+
@host = $conjur.resource("cucumber:host:#{@host_id}")
|
74
|
+
@host.attributes['api_key'] = @host_api_key
|
75
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
command_name "#{ENV['RUBY_VERSION']}"
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'json_spec/cucumber'
|
8
|
+
require 'conjur/api'
|
9
|
+
|
10
|
+
Conjur.configuration.appliance_url = ENV['CONJUR_APPLIANCE_URL'] || 'http://localhost/api/v6'
|
11
|
+
Conjur.configuration.account = ENV['CONJUR_ACCOUNT'] || 'cucumber'
|
12
|
+
Conjur.configuration.authn_local_socket = "/run/authn-local-5/.socket"
|
13
|
+
|
14
|
+
$username = ENV['CONJUR_AUTHN_LOGIN'] || 'admin'
|
15
|
+
$password = ENV['CONJUR_AUTHN_API_KEY'] || 'secret'
|
16
|
+
|
17
|
+
$api_key = Conjur::API.login $username, $password
|
18
|
+
$conjur = Conjur::API.new_from_key $username, $api_key
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Change a user's password.
|
2
|
+
Background:
|
3
|
+
Given a new user
|
4
|
+
|
5
|
+
Scenario: A user can set/change her password using the current API key.
|
6
|
+
When I run the code:
|
7
|
+
"""
|
8
|
+
Conjur::API.update_password @user_id, @user_api_key, 'SEcret12!!!!'
|
9
|
+
@new_api_key = Conjur::API.login @user_id, 'SEcret12!!!!'
|
10
|
+
"""
|
11
|
+
Then I can run the code:
|
12
|
+
"""
|
13
|
+
Conjur::API.new_from_key(@user_id, @new_api_key).token
|
14
|
+
"""
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Feature: User object
|
2
|
+
|
3
|
+
Background:
|
4
|
+
|
5
|
+
Scenario: User has a uidnumber
|
6
|
+
Given a new user
|
7
|
+
Then I can run the code:
|
8
|
+
"""
|
9
|
+
@user.uidnumber
|
10
|
+
"""
|
11
|
+
Then the result should be "1000"
|
12
|
+
|
13
|
+
Scenario: Logged-in user is the current_role
|
14
|
+
Given a new user
|
15
|
+
Then I can run the code:
|
16
|
+
"""
|
17
|
+
expect($conjur.current_role(Conjur.configuration.account).id.to_s).to eq("cucumber:user:admin")
|
18
|
+
"""
|
19
|
+
|
20
|
+
# Rotation of own API key should be done via `Conjur::API.rotate_api_key()`
|
21
|
+
Scenario: User's own API key cannot be rotated with an API key
|
22
|
+
Given a new user
|
23
|
+
Then this code should fail with "You cannot rotate your own API key via this method"
|
24
|
+
"""
|
25
|
+
user = Conjur::API.new_from_key(@user.login, @user_api_key).resource(@user.id)
|
26
|
+
user.rotate_api_key
|
27
|
+
"""
|
28
|
+
|
29
|
+
# Rotation of own API key should be done via `Conjur::API.rotate_api_key()`
|
30
|
+
Scenario: User's own API key cannot be rotated with a token
|
31
|
+
Given a new user
|
32
|
+
Then this code should fail with "You cannot rotate your own API key via this method"
|
33
|
+
"""
|
34
|
+
token = Conjur::API.new_from_key(@user.login, @user_api_key).token
|
35
|
+
|
36
|
+
user = Conjur::API.new_from_token(token).resource(@user.id)
|
37
|
+
user.rotate_api_key
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario: Delegated user's API key can be rotated with an API key
|
41
|
+
Given a new delegated user
|
42
|
+
Then I can run the code:
|
43
|
+
"""
|
44
|
+
delegated_user_resource = Conjur::API.new_from_key(@user_owner.login, @user_owner_api_key).resource(@user.id)
|
45
|
+
api_key = delegated_user_resource.rotate_api_key
|
46
|
+
Conjur::API.new_from_key(delegated_user_resource.login, api_key).token
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: Delegated user's API key can be rotated with a token
|
50
|
+
Given a new delegated user
|
51
|
+
Then I can run the code:
|
52
|
+
"""
|
53
|
+
token = Conjur::API.new_from_key(@user_owner.login, @user_owner_api_key).token
|
54
|
+
|
55
|
+
delegated_user_resource = Conjur::API.new_from_token(token).resource(@user.id)
|
56
|
+
api_key = delegated_user_resource.rotate_api_key
|
57
|
+
Conjur::API.new_from_key(delegated_user_resource.login, api_key).token
|
58
|
+
"""
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: Display Variable fields.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.load_policy 'root', <<-POLICY
|
7
|
+
- !variable
|
8
|
+
id: ssl-certificate
|
9
|
+
kind: SSL certificate
|
10
|
+
mime_type: application/x-pem-file
|
11
|
+
POLICY
|
12
|
+
"""
|
13
|
+
And I run the code:
|
14
|
+
"""
|
15
|
+
$conjur.resource('cucumber:variable:ssl-certificate')
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: Display MIME type and kind
|
19
|
+
Then the JSON at "mime_type" should be "application/x-pem-file"
|
20
|
+
And the JSON at "kind" should be "SSL certificate"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: Work with Variable values.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I run the code:
|
5
|
+
"""
|
6
|
+
@variable_id = "password"
|
7
|
+
$conjur.load_policy 'root', <<-POLICY
|
8
|
+
- !variable #{@variable_id}
|
9
|
+
- !variable #{@variable_id}-2
|
10
|
+
POLICY
|
11
|
+
@variable = $conjur.resource("cucumber:variable:#{@variable_id}")
|
12
|
+
@variable_2 = $conjur.resource("cucumber:variable:#{@variable_id}-2")
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Add a value, retrieve the variable metadata and the value.
|
16
|
+
When I run the code:
|
17
|
+
"""
|
18
|
+
@initial_count = @variable.version_count
|
19
|
+
@variable.add_value 'value-0'
|
20
|
+
"""
|
21
|
+
And I run the code:
|
22
|
+
"""
|
23
|
+
expect(@variable.version_count).to eq(@initial_count + 1)
|
24
|
+
"""
|
25
|
+
And I run the code:
|
26
|
+
"""
|
27
|
+
@variable.value(@variable.version_count)
|
28
|
+
"""
|
29
|
+
Then the result should be "value-0"
|
30
|
+
|
31
|
+
Scenario: Retrieve a historical value.
|
32
|
+
Given I run the code:
|
33
|
+
"""
|
34
|
+
@variable.add_value 'value-0'
|
35
|
+
@variable.add_value 'value-1'
|
36
|
+
@variable.add_value 'value-2'
|
37
|
+
"""
|
38
|
+
When I run the code:
|
39
|
+
"""
|
40
|
+
@variable.value(@variable.version_count - 2)
|
41
|
+
"""
|
42
|
+
Then the result should be "value-0"
|
43
|
+
|
44
|
+
Scenario: Retrieve multiple values in a batch
|
45
|
+
Given I run the code:
|
46
|
+
"""
|
47
|
+
@variable.add_value 'value-0'
|
48
|
+
@variable_2.add_value 'value-2'
|
49
|
+
"""
|
50
|
+
When I run the code:
|
51
|
+
"""
|
52
|
+
$conjur.variable_values([ @variable, @variable_2 ].map(&:id))
|
53
|
+
"""
|
54
|
+
Then the JSON should be:
|
55
|
+
"""
|
56
|
+
{
|
57
|
+
"cucumber:variable:password": "value-0",
|
58
|
+
"cucumber:variable:password-2": "value-2"
|
59
|
+
}
|
60
|
+
"""
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: When co-located with the Conjur server, the API can use the authn-local service to authenticate.
|
2
|
+
|
3
|
+
Scenario: authn-local can be used to obtain an access token.
|
4
|
+
When I run the code:
|
5
|
+
"""
|
6
|
+
Conjur::API.authenticate_local "alice"
|
7
|
+
"""
|
8
|
+
Then the JSON should have "data"
|
9
|
+
|
10
|
+
Scenario: Conjur API supports construction from authn-local.
|
11
|
+
When I run the code:
|
12
|
+
"""
|
13
|
+
@api = Conjur::API.new_from_authn_local "alice"
|
14
|
+
@api.token
|
15
|
+
"""
|
16
|
+
Then the JSON should have "data"
|
17
|
+
|
18
|
+
Scenario: Conjur API will automatically refresh the token.
|
19
|
+
When I run the code:
|
20
|
+
"""
|
21
|
+
@api = Conjur::API.new_from_authn_local "alice"
|
22
|
+
@api.token
|
23
|
+
@api.force_token_refresh
|
24
|
+
@api.token
|
25
|
+
"""
|
26
|
+
Then the JSON should have "data"
|
27
|
+
And the JSON at "data" should be "alice"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: Check if an object exists.
|
2
|
+
|
3
|
+
Scenario: A created group resource exists
|
4
|
+
When I run the code:
|
5
|
+
"""
|
6
|
+
$conjur.resource('cucumber:group:developers').exists?
|
7
|
+
"""
|
8
|
+
Then the result should be "true"
|
9
|
+
|
10
|
+
Scenario: An un-created resource doesn't exist
|
11
|
+
When I run the code:
|
12
|
+
"""
|
13
|
+
$conjur.resource('cucumber:food:bacon').exists?
|
14
|
+
"""
|
15
|
+
Then the result should be "false"
|
16
|
+
|
17
|
+
Scenario: A created group role exists
|
18
|
+
When I run the code:
|
19
|
+
"""
|
20
|
+
$conjur.role('cucumber:group:developers').exists?
|
21
|
+
"""
|
22
|
+
Then the result should be "true"
|
23
|
+
|
24
|
+
Scenario: An un-created role doesn't exist
|
25
|
+
When I run the code:
|
26
|
+
"""
|
27
|
+
$conjur.role('cucumber:food:bacon').exists?
|
28
|
+
"""
|
29
|
+
Then the result should be "false"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Display Host object fields.
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a new host
|
5
|
+
|
6
|
+
Scenario: API key of a newly created host is available and valid.
|
7
|
+
Then I run the code:
|
8
|
+
"""
|
9
|
+
expect(@host.exists?).to be(true)
|
10
|
+
expect(@host.api_key).to be
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: API key of a a host can be rotated.
|
14
|
+
Then I run the code:
|
15
|
+
"""
|
16
|
+
api_key = @host.rotate_api_key
|
17
|
+
Conjur::API.new_from_key("host/#{@host.id.identifier}", api_key).token
|
18
|
+
"""
|