Files
opencloud/tests/ocwrapper/wrapper/wrapper.go
T
Viktor Scharf 0d42e7228f test: get the audit records from the ocwrapper (#4174)
The audit log tests read the audit records from a copy of the server
output, which the CI wrote with "| tee" to a file given to the tests in
AUDIT_RECORDS_FILE. The ocwrapper reads the server output anyway: it now
keeps the audit records, and returns them on GET /audit (DELETE /audit
clears them). The tests clear them when a scenario starts and fetch them
from there, so they need no extra setup in the CI or locally.

Assisted-by: Claude Code:claude-opus-5-5
2026-12-01 14:46:25 +01:00

41 lines
858 B
Go

package wrapper
import (
"fmt"
"net/http"
"ocwrapper/common"
"ocwrapper/log"
"ocwrapper/opencloud/config"
"ocwrapper/wrapper/handlers"
)
func Start(port string) {
defer common.Wg.Done()
if port == "" {
port = config.Get("port")
}
httpServer := &http.Server{
Addr: ":" + port,
}
var mux = http.NewServeMux()
mux.HandleFunc("/", http.NotFound)
mux.HandleFunc("/config", handlers.SetEnvHandler)
mux.HandleFunc("/rollback", handlers.RollbackHandler)
mux.HandleFunc("/command", handlers.CommandHandler)
mux.HandleFunc("/stop", handlers.StopOpencloudHandler)
mux.HandleFunc("/start", handlers.StartOpencloudHandler)
mux.HandleFunc("/audit", handlers.AuditHandler)
httpServer.Handler = mux
log.Println(fmt.Sprintf("Starting ocwrapper on port %s...", port))
err := httpServer.ListenAndServe()
if err != nil {
log.Panic(err)
}
}