conjur-api 5.3.2 → 5.3.6

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
  SHA256:
3
- metadata.gz: 184486b0770526d9426247e1d6add16572cc73791a160bc828265ea39f01e288
4
- data.tar.gz: 35f3aae54507b549c5c43e7b66034eff28ab4ed331574c4f80301c32c6c42070
3
+ metadata.gz: 7ff5a377ccb9f8a1e9bf489c3c4e8a403adf795ce73f2eb88d204ff9963f9e15
4
+ data.tar.gz: ce065cc5820c6deaabd504f8cc3893da57ed0043ef621327134e53df4ce689b9
5
5
  SHA512:
6
- metadata.gz: b289c3c2e41af4e7847d08b0a7229df9d9a96a2ef1c981ad6ac69bc1db588f99e4f63467152678d34f55c37eeb2ae30daf7ed55f39eb8e3ec9630b1749af6509
7
- data.tar.gz: 0a3aba01a8046572a9a1dfea88a71c250727731e2df836f2a262c70a08514dde2b8281c544feb55243fd081f9da0dabf13ecaa7a99bf5d7adf86c0ed1fc7d370
6
+ metadata.gz: 888764fb96ae3122eb82a9ed9d652548a46c33109d5c85ab09ece0ce0cd65982f429376b559ebdd47d77c76ed911d2de0cec36b92bf6eeff1e92051d7ce36892
7
+ data.tar.gz: 4ecd8d2df762195c14167e513e4379a985076f8dec2fc7f62d09d013ad472c24a3e44c068c733859a2b9051a852be709521251ce46d049fd54b56db7b2a9d8ed
@@ -0,0 +1,10 @@
1
+ * @cyberark/community-and-integrations-team @conjurinc/community-and-integrations-team @conjurdemos/community-and-integrations-team
2
+
3
+ # Changes to .trivyignore require Security Architect approval
4
+ .trivyignore @cyberark/security-architects @conjurinc/security-architects @conjurdemos/security-architects
5
+
6
+ # Changes to .codeclimate.yml require Quality Architect approval
7
+ .codeclimate.yml @cyberark/quality-architects @conjurinc/quality-architects @conjurdemos/quality-architects
8
+
9
+ # Changes to SECURITY.md require Security Architect approval
10
+ SECURITY.md @cyberark/security-architects @conjurinc/security-architects @conjurdemos/security-architects
data/.gitleaks.toml CHANGED
@@ -1,4 +1,4 @@
1
- title = "Secretless Broker gitleaks config"
1
+ title = "Conjur API Ruby gitleaks config"
2
2
 
3
3
  # This is the config file for gitleaks. You can configure gitleaks what to search for and what to whitelist.
4
4
  # If GITLEAKS_CONFIG environment variable
