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

Unpin openapitools/openapi-generator-cli version #228

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
uses: actions/checkout@v2

- name: run integration test script
run: ./bin/test_integration -l csharp-netcore
run: ./bin/test_integration -l csharp
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ To ensure your changes work as expected, you can run the [automated tests](#auto
* Run a subset of a clients tests by including an argument with the full package
path of the tests to run:
```shell
$ ./bin/test_integration -l python --test test_authn_api.TestAuthnApi.test_authenticate_200
$ ./bin/test_integration -l python --test auth.test_authentication_api.TestAuthnApi.test_get_access_token_200
```
* Tests can be run against Conjur Enterprise.
* This requires access to the CyberArk Docker registry in order to pull Conjur Enterprise images
Expand Down
2 changes: 1 addition & 1 deletion bin/generate_client
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OPTIONS
EOF
}

generator_version="v4.3.1"
generator_version="latest-release" # v7.0.1 as of 29 Sept 2023
GENERATOR_IMAGE="openapitools/openapi-generator-cli:$generator_version"

client_lang=""
Expand Down
27 changes: 13 additions & 14 deletions bin/test_integration
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ USAGE

MANDATORY
-l|--language <language> Specify a client language to test.
Testable languages include
csharp-netcore and python.
Testable languages include:
${supported_langs[@]}

OPTIONS
-e|--enterprise Run tests against Conjur Enterprise.
Expand Down Expand Up @@ -52,7 +52,7 @@ else
sudo_prefix=""
fi

declare -a supported_langs=("csharp-netcore" "java" "python")
declare -a supported_langs=("csharp" "python")
language=""
test=""

Expand Down Expand Up @@ -100,13 +100,12 @@ done
if [[ -z "$language" ]]; then
echo "Missing required --language option"
echo "Valid language arguments:"
echo " csharp-netcore"
echo " python"
printf ' %s\n' "${supported_langs[@]}"
exit 1
fi

if [[ $enterprise -eq 1 ]]; then
if [[ "$language" == "csharp-netcore" ]]; then
if [[ "$language" == "csharp" ]]; then
echo "Enterprise tests for C# Conjur client not supported!"
exit 1
fi
Expand Down Expand Up @@ -145,26 +144,26 @@ configure_env() {
fi
}

