diff --git a/HISTORY.md b/HISTORY.md index 8259555..abf5dd1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,14 @@ 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). +## [1.1.0](https://github.com/cortexapps/cli/releases/tag/1.1.0) - 2025-11-04 + +[Compare with 1.0.6](https://github.com/cortexapps/cli/compare/1.0.6...1.1.0) + +### Added + +- add: support for triggering scorecard entity evaluation ([66d73d9](https://github.com/cortexapps/cli/commit/66d73d9ec5ab6d2373736f636e53643abe06c063) by Jeff Schnitter). + ## [1.0.6](https://github.com/cortexapps/cli/releases/tag/1.0.6) - 2025-10-31 [Compare with 1.0.5](https://github.com/cortexapps/cli/compare/1.0.5...1.0.6) diff --git a/cortexapps_cli/cli.py b/cortexapps_cli/cli.py index 8998fa5..03d471d 100755 --- a/cortexapps_cli/cli.py +++ b/cortexapps_cli/cli.py @@ -121,6 +121,10 @@ def global_callback( else: url = "https://api.getcortexapp.com" + # Set default URL if not provided + if not url: + url = "https://api.getcortexapp.com" + # strip any quotes or spaces from the api_key and url api_key = api_key.strip('"\' ') url = url.strip('"\' /') diff --git a/tests/test_config_file.py b/tests/test_config_file.py index 1c356dc..f37cc81 100644 --- a/tests/test_config_file.py +++ b/tests/test_config_file.py @@ -70,3 +70,28 @@ def test_config_file_base_url_env_var(monkeypatch, tmp_path): f.write_text(content) monkeypatch.setenv("CORTEX_BASE_URL", "https://api.getcortexapp.com") cli(["-c", str(f), "-t", "mySection", "entity-types", "list"]) + +def test_no_base_url_defaults_correctly(monkeypatch, tmp_path): + """ + Test that when base_url is not provided via config file or environment variable, + the CLI defaults to https://api.getcortexapp.com without crashing. + + This reproduces the bug from issue #151 where url.strip() was called on None. + """ + # Remove CORTEX_BASE_URL from environment + monkeypatch.delenv("CORTEX_BASE_URL", raising=False) + + cortex_api_key = os.getenv('CORTEX_API_KEY') + + # Create config file WITHOUT base_url + f = tmp_path / "cortex_config_no_base_url" + template = Template(""" + [default] + api_key = "${cortex_api_key}" + """) + content = template.substitute(cortex_api_key=cortex_api_key) + f.write_text(content) + + # This should not crash and should use the default URL + response = cli(["-c", str(f), "entity-types", "list"]) + assert 'definitions' in response, "Should successfully call API with default URL" diff --git a/tests/test_scorecards.py b/tests/test_scorecards.py index 0368c42..9ec4216 100644 --- a/tests/test_scorecards.py +++ b/tests/test_scorecards.py @@ -27,9 +27,10 @@ def test_scorecards(): # cannot rely on a scorecard evaluation being complete, so not performing any validation cli(["scorecards", "next-steps", "-s", "cli-test-scorecard", "-t", "cli-test-service"]) - # Test trigger-evaluation command + # Test trigger-evaluation command (accepts both success and 409 Already evaluating) response = cli(["scorecards", "trigger-evaluation", "-s", "cli-test-scorecard", "-e", "cli-test-service"], return_type=ReturnType.STDOUT) - assert "Scorecard evaluation triggered successfully" in response, "Should receive success message when triggering evaluation" + assert ("Scorecard evaluation triggered successfully" in response or "Already evaluating scorecard" in response), \ + "Should receive success message or 409 Already evaluating error" # cannot rely on a scorecard evaluation being complete, so not performing any validation #response = cli(["scorecards", "scores", "-s", "cli-test-scorecard", "-t", "cli-test-service"])