Skip to content
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

Initial PR #1

Merged
merged 5 commits into from
May 6, 2021
Merged

Initial PR #1

merged 5 commits into from
May 6, 2021

Conversation

telday
Copy link
Contributor

@telday telday commented May 3, 2021

Initial Pull Request

Most of the code included in this PR is directly copied from the conjur-openapi-spec repo. Things to look closely at are the shell scripts which had to undergo some small changes to make them compatible with this new repository format, as well as the CONTRIBUTING & README documents which I have added some details to.

This PR is dependent on another PR being pulled into the OpenAPI repository. Without it setting secrets in the java client will not work. For manual testing purposes you can change a line in bin/refresh_client from:

git clone https://github.com/cyberark/conjur-openapi-spec.git to
git clone -b update-request-body https://github.com/cyberark/conjur-openapi-spec.git and everything should work.

Checklist:

TODO:

  • Fill out README.md, addressing all TODOs
    • Name
    • Certification Level
    • Requirements
    • Usage Instructions
  • Edit the CONTRIBUTING.md with development and contribution guidelines for your specific
    project
    • Development
    • Testing
    • Releases
  • Update CHANGELOG.md with information on previous versions (if applicable)
  • Add issue templates to .github/ISSUE_TEMPLATE/ if the defaults in https://github.com/cyberark/.github
    don't work for your use case
  • The project comes by default with an Apache 2.0 License (in LICENSE) - if you would
    prefer to use some other license, you'll need to revise this file

Migrating From Another Repo:

  • If changing repo name, make sure to update any references to the old name
  • Update any links to refer to the new repo location

Important

  • If this repo will be public, also follow these requirements
  • Remove the "new project" issue template from the project: .github/ISSUE_TEMPLATE/new-project.md
  • (Final TODO) Delete the PR template (.github/pull_request_template.md) - the project will use the default org PR template

@telday telday force-pushed the telday-patch-1 branch 4 times, most recently from cbf2afe to 76c6903 Compare May 5, 2021 14:29
@telday telday changed the title Update README.md Initial PR May 5, 2021
@telday telday force-pushed the telday-patch-1 branch 2 times, most recently from 2f9fa5d to ed4fb6f Compare May 5, 2021 14:37
telday added 2 commits May 5, 2021 10:41
The integration testing environment is largely
the same, as well as the script for generating the
client. Although there are not currently tests
for the OIDC & LDAP authenticators included in the
client I left them in as a part of the integration
testing infrastructure, it is zero cost to leave them
in & we will definitely want to test against them in
the future.
@telday telday force-pushed the telday-patch-1 branch from ed4fb6f to 068e90b Compare May 5, 2021 14:42
@telday telday marked this pull request as ready for review May 5, 2021 14:50
@telday telday force-pushed the telday-patch-1 branch from 068e90b to 84d9ef5 Compare May 5, 2021 15:00
@telday telday requested a review from izgeri May 5, 2021 15:07
Copy link

@diverdane diverdane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, awesome user documentation!!! I've reviewed a bunch. Let me know if there are other files on which I haven't commented that should be reviewed with special attention.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated
a high level overview of the benefit of your project and its main use cases.
| Java Client Version | API Version |
| :-----------------: | :---------: |
| 1.x.x | 5.1.1 |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the 5.1.1 API version be the currently supported OpenAPI Generator version (4.3.1)?
Or if "API version" refers to a different repo than the OpenAPI Generator, can we add a hyperlink to that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 5.1.1 version number corresponds to the Conjur API Version. I will try to make this more clear and add a link to the OpenAPI releases page.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
bin/get_conjur_admin_key Outdated Show resolved Hide resolved
bin/get_conjur_admin_key Outdated Show resolved Hide resolved
# Docker-compose will pick this file up when starting containers
# so we will have these variables in the container
cat <<ENV > .env
CONJUR_AUTHN_API_KEY=$admin_api_key

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add quotes:

CONJUR_AUTHN_API_KEY="$admin_api_key"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had to revert this one. Putting quotes around the substitution here also puts quotes around the variable when you retrieve it which causes issues in the client. Don't know if there is a way around this.

bin/util Outdated Show resolved Hide resolved
bin/util Outdated Show resolved Hide resolved
@telday telday force-pushed the telday-patch-1 branch 2 times, most recently from 256d938 to 51be530 Compare May 6, 2021 14:48
@telday telday force-pushed the telday-patch-1 branch 3 times, most recently from 57c7238 to ac4fa96 Compare May 6, 2021 15:46
@telday telday requested a review from diverdane May 6, 2021 15:47
Copy link