run_csharp-netcore_tests(){
run_csharp_tests(){
if [[ -n "$test" ]]; then
test_params="--filter \"ClassName=Org.OpenAPITools.Test.$test\""
fi

# Overwrite the autogenerated tests with the manually written tests
$sudo_prefix rm -rf ./out/$appliance/csharp-netcore/src/Org.OpenAPITools.Test/Api
$sudo_prefix rm -rf ./out/$appliance/csharp-netcore/src/Org.OpenAPITools.Test/Model
$sudo_prefix cp -r ./test/csharp-netcore/* ./out/$appliance/csharp-netcore/src/Org.OpenAPITools.Test/
$sudo_prefix rm -rf ./out/$appliance/csharp/src/Org.OpenAPITools.Test/Api
$sudo_prefix rm -rf ./out/$appliance/csharp/src/Org.OpenAPITools.Test/Model
$sudo_prefix cp -r ./test/csharp/* ./out/$appliance/csharp/src/Org.OpenAPITools.Test/

docker run --rm --network $docker_network \
-v ${PWD}/out/${appliance}/csharp-netcore:/src \
-e CONJUR_HTTP_APPLIANCE_URL=http://conjur \
-v ${PWD}/out/${appliance}/csharp:/src \
-e CONJUR_HTTP_APPLIANCE_URL=http://conjur \
-e CONJUR_HTTPS_APPLIANCE_URL=https://conjur-https \
-e CONJUR_ACCOUNT=dev \
-e CONJUR_AUTHN_LOGIN=admin \
-e CONJUR_CA_BUNDLE=/opt/conjur-openapi-spec/config/https/ca.crt \
--env-file .env \
-w /src \
mcr.microsoft.com/dotnet/sdk:2.1 \
-w /src \
mcr.microsoft.com/dotnet/sdk:7.0 \
bash -c "dotnet test $test_params"
}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ services:
- ./config/https/:/config

test-dotnet:
image: mcr.microsoft.com/dotnet/sdk:2.1
image: mcr.microsoft.com/dotnet/sdk:7.0
command: ['sleep', '999d']
depends_on:
- conjur
Expand Down
44 changes: 21 additions & 23 deletions examples/python/python_client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python3

import base64
import os
import pathlib
import sys

import conjur
from conjur.rest import ApiException
from conjur.api import AuthenticationApi, PoliciesApi, SecretsApi

CERT_DIR = pathlib.Path('config/https')
SSL_CERT_FILE = 'ca.crt'
Expand Down Expand Up @@ -40,11 +39,10 @@
config.key_file = CERT_DIR.joinpath(CONJUR_KEY_FILE)

api_client = conjur.ApiClient(config)
login_api = conjur.AuthenticationApi(api_client)
login_api = AuthenticationApi(api_client)

# Authenticate admin using basicAuth, receiving short-lived access token
print("Authenticating admin...")

access_token = login_api.get_access_token(
account=ACCOUNT_NAME,
login=LOGIN,
Expand All @@ -65,11 +63,11 @@

# Add Conjur Token header to client configuration
token_body = 'token="{}"'.format(access_token)
api_client.configuration.api_key = {'Authorization': token_body}
api_client.configuration.api_key_prefix = {'Authorization': 'Token'}
api_client.configuration.api_key_prefix = {'conjurAuth': 'Token'}
api_client.configuration.api_key = {'conjurAuth': token_body}

policy_api = conjur.PoliciesApi(api_client)
login_api = conjur.AuthenticationApi(api_client)
policy_api = PoliciesApi(api_client)
login_api = AuthenticationApi(api_client)

# Load simple policy, which only defines an admin user
# Allows the example to be run multiple times sequentially
Expand All @@ -78,17 +76,17 @@
# the full policy will not respond with alice's api key.
print("\nLoading simple root policy...")
policy_api.replace_policy(
ACCOUNT_NAME,
"root",
empty_policy
account=ACCOUNT_NAME,
identifier="root",
body=empty_policy
)
print("Empty policy loaded.")

# Load a policy using api client
print("\nLoading root policy...")
loaded_results = policy_api.replace_policy(
ACCOUNT_NAME,
"root",
account=ACCOUNT_NAME,
identifier="root",
body=policy
)
print("Policy loaded.")
Expand All @@ -106,29 +104,29 @@

# Store a secret, uses conjurAuth
print("\nStoring secret...")
secrets_api = conjur.SecretsApi(api_client)
secrets_api = SecretsApi(api_client)
print("Secret data: ", secret)
secrets_api.create_secret(
ACCOUNT_NAME,
"variable",
secret_id,
account=ACCOUNT_NAME,
kind="variable",
identifier=secret_id,
body=secret
)
print("Secret stored.")

# Retrieve secrets, uses conjurAuth
print("\nRetrieving secret...")
retrieved_secret = secrets_api.get_secret(
ACCOUNT_NAME,
"variable",
secret_id
)
print("Retrieved seceret: ", retrieved_secret)
account=ACCOUNT_NAME,
kind="variable",
identifier=secret_id
).decode()
print("Retrieved secret: ", retrieved_secret)

if retrieved_secret != secret:
print("Secret Malformed.")
print("Secret stored: ", secret)
print("Secret retrieved: ", retrieved)
print("Secret retrieved: ", retrieved_secret)
sys.exit(1)

print("\nDone!")
17 changes: 10 additions & 7 deletions examples/ruby/ruby_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Load the gem
require 'conjur-sdk'
require 'json'

CERT_DIR = '/config/https'
SSL_CERT_FILE = 'ca.crt'
Expand Down Expand Up @@ -65,8 +66,8 @@

# Add Conjur Token header to api configuration
token_body = 'token="%s"' % [token]
config.api_key['Authorization'] = token_body
config.api_key_prefix['Authorization'] = 'Token'
config.api_key_prefix['conjurAuth'] = 'Token'
config.api_key['conjurAuth'] = token_body

policy_instance = ConjurSDK::PoliciesApi.new
authn_instance = ConjurSDK::AuthenticationApi.new
Expand Down Expand Up @@ -121,11 +122,13 @@
# Retrieve a secret, uses conjurAuth
puts
puts "Retrieving secret..."
retrieved_secret = secrets_instance.get_secret(
account=ACCOUNT,
kind="variable",
identifier=secret_id
)
retrieved_secret = JSON.parse(
secrets_instance.get_secret(
account=ACCOUNT,
kind="variable",
identifier=secret_id
)
)['body']
puts "Retrieved secret: #{retrieved_secret}"

if retrieved_secret != secret
Expand Down
2 changes: 1 addition & 1 deletion spec/authentication.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ components:

ApiKey:
type: string
minLength: 55
maxLength: 56
description: "Example of a Conjur API key"
example: "14m9cf91wfsesv1kkhevg12cdywm2wvqy6s8sk53z1ngtazp1t9tykc"

Expand Down
50 changes: 20 additions & 30 deletions spec/host-factory.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
components:
schemas:
CreateHost:
CreatedHost:
description: Contains information about a created host
type: object
properties:
Expand Down Expand Up @@ -97,57 +97,47 @@ components:
"id": "new-host"
}

CreateHostToken:
type: array
items:
type: object
properties:
expiration:
type: string
cidr:
type: array
items:
type: string
token:
HostToken:
type: object
properties:
expiration:
type: string
cidr:
type: array
items:
type: string
required:
- expiration
- cidr
- token
token:
type: string
required:
- expiration
- cidr
- token
example:
[
{
{
"expiration": "2017-08-04T22:27:20+00:00",
"cidr": [
"127.0.0.1/32",
"127.0.0.2/32"
],
"token": "281s2ag1g8s7gd2ezf6td3d619b52t9gaak3w8rj0p38124n384sq7x"
},
{
"expiration": "2017-08-04T22:27:20+00:00",
"cidr": [
"127.0.0.1/32",
"127.0.0.2/32"
],
"token": "2c0vfj61pmah3efbgpcz2x9vzcy1ycskfkyqy0kgk1fv014880f4"
}
]

responses:
CreateHost:
description: "The response body contains the newly-created host"
content:
application/json:
schema:
$ref: "#/components/schemas/CreateHost"
$ref: "#/components/schemas/CreatedHost"

CreateHostToken:
description: "Zero or more tokens were created and delivered in the response body"
content:
application/json:
schema:
$ref: '#/components/schemas/CreateHostToken'
type: array
items:
$ref: '#/components/schemas/HostToken'

paths:
CreateHostToken:
Expand Down
24 changes: 4 additions & 20 deletions spec/resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ components:
"version": 15.0
}


Resource:
type: object
properties:
Expand Down Expand Up @@ -105,24 +104,7 @@ components:
"permissions": [],
"policy": "dev:policy:root",
"policy_versions": [],
}

Resources:
type: array
items:
$ref: '#/components/schemas/Resource'
example:
[
{
"annotations": [],
"created_at": "2021-03-23T16:37:14.455+00:00",
"id": "dev:policy:conjur/authn-ldap/test",
"owner": "dev:user:admin",
"permissions": [],
"policy": "dev:policy:root",
"policy_versions": [],
}
]
}

responses:
Resource:
Expand All @@ -137,7 +119,9 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/Resources'
type: array
items:
$ref: '#/components/schemas/Resource'

paths:
ListResources:
Expand Down
Loading
Loading