Minor fixes

This commit is contained in:
2025-05-17 12:48:37 -04:00
parent b33127bd34
commit ce6f2ce29d
9 changed files with 27 additions and 34 deletions

View File

@ -12,7 +12,7 @@ import (
"testing"
"time"
"kat-system/internal/pki"
"git.dws.rip/dubey/kat/internal/pki"
)
func TestServerWithMTLS(t *testing.T) {
@ -31,7 +31,7 @@ func TestServerWithMTLS(t *testing.T) {
// Generate CA
caKeyPath := filepath.Join(tempDir, "ca.key")
caCertPath := filepath.Join(tempDir, "ca.crt")
if err := pki.GenerateCA(caKeyPath, caCertPath, "KAT Test CA", 24*time.Hour); err != nil {
if err := pki.GenerateCA(tempDir, caKeyPath, caCertPath); err != nil {
t.Fatalf("Failed to generate CA: %v", err)
}
@ -39,7 +39,7 @@ func TestServerWithMTLS(t *testing.T) {
serverKeyPath := filepath.Join(tempDir, "server.key")
serverCSRPath := filepath.Join(tempDir, "server.csr")
serverCertPath := filepath.Join(tempDir, "server.crt")
if err := pki.GenerateCertificateRequest("server.test", serverKeyPath, serverCSRPath); err != nil {
if err := pki.GenerateCertificateRequest("localhost", serverKeyPath, serverCSRPath); err != nil {
t.Fatalf("Failed to generate server CSR: %v", err)
}
if err := pki.SignCertificateRequest(caKeyPath, caCertPath, serverCSRPath, serverCertPath, 24*time.Hour); err != nil {
@ -58,7 +58,7 @@ func TestServerWithMTLS(t *testing.T) {
}
// Create and start server
server, err := NewServer("localhost:0", serverCertPath, serverKeyPath, caCertPath)
server, err := NewServer("localhost:8443", serverCertPath, serverKeyPath, caCertPath)
if err != nil {
t.Fatalf("Failed to create server: %v", err)
}
@ -76,7 +76,7 @@ func TestServerWithMTLS(t *testing.T) {
}()
// Wait for server to start
time.Sleep(100 * time.Millisecond)
time.Sleep(250 * time.Millisecond)
// Load CA cert
caCert, err := os.ReadFile(caCertPath)