437aab39b4
P0a1 — Re-architecture Foundation (path resolver + config demotion). Path resolver (REQ-070, R-002): - internal/paths/paths.go: 23 functions for the multi-namespace layout (Root/ClusterDir/NamespaceDir/NS*/DefaultNamespace/CA/MasterKey/CacheDB/ Txn/Peers/KnownHosts/SSH/Server/Config). Honors $ORCA_HOME. 100% coverage. - internal/certpaths/certpaths.go: refactored as thin shim delegating to paths, preserving the v0.8 flat-layout API for backward compat during the dual-write window (REQ-090). Package doc explains the v0.10-P14 migration plan. certpaths deleted after v0.10-P14. 100% coverage. Config demotion (REQ-069, R-014): - internal/config/markdown.go: minimal hand-rolled YAML frontmatter parser (no new dep — yaml.v3 not in go.mod). Returns same *Config struct as HCL. - internal/config/config.go: renamed Load body to LoadHCL (// Deprecated per R-013), added dispatcher Load() routing on extension (.hcl->HCL, .md->Markdown, .yaml->Markdown). Signature preserved so root.go unchanged. - dispatch_test.go + markdown_test.go: 89.8% coverage on config package. Known_hosts flock (REQ-063, deferred P1 from REVIEW_v0.8 A2): - internal/security/flock.go: stdlib syscall.Flock advisory lock helper. - internal/proxmox/bootstrap.go: TOFUHostKeyCallback capture + ResetHostKey both acquire the flock before read-modify-write on known_hosts. Prevents concurrent writers under v0.9 parallel SSH fan-out. 3 flock tests. CA migration spec (grill C-07): - .ciagent/CA_MIGRATION_SPEC_v0.9.md: Option A (preserve trust root, RECOMMENDED) vs Option B (forced re-bootstrap). Pre-flight checks, migration steps, rollback, post-migration invariants, spike plan. Verification: build pass, 17/17 Go packages pass, 20/20 bats pass, gofmt clean, go vet clean, verify-reqs 90 consistent. Coverage: paths 100%, certpaths 100%, config 89.8%, emit covered. ---ci--- project: orca phase: P0a1 milestone: v0.9 status: execute ---/ci---
62 lines
1.0 KiB
Go
62 lines
1.0 KiB
Go
package security
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestFlock_acquireAndRelease(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "test.lock")
|
|
|
|
release, err := Flock(path)
|
|
if err != nil {
|
|
t.Fatalf("Flock: %v", err)
|
|
}
|
|
if _, statErr := os.Stat(path); statErr != nil {
|
|
t.Fatalf("lock file not created: %v", statErr)
|
|
}
|
|
release()
|
|
}
|
|
|
|
func TestFlock_reentrantAfterRelease(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "test.lock")
|
|
|
|
r1, err := Flock(path)
|
|
if err != nil {
|
|
t.Fatalf("first Flock: %v", err)
|
|
}
|
|
r1()
|
|
|
|
r2, err := Flock(path)
|
|
if err != nil {
|
|
t.Fatalf("second Flock after release: %v", err)
|
|
}
|
|
r2()
|
|
}
|
|
|
|
func TestFlock_concurrentBlocks(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "test.lock")
|
|
|
|
r1, err := Flock(path)
|
|
if err != nil {
|
|
t.Fatalf("first Flock: %v", err)
|
|
}
|
|
defer r1()
|
|
|
|
done := make(chan error, 1)
|
|
go func() {
|
|
_, err := Flock(path)
|
|
done <- err
|
|
}()
|
|
|
|
select {
|
|
case <-done:
|
|
t.Fatal("second Flock should block while first holds the lock")
|
|
default:
|
|
}
|
|
}
|