fix(jfrog-oauth): fail when access_token is empty #574
+409
−191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #72 - The
jfrog-oauthmodule now fails with a clear error message when the JFrog access token is empty, instead of silently creating configurations with empty tokens.Changes
1. Added Precondition Validation (
main.tf)This ensures the module fails at plan time with a clear error when users haven't authenticated via external auth.
2. Replaced
main.test.tswithjfrog-oauth.tftest.hclWhy we removed the TypeScript tests:
The TypeScript tests used
runTerraformApply()which runsterraform applydirectly. This approach cannot mock data sources likecoder_external_auth. The Coder provider returns empty strings for tokens by default when running outside a real Coder workspace.With our new precondition, the TypeScript tests would always fail because:
terraform applyruns → emptyaccess_tokenfrom mock providerThe solution: Terraform's native
.tftest.hclformat supportsoverride_datablocks that can properly mock data sources:3. Comprehensive Test Coverage
The new
jfrog-oauth.tftest.hclincludes 12 tests (up from 7):test_required_varstest_empty_access_token_failstest_valid_access_token_succeedstest_jfrog_url_validationtest_username_field_validationtest_with_npm_package_managertest_configure_code_servertest_go_proxy_envtest_pypi_package_managertest_docker_package_managertest_conda_package_managertest_maven_package_managerAll package manager tests use
strcontains()to verify the actual script content matches expected configuration formats.Test Limitations (Acknowledged)
The tests verify template rendering but not runtime execution:
Rationale: The original TypeScript tests also only checked script content (
toContain()), not execution. Full execution testing would require a mock JFrog server, which adds significant complexity for limited benefit. The script is straightforward bash that configures files and runs CLI commands.Testing
Generated with mux