data/CHANGELOG.md CHANGED
@@ -6,6 +6,42 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [5.3.6] - 2021-12-09
10
+ ### Changed
11
+ - Support ruby-3.0.2.
12
+ [cyberark/conjur-api-ruby#197](https://github.com/cyberark/conjur-api-ruby/pull/197)
13
+
14
+ ## [5.3.5] - 2021-05-04
15
+
16
+ ### Added
17
+ - Add `rest_client_options` option to `Conjur.configuration`. This allows users to
18
+ configure the RestClient instance used by Conjur API to communicate with the Conjur
19
+ server.
20
+ [cyberark/conjur-api-ruby#188](https://github.com/cyberark/conjur-api-ruby/issues/188)
21
+
22
+ ### Changed
23
+ - Replace monkey patching `RestClient::Request` with defaults on `Conjur.configuration.rest_client_options`
24
+ in order to limit the scope of the default `:ssl_cert_store` option only to inside
25
+ Conjur API.
26
+ [cyberark/conjur-api-ruby#188](https://github.com/cyberark/conjur-api-ruby/issues/188)
27
+
28
+ ## [5.3.4] - 2020-10-29
29
+
30
+ ### Changed
31
+ - When rotating the currently logged in user's/host's API key, we now explictily
32
+ prevent use of `resource({own_id}).rotate_api_key` for that action as the
33
+ `Conjur::API.rotate_api_key` should be used instead for that. This change is a
34
+ downstream enforcement of the stricter key rotation requirements on the server
35
+ covered by [this](https://github.com/cyberark/conjur/security/advisories/GHSA-qhjf-g9gm-64jq)
36
+ security bulletin.
37
+ [cyberark/conjur-api-ruby#181](https://github.com/cyberark/conjur-api-ruby/issues/181)
38
+
39
+ ## [5.3.3] - 2020-08-18
40
+ ### Changed
41
+ - Release process is updated to ensure that the published Ruby Gem matches a tag in this repository,
42
+ so that consumers of this gem can always reference the correct source code included in any given version.
43
+ [cyberark/conjur-api-ruby#173](https://github.com/cyberark/conjur-api-ruby/issues/173)
44
+
9
45
  ## 5.3.2 - 2018-09-24
10
46
  ### Added
11
47
  - Add `Conjur::API.authenticator_list`, `Conjur::API.authenticator_enable`, and
@@ -315,7 +351,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
315
351
 
316
352
  ## [2.0.0] - 2013-13-12
317
353
 
318
- [Unreleased]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.1...HEAD
354
+ [Unreleased]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.6...HEAD
355
+ [5.3.6]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.5...v5.3.6
356
+ [5.3.5]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.4...v5.3.5
357
+ [5.3.4]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.3...v5.3.4
358
+ [5.3.3]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.1...v5.3.3
319
359
  [5.3.1]: https://github.com/cyberark/conjur-api-ruby/compare/v5.3.0...v5.3.1
320
360
  [5.3.0]: https://github.com/cyberark/conjur-api-ruby/compare/v5.1.0...v5.3.0
321
361
  [5.1.0]: https://github.com/cyberark/conjur-api-ruby/compare/v5.0.0...v5.1.0
data/CONTRIBUTING.md CHANGED
@@ -120,30 +120,22 @@ $ docker-compose down
120
120
 
121
121
  ## Releasing
122
122
 
123
- Releasing a new version of this Gem involves a two step process:
124
- 1. Tag and Release (using `bin/release`)
125
- 2. Approving the push to RubyGems in Jenkins
123
+ ### Update the version and changelog
126
124
 
127
- ### Step 1: Tag and Release
125
+ 1. Create a new branch for the version bump.
126
+ 1. Based on the unreleased content, determine the new version number and update
127
+ the [version.rb](lib/conjur-api/version.rb) file.
128
+ 1. Commit these changes - `Bump version to x.y.z` is an acceptable commit message - and open a PR
129
+ for review. Your PR should include updates to `lib/conjur-api/version.rb`, and
130
+ `CHANGELOG.md`.
128
131
 
129
- First, update the following files:
132
+ ### Add a git tag
130
133
 
131
- - The version file (`lib/conjur-api/version.rb`) has been updated with an appropriate Semantic version number.
132
- - The `CHANGELOG.md` file has been updated to reflect the release version and appropriate release notes.
134
+ 1. Once your changes have been **reviewed and merged into main**, tag the version
135
+ using `git tag -a "vx.y.z" -m "vx.y.z release"`. Note this requires you to be able to sign releases.
136
+ Consult the [github documentation on signing commits](https://help.github.com/articles/signing-commits-with-gpg/)
137
+ on how to set this up. `vx.y.z release` is an acceptable tag message.
138
+ 1. Push the tag: `git push vx.y.z` (or `git push origin vx.y.z` if you are working
139
+ from your local machine).
133
140
 
134
- Next, save -- but do not commit -- the changes above.
135
-
136
- Finally, when you're ready to release, run the following:
137
-
138
- ```sh
139
- $ bin/release
140
- ```
141
-
142
- ### Step 2: Approve the push to RubyGems in Jenkins
143
-
144
- - Navigate to Jenkins: https://jenkins.conjur.net/job/cyberark--conjur-api-ruby/job/master/.
145
- - Once the pipeline reaches the `Publish to RubyGems?` stage, click the blue box, and then click `Logs`.
146
- - Open the confirmation step (`Wait for interactive input -- Publish to RubyGems?`), and click `Proceed`. Nothing appears to happen, but the "Publish" stage will be run.
147
- - Finally, verify that the new library is present in RubyGems: https://rubygems.org/gems/conjur-api
148
-
149
- The release is now complete.
141
+ After pushing the tag, a matching version will be published to [RubyGems](https://rubygems.org/gems/conjur-api/versions)!
data/Dockerfile CHANGED
@@ -1,4 +1,5 @@
1
- FROM ruby:2.3
1
+ ARG RUBY_VERSION
2
+ FROM ruby:$RUBY_VERSION
2
3
 
3
4
  RUN apt-get update && apt-get install -y vim curl
4
5
 
data/Gemfile CHANGED
@@ -1,11 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- #ruby=ruby-2.3
3
+ #ruby=ruby-3.0
4
4
  #ruby-gemset=conjur-api
5
5
 
6
6
  # Specify your gem's dependencies in conjur-api.gemspec
7
7
  gemspec
8
-
9
- group :test do
10
- gem 'simplecov-cobertura', require: false
11
- end
data/Jenkinsfile CHANGED
@@ -13,20 +13,41 @@ pipeline {
13
13
  }
14
14
 
15
15
  stages {
16
- stage('Validate') {
17
- parallel {
18
- stage('Changelog') {
19
- steps { sh './bin/parse-changelog.sh' }
16
+ stage('Validate Changelog') {
17
+ steps { sh './bin/parse-changelog.sh' }
18
+ }
19
+
20
+ stage('Prepare CC Report Dir'){
21
+ steps {
22
+ script {
23
+ ccCoverage.dockerPrep()
24
+ sh 'mkdir -p coverage'
20
25
  }
21
26
  }
22
27
  }
23
28
 
24
- stage('Test') {
29
+ stage('Test Ruby 2.5') {
30
+ environment {
31
+ RUBY_VERSION = '2.5'
32
+ }
25
33
  steps {
26
- script {
27
- ccCoverage.setGitEnvVars();
34
+ sh './test.sh'
35
+ }
36
+
37
+ post {
38
+ always {
39
+ junit 'spec/reports/*.xml'
40
+ junit 'features/reports/*.xml'
41
+ junit 'features_v4/reports/*.xml'
28
42
  }
29
- milestone(1)
43
+ }
44
+ }
45
+
46
+ stage('Test Ruby 2.6') {
47
+ environment {
48
+ RUBY_VERSION = '2.6'
49
+ }
50
+ steps {
30
51
  sh './test.sh'
31
52
  }
32
53
 
@@ -35,39 +56,62 @@ pipeline {
35
56
  junit 'spec/reports/*.xml'
36
57
  junit 'features/reports/*.xml'
37
58
  junit 'features_v4/reports/*.xml'
38
- cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'coverage/coverage.xml', conditionalCoverageTargets: '100, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '99, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '100, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
39
59
  }
40
60
  }
41
61
  }
42
62
 
43
- // Only publish to RubyGems if branch is 'master'
44
- // AND someone confirms this stage within 5 minutes
45
- stage('Publish to RubyGems?') {
46
- agent { label 'releaser-v2' }
47
-
48
- when {
49
- allOf {
50
- branch 'master'
51
- expression {
52
- boolean publish = false
53
-
54
- if (env.PUBLISH_GEM == "true") {
55
- return true
56
- }
57
-
58
- try {
59
- timeout(time: 5, unit: 'MINUTES') {
60
- input(message: 'Publish to RubyGems?')
61
- publish = true
62
- }
63
- } catch (final ignore) {
64
- publish = false
65
- }
66
-
67
- return publish
68
- }
63
+ stage('Test Ruby 2.7') {
64
+ environment {
65
+ RUBY_VERSION = '2.7'
66
+ }
67
+ steps {
68
+ sh './test.sh'
69
+ }
70
+
71
+ post {
72
+ always {
73
+ junit 'spec/reports/*.xml'
74
+ junit 'features/reports/*.xml'
75
+ junit 'features_v4/reports/*.xml'
69
76
  }
70
77
  }
78
+ }
79
+
80
+ stage('Test Ruby 3.0') {
81
+ environment {
82
+ RUBY_VERSION = '3.0'
83
+ }
84
+ steps {
85
+ sh("./test.sh")
86
+ }
87
+ post {
88
+ always {
89
+ junit 'spec/reports/*.xml'
90
+ junit 'features/reports/*.xml'
91
+ junit 'features_v4/reports/*.xml'
92
+ }
93
+ }
94
+ }
95
+
96
+ stage('Submit Coverage Report'){
97
+ steps{
98
+ sh 'ci/submit-coverage'
99
+ publishHTML([reportDir: 'coverage', reportFiles: 'index.html', reportName: 'Coverage Report', reportTitles: '',
100
+ allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true])
101
+ }
102
+
103
+ post {
104
+ always {
105
+ archiveArtifacts artifacts: "coverage/.resultset.json", fingerprint: false
106
+ }
107
+ }
108
+ }
109
+
110
+ // Only publish to RubyGems if the tag begins with 'v' ex) v5.3.2
111
+ stage('Publish to RubyGems?') {
112
+ agent { label 'executor-v2' }
113
+
114
+ when { tag "v*" }
71
115
  steps {
72
116
  // Clean up first
73
117
  sh 'docker run -i --rm -v $PWD:/src -w /src alpine/git clean -fxd'
data/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright (c) 2020 CyberArk Software Ltd. All rights reserved.
190
+ Copyright (c) 2021 CyberArk Software Ltd. All rights reserved.
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -11,7 +11,7 @@ The Conjur server comes in two major versions:
11
11
  * **4.x** Conjur 4 is a commercial, non-open-source product, which is documented at [https://developer.conjur.net/](https://developer.conjur.net/).
12
12
  * **5.x** Conjur 5 is open-source software, hosted and documented at [https://www.conjur.org/](https://www.conjur.org/).
13
13
 
14
- You can use the `master` branch of this project, which is `conjur-api` version `5.x`, to do all of the following things against either type of Conjur server:
14
+ You can use the `main` branch of this project, which is `conjur-api` version `5.x`, to do all of the following things against either type of Conjur server:
15
15
 
16
16
  * Authenticate
17
17
  * Fetch secrets
@@ -24,6 +24,17 @@ Use the configuration setting `Conjur.configuration.version` to select your serv
24
24
 
25
25
  If you are using Conjur server version `4.x`, you can also choose to use the `conjur-api` version `4.x`. In this case, the `Configuration.version` setting is not required (actually, it doesn't exist).
26
26
 
27
+ ## Using conjur-api-ruby with Conjur Open Source
28
+
29
+ Are you using this project with [Conjur Open Source](https://github.com/cyberark/conjur)? Then we
30
+ **strongly** recommend choosing the version of this project to use from the latest [Conjur OSS
31
+ suite release](https://docs.conjur.org/Latest/en/Content/Overview/Conjur-OSS-Suite-Overview.html).
32
+ Conjur maintainers perform additional testing on the suite release versions to ensure
33
+ compatibility. When possible, upgrade your Conjur version to match the
34
+ [latest suite release](https://docs.conjur.org/Latest/en/Content/ReleaseNotes/ConjurOSS-suite-RN.htm);
35
+ when using integrations, choose the latest suite release that matches your Conjur version. For any
36
+ questions, please contact us on [Discourse](https://discuss.cyberarkcommons.org/c/conjur/5).
37
+
27
38
  # Installation
28
39
 
29
40
  Add this line to your application's Gemfile:
@@ -117,12 +128,34 @@ Conjur::API.new_from_key login, api_key
117
128
  Note that if you are connecting as a [Host](http://developer.conjur.net/reference/services/directory/host), the login should be
118
129
  prefixed with `host/`. For example: `host/myhost.example.com`, not just `myhost.example.com`.
119
130
 
131
+ ## Configuring RestClient
132
+
133
+ [Conjur::Configuration](https://github.com/conjurinc/api-ruby/blob/master/lib/conjur/configuration.rb)
134
+ allows optional configuration of the [RestClient](https://github.com/rest-client/rest-client)
135
+ instance used by Conjur API to communicate with the Conjur server, via the options hash
136
+ `Conjur.configuration.rest_client_options`.
137
+
138
+ The default value for the options hash is:
139
+ ```ruby
140
+ {
141
+ ssl_cert_store: OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE
142
+ }
143
+ ```
144
+
145
+ For example, here's how you would configure the client to use a proxy and `ssl_ca_file` (instead of the default `ssl_cert_store`).
146
+ ```ruby
147
+ Conjur.configuration.rest_client_options = {
148
+ ssl_ca_file: "ca_certificate.pem",
149
+ proxy: "http://proxy.example.com/"
150
+ }
151
+ ```
152
+
120
153
  ## Contributing
121
154
 
122
155
  We welcome contributions of all kinds to this repository. For instructions on how to get started and descriptions of our development workflows, please see our [contributing
123
156
  guide][contrib].
124
157
 
125
- [contrib]: https://github.com/cyberark/conjur-api-ruby/blob/master/CONTRIBUTING.md
158
+ [contrib]: https://github.com/cyberark/conjur-api-ruby/blob/main/CONTRIBUTING.md
126
159
 
127
160
  ## License
128
161
 
data/SECURITY.md ADDED
@@ -0,0 +1,42 @@
1
+ # Security Policies and Procedures
2
+
3
+ This document outlines security procedures and general policies for the CyberArk Conjur
4
+ suite of tools and products.
5
+
6
+ * [Reporting a Bug](#reporting-a-bug)
7
+ * [Disclosure Policy](#disclosure-policy)
8
+ * [Comments on this Policy](#comments-on-this-policy)
9
+
10
+ ## Reporting a Bug
11
+
12
+ The CyberArk Conjur team and community take all security bugs in the Conjur suite seriously.
13
+ Thank you for improving the security of the Conjur suite. We appreciate your efforts and
14
+ responsible disclosure and will make every effort to acknowledge your
15
+ contributions.
16
+
17
+ Report security bugs by emailing the lead maintainers at security@conjur.org.
18
+
19
+ The maintainers will acknowledge your email within 2 business days. Subsequently, we will
20
+ send a more detailed response within 2 business days of our acknowledgement indicating
21
+ the next steps in handling your report. After the initial reply to your report, the security
22
+ team will endeavor to keep you informed of the progress towards a fix and full
23
+ announcement, and may ask for additional information or guidance.
24
+
25
+ Report security bugs in third-party modules to the person or team maintaining
26
+ the module.
27
+
28
+ ## Disclosure Policy
29
+
30
+ When the security team receives a security bug report, they will assign it to a
31
+ primary handler. This person will coordinate the fix and release process,
32
+ involving the following steps:
33
+
34
+ * Confirm the problem and determine the affected versions.
35
+ * Audit code to find any potential similar problems.
36
+ * Prepare fixes for all releases still under maintenance. These fixes will be
37
+ released as fast as possible.
38
+
39
+ ## Comments on this Policy
40
+
41
+ If you have suggestions on how this process could be improved please submit a
42
+ pull request.
@@ -0,0 +1,36 @@
1
+ #!/bin/bash
2
+
3
+ set -eux
4
+
5
+ DIR="coverage"
6
+ BIN="cc-test-reporter"
7
+ REPORT="${DIR}/.resultset.json"
8
+
9
+ if [[ ! -e ${REPORT} ]]; then
10
+ echo "SimpleCov report (${REPORT}) not found"
11
+ ls -laR ${DIR}
12
+ exit 1
13
+ fi
14
+
15
+ if [[ ! -x ${BIN} ]]; then
16
+ echo "cc-test-reporter binary not found, not reporting coverage data to code climate"
17
+ ls -laR ${DIR}
18
+ # report is present but reporter binary is not, definitely a bug, exit error.
19
+ exit 1
20
+ fi
21
+
22
+ # Simplecov excludes files not within the current repo, it also needs to
23
+ # be able to read all the files referenced within the report. As the reports
24
+ # are generated in containers, the absolute paths contained in the report
25
+ # are not valid outside that container. This sed fixes the paths
26
+ # So they are correct relative to the Jenkins workspace.
27
+ sed -i -E "s+/src/conjur-api+${WORKSPACE}+g" "${REPORT}"
28
+
29
+ echo "Coverage reports prepared, submitting to CodeClimate."
30
+ # vars GIT_COMMIT, GIT_BRANCH & TRID are set by ccCoverage.dockerPrep
31
+
32
+ ./${BIN} after-build \
33
+ --coverage-input-type "simplecov"\
34
+ --id "${TRID}"
35
+
36
+ echo "Successfully Reported Coverage Data"
data/conjur-api.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/conjur-api/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Rafal Rzepecki","Kevin Gilpin"]
6
- gem.email = ["rafal@conjur.net","kgilpin@conjur.net"]
5
+ gem.authors = ["CyberArk Maintainers"]
6
+ gem.email = ["conj_maintainers@cyberark.com"]
7
7
  gem.description = %q{Conjur API}
8
8
  gem.summary = %q{Conjur API}
9
9
  gem.homepage = "https://github.com/cyberark/conjur-api-ruby/"
@@ -22,7 +22,8 @@ Gem::Specification.new do |gem|
22
22
  gem.executables -= %w{parse-changelog.sh}
23
23
 
24
24
  gem.add_dependency 'rest-client'
25
- gem.add_dependency 'activesupport'
25
+ gem.add_dependency 'activesupport', '>= 4.2'
26
+ gem.add_dependency 'addressable', '~> 2.8.0'
26
27
 
27
28
  gem.add_development_dependency 'rake', '>= 12.3.3'
28
29
  gem.add_development_dependency 'rspec', '~> 3'
@@ -30,7 +31,7 @@ Gem::Specification.new do |gem|
30
31
  gem.add_development_dependency 'json_spec'
31
32
  gem.add_development_dependency 'cucumber', '~> 2.99'
32
33
  gem.add_development_dependency 'ci_reporter_rspec'
33
- gem.add_development_dependency 'simplecov'
34
+ gem.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
34
35
  gem.add_development_dependency 'io-grab'
35
36
  gem.add_development_dependency 'rdoc'
36
37
  gem.add_development_dependency 'yard'
data/docker-compose.yml CHANGED
@@ -23,7 +23,11 @@ services:
23
23
  - authn_local_4:/run/authn-local
24
24
 
25
25
  tester_5:
26
- build: .
26
+ build:
27
+ context: .
28
+ dockerfile: Dockerfile
29
+ args:
30
+ RUBY_VERSION: ${RUBY_VERSION}
27
31
  volumes:
28
32
  - ./spec/reports:/src/conjur-api/spec/reports
29
33
  - ./features/reports:/src/conjur-api/features/reports
@@ -35,7 +39,11 @@ services:
35
39
  CONJUR_ACCOUNT: cucumber
36
40
 
37
41
  tester_4:
38
- build: .
42
+ build:
43
+ context: .
44
+ dockerfile: Dockerfile
45
+ args:
46
+ RUBY_VERSION: ${RUBY_VERSION}
39
47
  volumes:
40
48
  - ./features_v4/reports:/src/conjur-api/features_v4/reports
41
49
  - ./tmp/conjur.pem:/src/conjur-api/tmp/conjur.pem
@@ -47,7 +55,11 @@ services:
47
55
  CONJUR_ACCOUNT: cucumber
48
56
 
49
57
  dev:
50
- build: .
58
+ build:
59
+ context: .
60
+ dockerfile: Dockerfile
61
+ args:
62
+ RUBY_VERSION: ${RUBY_VERSION}
51
63
  entrypoint: bash
52
64
  volumes:
53
65
  - .:/src/conjur-api
@@ -1,20 +1,50 @@
1
- Feature: Display Host object fields.
1
+ Feature: Host object
2
2
 
3
- Background:
3
+ Scenario: API key of a newly created host is available and valid
4
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:
5
+ Then I can run the code:
8
6
  """
9
7
  expect(@host.exists?).to be(true)
10
8
  expect(@host.api_key).to be
11
9
  Conjur::API.new_from_key(@host.login, @host.api_key).token
12
10
  """
13
11
 
14
- Scenario: API key of a a host can be rotated.
15
- Then I run the code:
12
+ # Rotation of own API key should be done via `Conjur::API.rotate_api_key()`
13
+ Scenario: Host's own API key cannot be rotated with an API key
14
+ Given a new host
15
+ Then this code should fail with "You cannot rotate your own API key via this method"
16
16
  """
17
17
  host = Conjur::API.new_from_key(@host.login, @host.api_key).resource(@host.id)
18
- api_key = host.rotate_api_key
19
- Conjur::API.new_from_key(@host.login, api_key).token
18
+ host.rotate_api_key
19
+ """
20
+
21
+ # Rotation of own API key should be done via `Conjur::API.rotate_api_key()`
22
+ Scenario: Host's own API key cannot be rotated with a token
23
+ Given a new host
24
+ Then this code should fail with "You cannot rotate your own API key via this method"
25
+ """
26
+ token = Conjur::API.new_from_key(@host.login, @host.api_key).token
27
+
28
+ host = Conjur::API.new_from_token(token).resource(@host.id)
29
+ host.rotate_api_key
30
+ """
31
+
32
+ Scenario: Delegated host's API key can be rotated with an API key
33
+ Given a new delegated host
34
+ Then I can run the code:
35
+ """
36
+ delegated_host_resource = Conjur::API.new_from_key(@host_owner.login, @host_owner_api_key).resource(@host.id)
37
+ api_key = delegated_host_resource.rotate_api_key
38
+ Conjur::API.new_from_key(delegated_host_resource.login, api_key).token
39
+ """
40
+
41
+ Scenario: Delegated host's API key can be rotated with a token
42
+ Given a new delegated host
43
+ Then I can run the code:
44
+ """
45
+ token = Conjur::API.new_from_key(@host_owner.login, @host_owner_api_key).token
46
+
47
+ delegated_host_resource = Conjur::API.new_from_token(token).resource(@host.id)
48
+ api_key = delegated_host_resource.rotate_api_key
49
+ Conjur::API.new_from_key(delegated_host_resource.login, api_key).token
20
50
  """
@@ -1,7 +1,18 @@
1
- When(/^I(?: can)? run the code:$/) do |code|
1
+ Then(/^I(?: can)? run the code:$/) do |code|
2
2
  @result = eval(code).tap do |result|
3
- if ENV['DEBUG']
4
- puts 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}'"
5
13
  end
14
+ else
15
+ puts @result if ENV['DEBUG']
16
+ fail "The provided block did not raise an error"
6
17
  end
7
18
  end
@@ -13,6 +13,25 @@ Given(/^a new user$/) do
13
13
  expect(@user_api_key).to be
14
14
  end
15
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
+
16
35
  Given(/^a new group$/) do
17
36
  @group_id = "group-#{random_hex}"
18
37
  response = $conjur.load_policy 'root', <<-POLICY
@@ -33,3 +52,24 @@ Given(/^a new host$/) do
33
52
  @host = $conjur.resource("cucumber:host:#{@host_id}")
34
53
  @host.attributes['api_key'] = @host_api_key
35
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
@@ -1,8 +1,8 @@
1
1
  require 'simplecov'
2
- require 'simplecov-cobertura'
3
2
 
4
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
5
- SimpleCov.start
3
+ SimpleCov.start do
4
+ command_name "#{ENV['RUBY_VERSION']}"
5
+ end
6
6
 
7
7
  require 'json_spec/cucumber'
8
8
  require 'conjur/api'