@diverdane diverdane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more comments.
I scrolled past the rest of the files, it looks like it's mostly generated scaffolding code?


conjur_container_alive(){
if [ -z `docker-compose ps -q conjur` ]; then
echo 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open for convincing... but for readability, my preference for a boolean bash function would be to just execute true or false
(See https://stackoverflow.com/questions/2953646/how-can-i-declare-and-use-boolean-variables-in-a-shell-script).

For example:

conjur_container_alive(){
  if [ -z `docker-compose ps -q conjur` ]; then
    true
  elif [ -z `docker ps -q --no-trunc | grep $(docker-compose ps -q conjur)` ]; then
    true
  else
    false
  fi
}

And then, when this function gets invoked, the conditional would be:

    if [ "$no_rebuild_conjur" = false ] || conjur_container_alive; then

Here, the no_rebuild_conjur would be initialized as:

    no_rebuild_conjur=false

Another way to do it would be to echo the literal 'true' or 'false' in the function and for the variable initialization:

conjur_container_alive(){
  if [ -z `docker-compose ps -q conjur` ]; then
    echo 'true'
  elif [ -z `docker ps -q --no-trunc | grep $(docker-compose ps -q conjur)` ]; then
    echo 'true'
  else
    echo 'false'
  fi
}

And then the function invocation would be:

    if [ "$no_rebuild_conjur" = 'false' ] || [ "$(conjur_container_alive)" = 'true' ]; then

Here, the no_rebuild_conjur would be initialized as:

    no_rebuild_conjur='false'

FWIW, I made a "playground" bash script to experiment and validate these techniques:

#!/bin/bash

set -e

true_var=true
false_var=false
true_var_2='true'
false_var_2='false'

function true_func() {
    true
}

function false_func() {
    false
}

function true_func_2() {
    echo 'true'
}

function false_func_2() {
    echo 'false'
}

if "$true_var"; then
    echo "true_var is true"
else
    echo "true_var is false"
fi

if "$false_var"; then
    echo "false_var is true"
else
    echo "false_var is false"
fi

if [ "$true_var" = true ]; then
    echo "true_var is true"
else
    echo "true_var is false"
fi

if [ "$false_var" = true ]; then
    echo "false_var is true"
else
    echo "false_var is false"
fi

if [ "$true_var_2" = 'true' ]; then
    echo "true_var_2 is 'true'"
else
    echo "true_var_2 is 'false'"
fi

if [ "$false_var_2" = 'true' ]; then
    echo "false_var_2 is 'true'"
else
    echo "false_var_2 is 'false'"
fi

if true_func; then
    echo "true_func returns true"
else
    echo "true_func returns false"
fi

if false_func; then
    echo "false_func returns true"
else
    echo "false_func returns false"
fi

if [ "$(true_func_2)" = 'true' ]; then
    echo "true_func_2 returns 'true'"
else
    echo "true_func_2 returns 'false'"
fi

if [ "$(false_func_2)" = 'true' ]; then
    echo "false_func_2 returns 'true'"
else
    echo "false_func_2 returns 'false'"
fi

if $true_var && true_func; then
    echo "Both true_var and true_func are true"
else
    echo "true_var and true_func are not both true"
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing this out! I actually had no idea you could just execute true/false from a function. I updated the boolean variables, will probably go over to the openapi repo and make a few changes over there as well to clean things up.


source bin/util

no_regen_client=0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more readable to use literal 'true' or 'false' for boolean variables?

For example:

no_regen_client='false'

And conditional check would be:

if [ "$no_regen_client" = 'false' ]; then
    # Do stuff
fi

Or, you can use true or false directly:

no_regen_client=false

And conditional check would be:

if [ "$no_regen_client" = false ]; then
    # Do stuff
fi

@telday telday force-pushed the telday-patch-1 branch from ac4fa96 to 06368e6 Compare May 6, 2021 19:10
@telday telday requested a review from diverdane May 6, 2021 19:10
Copy link

@diverdane diverdane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Everything looks really great. I'm approving, though I only did a very quick scan of the generated scaffolding... I'm assuming that part will evolve and get thoroughly tested as you add more features.

@telday telday merged commit 433f3d2 into main May 6, 2021
@telday telday deleted the telday-patch-1 branch May 6, 2021 19:30
conjur-jenkins pushed a commit that referenced this pull request Jan 6, 2025
CNJR-4234 - OpenAPI Specification - Java SDK - Added Automated testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants