Skip to content
Merged
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 oks_cli/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def profile():
@click.option('--password', required=False, help="Password", type=click.STRING)
@click.option('--region', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1']))
@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING)
@click.option('--jwt', help="Enable JWT, by default is false")
@click.option('--jwt', help="Enable JWT, by default is false", type=click.BOOL)
def add_profile(profile_name, access_key, secret_key, username, password, region, endpoint, jwt):
"""Add a new profile with AK/SK or username/password authentication."""
if not profile_name:
Expand Down
28 changes: 27 additions & 1 deletion tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from click.testing import CliRunner
from oks_cli.main import cli

from unittest.mock import patch

def test_profile_list_command():
runner = CliRunner()
Expand Down Expand Up @@ -38,6 +38,32 @@ def test_profile_add_command():
assert result.exit_code == 0
assert "Profile default has been successfully added" in result.output

def test_profile_add_jwt_boolean():
runner = CliRunner()

with patch("oks_cli.profile.set_profile") as mock_set_profile:
result = runner.invoke(
cli,
[
"profile", "add",
"--region", "eu-west-2",
"--access-key", "AK",
"--secret-key", "SK",
"--jwt", "true"
],
input="y\n"
)

assert result.exit_code == 0

mock_set_profile.assert_called_once()
profile_name, obj = mock_set_profile.call_args[0]

assert profile_name == "default"

assert isinstance(obj["jwt"], bool)
assert obj["jwt"] is True

def test_profile_update_command(add_default_profile):
runner = CliRunner()
result = runner.invoke(cli, ["profile", "update", "--profile-name", "default", "--region", "cloudgouv-eu-west-1"])
Expand Down