-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print Conjur version only on server startup #1590
Conversation
efa28f0
to
d5c9601
Compare
bin/conjur-cli.rb
Outdated
@@ -72,6 +72,9 @@ def test_select | |||
end | |||
|
|||
Process.fork do | |||
conjur_version = (File.read(File.expand_path("../VERSION", File.dirname(__FILE__)))).strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use parentheses around a method call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use some helper variables to make this line less complex? Might solve this codeclimate warning too.
CHANGELOG.md
Outdated
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | |||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | |||
|
|||
## Unreleased | |||
### Fixed | |||
- The Conjur version is now printed on server startup, after running `conjurctl server` | |||
((cyberark/conjur#1590)[https://github.com/cyberark/conjur/pull/1590]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parens are backwards here. The issue should have square brackets and the link should have parens.
bin/conjur-cli.rb
Outdated
@@ -72,6 +72,9 @@ def test_select | |||
end | |||
|
|||
Process.fork do | |||
conjur_version = (File.read(File.expand_path("../VERSION", File.dirname(__FILE__)))).strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use some helper variables to make this line less complex? Might solve this codeclimate warning too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this broke a bunch of downstream projects that rely on conjurctl role retrieve-key
can we please add a test to this PR that validates that this method works (and retrieves a valid key for the specified role) so we catch changes that break it in conjur PRs instead of in downstream pipelines post-tag?
d5c9601
to
ce08512
Compare
ce08512
to
0636557
Compare
The print that we added didn't print the version only on server startup, and actually printed it for every `conjurctl` command. This commit changes this behaviour so the message is printed only on server startup.
0636557
to
788aaf7
Compare
@env.each do |key, value| | ||
ENV[key] = value | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final newline missing.
|
||
Given(/^I set environment variable "([^"]*)" to "([^"]*)"$/) do |variable_name, variable_value| | ||
ENV[variable_name] = variable_value | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final newline missing.
@env.each do |key, value| | ||
ENV[key] = value | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final newline missing.
788aaf7
to
9f2d9f1
Compare
@@ -0,0 +1,8 @@ | |||
Feature: Retrieving an API key with conjurctl | |||
|
|||
# We need to be in production environment to test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why we need to be in production?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because that's the environment our clients will be. When we are in dev env the error doesn't occur
# We need to be in production environment to test this | ||
Scenario: Retrieve an API key | ||
Given I set environment variable "RAILS_ENV" to "production" | ||
And I set environment variable "CONJUR_LOG_LEVEL" to "info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why setting the conjur_log_level is relevant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because if we are in debug mode the output will contain some junk. we change the env so we are in the expected environment of the client using this tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o.k. Since its not suppose to influence the results.
In general i want to work with relevant steps only(in this case its not critical) because if from some reason we will fail on this step we cant say "retrieve an API key" is not working.
@@ -0,0 +1,8 @@ | |||
Feature: Retrieving an API key with conjurctl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add another test to verify we have error when the API is wrong(role does not exist).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
9f2d9f1
to
3d91227
Compare
|
||
Scenario: Retrieve an API key of a non-existing user fails | ||
When I retrieve an API key for user "cucumber:user:non-existing-user" using conjurctl | ||
Then the stderr includes the error "role does not exist" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line is missing
3d91227
to
2655d87
Compare
@@ -0,0 +1,15 @@ | |||
require 'open3' | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line detected.
|
||
When(/^I retrieve an API key for user "([^"]*)" using conjurctl$/) do |user_id| | ||
command = "conjurctl role retrieve-key #{user_id}" | ||
@conjurctl_stdout, @conjurctl_stderr, _ = Open3.capture3(command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use trailing _
s in parallel assignment. Prefer @conjurctl_stdout, @conjurctl_stderr, = Open3.capture3(command)
.
end | ||
|
||
Then(/^the stderr includes the error "([^"]*)"$/) do |error| | ||
expect(@conjurctl_stderr).to include("#{error}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to_s
over string interpolation.
Some test manipulate the env so we need to revert to the original one after each scenario.
2655d87
to
6dded0d
Compare
Code Climate has analyzed commit 6dded0d and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 85.6% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests approved
Connected to #1589
We recently started to print the Conjur version on server startup:
However, this message is written for every
conjurctl
command. For example:This PR changes the behaviour so that the message is printed only on server startup.
After the change, the output of
conjurctl server
is:and the output of
conjurctl role
is: