956 lines
26 KiB
Plaintext
956 lines
26 KiB
Plaintext
|
|
#!/usr/bin/env nu
|
||
|
|
|
||
|
|
# Complete Configuration System Test Suite
|
||
|
|
# Tests all aspects of the target-based configuration system
|
||
|
|
# Version: 4.0.0
|
||
|
|
|
||
|
|
use ../core/nulib/lib_provisioning *
|
||
|
|
|
||
|
|
def main [
|
||
|
|
--verbose # Show detailed test output
|
||
|
|
] {
|
||
|
|
print "🧪 Complete Configuration System Test Suite"
|
||
|
|
print "============================================"
|
||
|
|
print ""
|
||
|
|
|
||
|
|
mut total_tests = 0
|
||
|
|
mut passed_tests = 0
|
||
|
|
mut failed_tests = 0
|
||
|
|
|
||
|
|
# Test Suite 1: Nomenclature Migration
|
||
|
|
print "Test Suite 1: Nomenclature Migration"
|
||
|
|
print "------------------------------------"
|
||
|
|
let result1 = (test-nomenclature-migration $verbose)
|
||
|
|
$total_tests = $total_tests + $result1.total
|
||
|
|
$passed_tests = $passed_tests + $result1.passed
|
||
|
|
$failed_tests = $failed_tests + $result1.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 2: Provider Configs
|
||
|
|
print "Test Suite 2: Provider Configurations"
|
||
|
|
print "-------------------------------------"
|
||
|
|
let result2 = (test-provider-configs $verbose)
|
||
|
|
$total_tests = $total_tests + $result2.total
|
||
|
|
$passed_tests = $passed_tests + $result2.passed
|
||
|
|
$failed_tests = $failed_tests + $result2.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 3: Platform Configs
|
||
|
|
print "Test Suite 3: Platform Service Configurations"
|
||
|
|
print "---------------------------------------------"
|
||
|
|
let result3 = (test-platform-configs $verbose)
|
||
|
|
$total_tests = $total_tests + $result3.total
|
||
|
|
$passed_tests = $passed_tests + $result3.passed
|
||
|
|
$failed_tests = $failed_tests + $result3.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 4: KMS Config
|
||
|
|
print "Test Suite 4: KMS Configuration"
|
||
|
|
print "-------------------------------"
|
||
|
|
let result4 = (test-kms-config $verbose)
|
||
|
|
$total_tests = $total_tests + $result4.total
|
||
|
|
$passed_tests = $passed_tests + $result4.passed
|
||
|
|
$failed_tests = $failed_tests + $result4.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 5: Workspace Structure
|
||
|
|
print "Test Suite 5: Workspace Structure"
|
||
|
|
print "---------------------------------"
|
||
|
|
let result5 = (test-workspace-structure $verbose)
|
||
|
|
$total_tests = $total_tests + $result5.total
|
||
|
|
$passed_tests = $passed_tests + $result5.passed
|
||
|
|
$failed_tests = $failed_tests + $result5.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 6: User Context System
|
||
|
|
print "Test Suite 6: User Context System"
|
||
|
|
print "---------------------------------"
|
||
|
|
let result6 = (test-user-context $verbose)
|
||
|
|
$total_tests = $total_tests + $result6.total
|
||
|
|
$passed_tests = $passed_tests + $result6.passed
|
||
|
|
$failed_tests = $failed_tests + $result6.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 7: Config Loading
|
||
|
|
print "Test Suite 7: Configuration Loading"
|
||
|
|
print "-----------------------------------"
|
||
|
|
let result7 = (test-config-loading $verbose)
|
||
|
|
$total_tests = $total_tests + $result7.total
|
||
|
|
$passed_tests = $passed_tests + $result7.passed
|
||
|
|
$failed_tests = $failed_tests + $result7.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Test Suite 8: Path Interpolation
|
||
|
|
print "Test Suite 8: Path Interpolation"
|
||
|
|
print "--------------------------------"
|
||
|
|
let result8 = (test-path-interpolation $verbose)
|
||
|
|
$total_tests = $total_tests + $result8.total
|
||
|
|
$passed_tests = $passed_tests + $result8.passed
|
||
|
|
$failed_tests = $failed_tests + $result8.failed
|
||
|
|
print ""
|
||
|
|
|
||
|
|
# Final Summary
|
||
|
|
print "========================================"
|
||
|
|
print "📊 Test Summary"
|
||
|
|
print "========================================"
|
||
|
|
print $"Total Tests: ($total_tests)"
|
||
|
|
print $"✅ Passed: ($passed_tests)"
|
||
|
|
print $"❌ Failed: ($failed_tests)"
|
||
|
|
print $"Success Rate: (($passed_tests * 100 / $total_tests))%"
|
||
|
|
print ""
|
||
|
|
|
||
|
|
if $failed_tests == 0 {
|
||
|
|
print "🎉 All tests PASSED!"
|
||
|
|
exit 0
|
||
|
|
} else {
|
||
|
|
print "❌ Some tests FAILED"
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 1: Nomenclature Migration
|
||
|
|
def test-nomenclature-migration [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
# Test 1: No legacy terms in core files
|
||
|
|
$tests = ($tests | append (test-no-legacy-terms "lib_provisioning/config/accessor.nu" $verbose))
|
||
|
|
|
||
|
|
# Test 2: Templates use new nomenclature
|
||
|
|
$tests = ($tests | append (test-template-nomenclature "templates/default_context.yaml" $verbose))
|
||
|
|
|
||
|
|
# Test 3: Environment variables updated
|
||
|
|
$tests = ($tests | append (test-env-vars-updated $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 2: Provider Configs
|
||
|
|
def test-provider-configs [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
# Test each provider
|
||
|
|
for provider in ["aws" "upcloud" "local"] {
|
||
|
|
$tests = ($tests | append (test-provider-config-exists $provider $verbose))
|
||
|
|
$tests = ($tests | append (test-provider-schema-exists $provider $verbose))
|
||
|
|
$tests = ($tests | append (test-provider-config-valid $provider $verbose))
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 3: Platform Configs
|
||
|
|
def test-platform-configs [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
# Test each platform service
|
||
|
|
for service in ["orchestrator" "control-center" "mcp-server"] {
|
||
|
|
$tests = ($tests | append (test-platform-config-exists $service $verbose))
|
||
|
|
$tests = ($tests | append (test-platform-schema-exists $service $verbose))
|
||
|
|
$tests = ($tests | append (test-platform-config-valid $service $verbose))
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 4: KMS Config
|
||
|
|
def test-kms-config [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
$tests = ($tests | append (test-kms-config-exists $verbose))
|
||
|
|
$tests = ($tests | append (test-kms-schema-exists $verbose))
|
||
|
|
$tests = ($tests | append (test-kms-accessor-functions $verbose))
|
||
|
|
$tests = ($tests | append (test-kms-config-valid $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 5: Workspace Structure
|
||
|
|
def test-workspace-structure [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
$tests = ($tests | append (test-templates-directory-exists $verbose))
|
||
|
|
$tests = ($tests | append (test-workspace-templates-exist $verbose))
|
||
|
|
$tests = ($tests | append (test-workspace-init-function $verbose))
|
||
|
|
$tests = ($tests | append (test-config-defaults-not-loaded $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 6: User Context System
|
||
|
|
def test-user-context [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
$tests = ($tests | append (test-user-context-template $verbose))
|
||
|
|
$tests = ($tests | append (test-context-functions-exist $verbose))
|
||
|
|
$tests = ($tests | append (test-active-workspace-detection $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 7: Config Loading
|
||
|
|
def test-config-loading [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
$tests = ($tests | append (test-loader-hierarchy $verbose))
|
||
|
|
$tests = ($tests | append (test-yaml-support $verbose))
|
||
|
|
$tests = ($tests | append (test-user-context-overrides $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Test Suite 8: Path Interpolation
|
||
|
|
def test-path-interpolation [verbose: bool] {
|
||
|
|
mut tests = []
|
||
|
|
|
||
|
|
$tests = ($tests | append (test-interpolation-functions $verbose))
|
||
|
|
$tests = ($tests | append (test-workspace-path-variable $verbose))
|
||
|
|
$tests = ($tests | append (test-env-variable-interpolation $verbose))
|
||
|
|
|
||
|
|
{
|
||
|
|
total: ($tests | length)
|
||
|
|
passed: ($tests | where passed == true | length)
|
||
|
|
failed: ($tests | where passed == false | length)
|
||
|
|
tests: $tests
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Individual Test Functions
|
||
|
|
|
||
|
|
def test-no-legacy-terms [file: string, verbose: bool] {
|
||
|
|
let base_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib"
|
||
|
|
let file_path = ($base_path | path join $file)
|
||
|
|
|
||
|
|
if not ($file_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: $"No legacy terms in ($file)"
|
||
|
|
passed: false
|
||
|
|
error: $"File not found: ($file_path)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $file_path)
|
||
|
|
let has_kloud = ($content | str contains "kloud")
|
||
|
|
let has_cn_provisioning = ($content | str contains "cn_provisioning")
|
||
|
|
|
||
|
|
let passed = not ($has_kloud or $has_cn_provisioning)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print $" ✅ No legacy terms in ($file)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Legacy terms found in ($file)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"No legacy terms in ($file)"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Legacy terms detected" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-template-nomenclature [template: string, verbose: bool] {
|
||
|
|
let base_path = "/Users/Akasha/project-provisioning/provisioning"
|
||
|
|
let file_path = ($base_path | path join $template)
|
||
|
|
|
||
|
|
if not ($file_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: $"Template uses new nomenclature: ($template)"
|
||
|
|
passed: false
|
||
|
|
error: $"File not found: ($file_path)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $file_path)
|
||
|
|
let uses_workspace = ($content | str contains "workspace")
|
||
|
|
let no_kloud = not ($content | str contains "kloud:")
|
||
|
|
|
||
|
|
let passed = $uses_workspace and $no_kloud
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print $" ✅ Template uses new nomenclature: ($template)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Template has legacy terms: ($template)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Template uses new nomenclature: ($template)"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Legacy nomenclature detected" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-env-vars-updated [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Environment variables updated"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_new_vars = ($content | str contains "PROVISIONING_WORKSPACE_PATH")
|
||
|
|
let no_old_vars = not ($content | str contains "PROVISIONING_KLOUD_PATH")
|
||
|
|
|
||
|
|
let passed = $has_new_vars and $no_old_vars
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print " ✅ Environment variables updated"
|
||
|
|
} else {
|
||
|
|
print " ❌ Old environment variables detected"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Environment variables updated"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Old env vars detected" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-provider-config-exists [provider: string, verbose: bool] {
|
||
|
|
let config_path = $"/Users/Akasha/project-provisioning/provisioning/extensions/providers/($provider)/config.defaults.toml"
|
||
|
|
let exists = ($config_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print $" ✅ Provider config exists: ($provider)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Provider config missing: ($provider)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Provider config exists: ($provider)"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { $"File not found: ($config_path)" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-provider-schema-exists [provider: string, verbose: bool] {
|
||
|
|
let schema_path = $"/Users/Akasha/project-provisioning/provisioning/extensions/providers/($provider)/config.schema.toml"
|
||
|
|
let exists = ($schema_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print $" ✅ Provider schema exists: ($provider)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Provider schema missing: ($provider)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Provider schema exists: ($provider)"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { $"File not found: ($schema_path)" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-provider-config-valid [provider: string, verbose: bool] {
|
||
|
|
let config_path = $"/Users/Akasha/project-provisioning/provisioning/extensions/providers/($provider)/config.defaults.toml"
|
||
|
|
|
||
|
|
if not ($config_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: $"Provider config valid TOML: ($provider)"
|
||
|
|
passed: false
|
||
|
|
error: "Config file not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let result = (do { open $config_path | from toml } | complete)
|
||
|
|
let passed = ($result.exit_code == 0)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print $" ✅ Provider config valid TOML: ($provider)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Provider config invalid TOML: ($provider)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Provider config valid TOML: ($provider)"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { $result.stderr } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-platform-config-exists [service: string, verbose: bool] {
|
||
|
|
let config_path = $"/Users/Akasha/project-provisioning/provisioning/platform/($service)/config.defaults.toml"
|
||
|
|
let exists = ($config_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print $" ✅ Platform config exists: ($service)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Platform config missing: ($service)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Platform config exists: ($service)"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { $"File not found: ($config_path)" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-platform-schema-exists [service: string, verbose: bool] {
|
||
|
|
let schema_path = $"/Users/Akasha/project-provisioning/provisioning/platform/($service)/config.schema.toml"
|
||
|
|
let exists = ($schema_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print $" ✅ Platform schema exists: ($service)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Platform schema missing: ($service)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Platform schema exists: ($service)"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { $"File not found: ($schema_path)" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-platform-config-valid [service: string, verbose: bool] {
|
||
|
|
let config_path = $"/Users/Akasha/project-provisioning/provisioning/platform/($service)/config.defaults.toml"
|
||
|
|
|
||
|
|
if not ($config_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: $"Platform config valid TOML: ($service)"
|
||
|
|
passed: false
|
||
|
|
error: "Config file not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let result = (do { open $config_path | from toml } | complete)
|
||
|
|
let passed = ($result.exit_code == 0)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print $" ✅ Platform config valid TOML: ($service)"
|
||
|
|
} else {
|
||
|
|
print $" ❌ Platform config invalid TOML: ($service)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: $"Platform config valid TOML: ($service)"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { $result.stderr } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-kms-config-exists [verbose: bool] {
|
||
|
|
let config_path = "/Users/Akasha/project-provisioning/provisioning/core/services/kms/config.defaults.toml"
|
||
|
|
let exists = ($config_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print " ✅ KMS config exists"
|
||
|
|
} else {
|
||
|
|
print " ❌ KMS config missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "KMS config exists"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { "KMS config file not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-kms-schema-exists [verbose: bool] {
|
||
|
|
let schema_path = "/Users/Akasha/project-provisioning/provisioning/core/services/kms/config.schema.toml"
|
||
|
|
let exists = ($schema_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print " ✅ KMS schema exists"
|
||
|
|
} else {
|
||
|
|
print " ❌ KMS schema missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "KMS schema exists"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { "KMS schema file not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-kms-accessor-functions [verbose: bool] {
|
||
|
|
let accessor_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/accessor.nu"
|
||
|
|
|
||
|
|
if not ($accessor_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "KMS accessor functions exist"
|
||
|
|
passed: false
|
||
|
|
error: "Accessor file not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $accessor_path)
|
||
|
|
let has_kms_functions = ($content | str contains "get-kms-")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_kms_functions {
|
||
|
|
print " ✅ KMS accessor functions exist"
|
||
|
|
} else {
|
||
|
|
print " ❌ KMS accessor functions missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "KMS accessor functions exist"
|
||
|
|
passed: $has_kms_functions
|
||
|
|
error: (if not $has_kms_functions { "No KMS accessor functions found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-kms-config-valid [verbose: bool] {
|
||
|
|
let config_path = "/Users/Akasha/project-provisioning/provisioning/core/services/kms/config.defaults.toml"
|
||
|
|
|
||
|
|
if not ($config_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "KMS config valid TOML"
|
||
|
|
passed: false
|
||
|
|
error: "Config file not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let result = (do { open $config_path | from toml } | complete)
|
||
|
|
let passed = ($result.exit_code == 0)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print " ✅ KMS config valid TOML"
|
||
|
|
} else {
|
||
|
|
print " ❌ KMS config invalid TOML"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "KMS config valid TOML"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { $result.stderr } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-templates-directory-exists [verbose: bool] {
|
||
|
|
let templates_path = "/Users/Akasha/project-provisioning/provisioning/config/templates"
|
||
|
|
let exists = ($templates_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print " ✅ Templates directory exists"
|
||
|
|
} else {
|
||
|
|
print " ❌ Templates directory missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Templates directory exists"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { "Templates directory not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-workspace-templates-exist [verbose: bool] {
|
||
|
|
let templates = [
|
||
|
|
"workspace-provisioning.yaml.template"
|
||
|
|
"provider-aws.toml.template"
|
||
|
|
"provider-local.toml.template"
|
||
|
|
"user-context.yaml.template"
|
||
|
|
]
|
||
|
|
|
||
|
|
let base_path = "/Users/Akasha/project-provisioning/provisioning/config/templates"
|
||
|
|
mut all_exist = true
|
||
|
|
|
||
|
|
for template in $templates {
|
||
|
|
let template_path = ($base_path | path join $template)
|
||
|
|
if not ($template_path | path exists) {
|
||
|
|
$all_exist = false
|
||
|
|
if $verbose {
|
||
|
|
print $" ❌ Template missing: ($template)"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if $verbose and $all_exist {
|
||
|
|
print " ✅ All workspace templates exist"
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "All workspace templates exist"
|
||
|
|
passed: $all_exist
|
||
|
|
error: (if not $all_exist { "Some templates missing" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-workspace-init-function [verbose: bool] {
|
||
|
|
let init_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/workspace/init.nu"
|
||
|
|
|
||
|
|
if not ($init_path | path exists) {
|
||
|
|
if $verbose {
|
||
|
|
print " ❌ Workspace init module missing"
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
name: "Workspace init module exists"
|
||
|
|
passed: false
|
||
|
|
error: "Init module not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $init_path)
|
||
|
|
let has_init = ($content | str contains "workspace-init")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_init {
|
||
|
|
print " ✅ Workspace init function exists"
|
||
|
|
} else {
|
||
|
|
print " ❌ Workspace init function missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Workspace init function exists"
|
||
|
|
passed: $has_init
|
||
|
|
error: (if not $has_init { "workspace-init function not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-config-defaults-not-loaded [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "config.defaults.toml NOT loaded at runtime"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let no_defaults_path = not ($content | str contains "get-defaults-config-path")
|
||
|
|
let has_workspace = ($content | str contains "get-active-workspace")
|
||
|
|
|
||
|
|
let passed = $no_defaults_path and $has_workspace
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print " ✅ config.defaults.toml NOT loaded (correct)"
|
||
|
|
} else {
|
||
|
|
print " ❌ config.defaults.toml may still be loaded"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "config.defaults.toml NOT loaded at runtime"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Config loader may still load defaults" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-user-context-template [verbose: bool] {
|
||
|
|
let template_path = "/Users/Akasha/project-provisioning/provisioning/config/templates/user-context.yaml.template"
|
||
|
|
let exists = ($template_path | path exists)
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $exists {
|
||
|
|
print " ✅ User context template exists"
|
||
|
|
} else {
|
||
|
|
print " ❌ User context template missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "User context template exists"
|
||
|
|
passed: $exists
|
||
|
|
error: (if not $exists { "Template not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-context-functions-exist [verbose: bool] {
|
||
|
|
let contexts_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/main_provisioning/contexts.nu"
|
||
|
|
|
||
|
|
if not ($contexts_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Context functions exist"
|
||
|
|
passed: false
|
||
|
|
error: "Contexts module not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $contexts_path)
|
||
|
|
let has_create = ($content | str contains "create-workspace-context")
|
||
|
|
let has_active = ($content | str contains "set-workspace-active")
|
||
|
|
let has_list = ($content | str contains "list-workspace-contexts")
|
||
|
|
|
||
|
|
let passed = $has_create and $has_active and $has_list
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print " ✅ Context functions exist"
|
||
|
|
} else {
|
||
|
|
print " ❌ Some context functions missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Context functions exist"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Missing context functions" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-active-workspace-detection [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Active workspace detection implemented"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_detection = ($content | str contains "get-active-workspace")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_detection {
|
||
|
|
print " ✅ Active workspace detection implemented"
|
||
|
|
} else {
|
||
|
|
print " ❌ Active workspace detection missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Active workspace detection implemented"
|
||
|
|
passed: $has_detection
|
||
|
|
error: (if not $has_detection { "get-active-workspace function not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-loader-hierarchy [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Config loader hierarchy correct"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_workspace = ($content | str contains "workspace/{name}/config/provisioning.yaml")
|
||
|
|
let has_providers = ($content | str contains "config/providers")
|
||
|
|
let has_platform = ($content | str contains "config/platform")
|
||
|
|
|
||
|
|
let passed = $has_workspace and $has_providers and $has_platform
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $passed {
|
||
|
|
print " ✅ Config loader hierarchy correct"
|
||
|
|
} else {
|
||
|
|
print " ❌ Config loader hierarchy incomplete"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Config loader hierarchy correct"
|
||
|
|
passed: $passed
|
||
|
|
error: (if not $passed { "Hierarchy not fully implemented" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-yaml-support [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "YAML format support"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_yaml = ($content | str contains "from yaml")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_yaml {
|
||
|
|
print " ✅ YAML format support"
|
||
|
|
} else {
|
||
|
|
print " ❌ YAML format support missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "YAML format support"
|
||
|
|
passed: $has_yaml
|
||
|
|
error: (if not $has_yaml { "YAML parsing not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-user-context-overrides [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "User context overrides implemented"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_overrides = ($content | str contains "apply-user-context-overrides")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_overrides {
|
||
|
|
print " ✅ User context overrides implemented"
|
||
|
|
} else {
|
||
|
|
print " ❌ User context overrides missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "User context overrides implemented"
|
||
|
|
passed: $has_overrides
|
||
|
|
error: (if not $has_overrides { "Override function not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-interpolation-functions [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Interpolation functions exist"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_interpolate = ($content | str contains "interpolate-config")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_interpolate {
|
||
|
|
print " ✅ Interpolation functions exist"
|
||
|
|
} else {
|
||
|
|
print " ❌ Interpolation functions missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Interpolation functions exist"
|
||
|
|
passed: $has_interpolate
|
||
|
|
error: (if not $has_interpolate { "Interpolation not implemented" } else { null })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-workspace-path-variable [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "workspace.path variable supported"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_variable = ($content | str contains "{{workspace.path}}")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_variable {
|
||
|
|
print " ✅ workspace.path variable supported"
|
||
|
|
} else {
|
||
|
|
print " ⚠️ workspace.path variable may be implicit"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# This might be handled implicitly, so just warn
|
||
|
|
{
|
||
|
|
name: "workspace.path variable supported"
|
||
|
|
passed: true
|
||
|
|
error: null
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
def test-env-variable-interpolation [verbose: bool] {
|
||
|
|
let loader_path = "/Users/Akasha/project-provisioning/provisioning/core/nulib/lib_provisioning/config/loader.nu"
|
||
|
|
|
||
|
|
if not ($loader_path | path exists) {
|
||
|
|
return {
|
||
|
|
name: "Environment variable interpolation"
|
||
|
|
passed: false
|
||
|
|
error: "Config loader not found"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let content = (open $loader_path)
|
||
|
|
let has_env_interpolation = ($content | str contains "interpolate-env-variables")
|
||
|
|
|
||
|
|
if $verbose {
|
||
|
|
if $has_env_interpolation {
|
||
|
|
print " ✅ Environment variable interpolation"
|
||
|
|
} else {
|
||
|
|
print " ❌ Environment variable interpolation missing"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
name: "Environment variable interpolation"
|
||
|
|
passed: $has_env_interpolation
|
||
|
|
error: (if not $has_env_interpolation { "Env interpolation not found" } else { null })
|
||
|
|
}
|
||
|
|
}
|