The `copilot_model` variable was restricted to a hardcoded enum of three models (`claude-sonnet-4`, `claude-sonnet-4.5`, `gpt-5`). Models change fast and this validation was blocking users from using newer models. ## Changes - Remove `validation` block from `copilot_model` variable in `main.tf` - Update variable description to indicate any Copilot-supported model can be used - Replace enum validation test with a test that verifies arbitrary model strings are accepted - Bump module version to `0.4.1` in README examples Closes #832 > 🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑💻
355 lines
9.1 KiB
HCL
355 lines
9.1 KiB
HCL
run "defaults_are_correct" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
}
|
|
|
|
assert {
|
|
condition = var.copilot_model == "claude-sonnet-4.5"
|
|
error_message = "Default model should be 'claude-sonnet-4.5'"
|
|
}
|
|
|
|
assert {
|
|
condition = var.report_tasks == true
|
|
error_message = "Task reporting should be enabled by default"
|
|
}
|
|
|
|
assert {
|
|
condition = var.resume_session == true
|
|
error_message = "Session resumption should be enabled by default"
|
|
}
|
|
|
|
assert {
|
|
condition = var.allow_all_tools == false
|
|
error_message = "allow_all_tools should be disabled by default"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.mcp_app_status_slug.name == "CODER_MCP_APP_STATUS_SLUG"
|
|
error_message = "Status slug env var should be created"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.mcp_app_status_slug.value == "copilot"
|
|
error_message = "Status slug value should be 'copilot'"
|
|
}
|
|
}
|
|
|
|
run "github_token_creates_env_var" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
github_token = "test_github_token_abc123"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.github_token) == 1
|
|
error_message = "github_token env var should be created when token is provided"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.github_token[0].name == "GITHUB_TOKEN"
|
|
error_message = "github_token env var name should be 'GITHUB_TOKEN'"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.github_token[0].value == "test_github_token_abc123"
|
|
error_message = "github_token env var value should match input"
|
|
}
|
|
}
|
|
|
|
run "github_token_not_created_when_empty" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
github_token = ""
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.github_token) == 0
|
|
error_message = "github_token env var should not be created when empty"
|
|
}
|
|
}
|
|
|
|
run "copilot_model_env_var_for_non_default" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
copilot_model = "claude-sonnet-4"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.copilot_model) == 1
|
|
error_message = "copilot_model env var should be created for non-default model"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.copilot_model[0].name == "COPILOT_MODEL"
|
|
error_message = "copilot_model env var name should be 'COPILOT_MODEL'"
|
|
}
|
|
|
|
assert {
|
|
condition = resource.coder_env.copilot_model[0].value == "claude-sonnet-4"
|
|
error_message = "copilot_model env var value should match input"
|
|
}
|
|
}
|
|
|
|
run "copilot_model_not_created_for_default" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
copilot_model = "claude-sonnet-4.5"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.copilot_model) == 0
|
|
error_message = "copilot_model env var should not be created for default model"
|
|
}
|
|
}
|
|
|
|
run "copilot_model_accepts_custom_model" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
copilot_model = "o3-pro"
|
|
}
|
|
|
|
assert {
|
|
condition = var.copilot_model == "o3-pro"
|
|
error_message = "copilot_model should accept any model string"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.copilot_model) == 1
|
|
error_message = "copilot_model env var should be created for non-default model"
|
|
}
|
|
}
|
|
|
|
run "copilot_config_merges_with_trusted_directories" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder/project"
|
|
trusted_directories = ["/workspace", "/data"]
|
|
}
|
|
|
|
assert {
|
|
condition = length(local.final_copilot_config) > 0
|
|
error_message = "final_copilot_config should be computed"
|
|
}
|
|
|
|
# Verify workdir is trimmed of trailing slash
|
|
assert {
|
|
condition = local.workdir == "/home/coder/project"
|
|
error_message = "workdir should be trimmed of trailing slash"
|
|
}
|
|
}
|
|
|
|
run "custom_copilot_config_overrides_default" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
copilot_config = jsonencode({
|
|
banner = "always"
|
|
theme = "dark"
|
|
})
|
|
}
|
|
|
|
assert {
|
|
condition = var.copilot_config != ""
|
|
error_message = "Custom copilot config should be set"
|
|
}
|
|
|
|
assert {
|
|
condition = jsondecode(local.final_copilot_config).banner == "always"
|
|
error_message = "Custom banner setting should be applied"
|
|
}
|
|
|
|
assert {
|
|
condition = jsondecode(local.final_copilot_config).theme == "dark"
|
|
error_message = "Custom theme setting should be applied"
|
|
}
|
|
}
|
|
|
|
run "trusted_directories_merged_with_custom_config" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder/project"
|
|
copilot_config = jsonencode({
|
|
banner = "always"
|
|
theme = "dark"
|
|
trusted_folders = ["/custom"]
|
|
})
|
|
trusted_directories = ["/workspace", "/data"]
|
|
}
|
|
|
|
assert {
|
|
condition = contains(jsondecode(local.final_copilot_config).trusted_folders, "/custom")
|
|
error_message = "Custom trusted folder should be included"
|
|
}
|
|
|
|
assert {
|
|
condition = contains(jsondecode(local.final_copilot_config).trusted_folders, "/home/coder/project")
|
|
error_message = "Workdir should be included in trusted folders"
|
|
}
|
|
|
|
assert {
|
|
condition = contains(jsondecode(local.final_copilot_config).trusted_folders, "/workspace")
|
|
error_message = "trusted_directories should be merged into config"
|
|
}
|
|
|
|
assert {
|
|
condition = contains(jsondecode(local.final_copilot_config).trusted_folders, "/data")
|
|
error_message = "All trusted_directories should be merged into config"
|
|
}
|
|
}
|
|
|
|
run "app_slug_is_consistent" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
}
|
|
|
|
assert {
|
|
condition = local.app_slug == "copilot"
|
|
error_message = "app_slug should be 'copilot'"
|
|
}
|
|
|
|
assert {
|
|
condition = local.module_dir_name == ".copilot-module"
|
|
error_message = "module_dir_name should be '.copilot-module'"
|
|
}
|
|
}
|
|
|
|
run "aibridge_proxy_defaults" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
}
|
|
|
|
assert {
|
|
condition = var.enable_aibridge_proxy == false
|
|
error_message = "enable_aibridge_proxy should default to false"
|
|
}
|
|
|
|
assert {
|
|
condition = var.aibridge_proxy_auth_url == null
|
|
error_message = "aibridge_proxy_auth_url should default to null"
|
|
}
|
|
|
|
assert {
|
|
condition = var.aibridge_proxy_cert_path == null
|
|
error_message = "aibridge_proxy_cert_path should default to null"
|
|
}
|
|
}
|
|
|
|
run "aibridge_proxy_enabled" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent-aibridge-proxy"
|
|
workdir = "/home/coder"
|
|
enable_aibridge_proxy = true
|
|
aibridge_proxy_auth_url = "https://coder:mock-token@aiproxy.example.com"
|
|
aibridge_proxy_cert_path = "/tmp/aibridge-proxy/ca-cert.pem"
|
|
}
|
|
|
|
assert {
|
|
condition = var.enable_aibridge_proxy == true
|
|
error_message = "AI Bridge Proxy should be enabled"
|
|
}
|
|
|
|
assert {
|
|
condition = var.aibridge_proxy_auth_url == "https://coder:mock-token@aiproxy.example.com"
|
|
error_message = "AI Bridge Proxy auth URL should match the input variable"
|
|
}
|
|
|
|
assert {
|
|
condition = var.aibridge_proxy_cert_path == "/tmp/aibridge-proxy/ca-cert.pem"
|
|
error_message = "AI Bridge Proxy cert path should match the input variable"
|
|
}
|
|
}
|
|
|
|
run "aibridge_proxy_validation_missing_proxy_auth_url" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent-validation"
|
|
workdir = "/home/coder"
|
|
enable_aibridge_proxy = true
|
|
aibridge_proxy_auth_url = ""
|
|
aibridge_proxy_cert_path = "/tmp/aibridge-proxy/ca-cert.pem"
|
|
}
|
|
|
|
expect_failures = [
|
|
var.enable_aibridge_proxy,
|
|
]
|
|
}
|
|
|
|
run "aibridge_proxy_validation_missing_cert_path" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent-validation"
|
|
workdir = "/home/coder"
|
|
enable_aibridge_proxy = true
|
|
aibridge_proxy_auth_url = "https://coder:mock-token@aiproxy.example.com"
|
|
aibridge_proxy_cert_path = ""
|
|
}
|
|
|
|
expect_failures = [
|
|
var.enable_aibridge_proxy,
|
|
]
|
|
}
|
|
|
|
run "aibridge_proxy_with_copilot_config" {
|
|
command = plan
|
|
|
|
variables {
|
|
agent_id = "test-agent"
|
|
workdir = "/home/coder"
|
|
copilot_model = "gpt-5"
|
|
github_token = "ghp_test123"
|
|
allow_all_tools = true
|
|
enable_aibridge_proxy = true
|
|
aibridge_proxy_auth_url = "https://coder:mock-token@aiproxy.example.com"
|
|
aibridge_proxy_cert_path = "/tmp/aibridge-proxy/ca-cert.pem"
|
|
}
|
|
|
|
assert {
|
|
condition = var.enable_aibridge_proxy == true
|
|
error_message = "AI Bridge Proxy should be enabled"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.github_token) == 1
|
|
error_message = "github_token environment variable should be set alongside proxy"
|
|
}
|
|
|
|
assert {
|
|
condition = length(resource.coder_env.copilot_model) == 1
|
|
error_message = "copilot_model environment variable should be set alongside proxy"
|
|
}
|
|
}
|