Files
Pulse/internal/api/oidc_ca_revalidation_linux_test.go
pulse-triage[bot] 53229f0f8c Revalidate OIDC CA paths through the initialization reader
Use the existing normalized, regular-file and size-checked reader for cached-provider CA hashes as well as initial trust setup. Accepted padded or cleaned paths must not rediscover the IdP on every native request or reject a valid callback when discovery is temporarily unavailable. Replaced unsafe trust files fail closed before further provider work.

Exercise native GET/POST logins and signed callbacks over real local TLS, discovery outages, exact hashes and limits, changed trust, restoration and bounded FIFO refusal. Preserve blank paths, provider lifecycle resets, nonce/PKCE, replay and session checks.

Contract-Neutral: Enforce the existing normalized regular-file/4 MiB SSO trust boundary and matching-native-provider lifecycle; no auth API, trust policy, stored configuration or credential-format change.
Change-source: pulse-maintainer
2026-11-17 00:05:06 +00:00

48 lines
1.4 KiB
Go

//go:build linux
package api
import (
"context"
"errors"
"os"
"os/exec"
"path/filepath"
"syscall"
"testing"
"time"
"github.com/rcourtman/pulse-go-rewrite/internal/securityutil"
)
// A subprocess bounds the regression: reverting to os.ReadFile must fail this
// test promptly, not leave a blocked FIFO reader in the package's process.
func TestOIDCCABundleRevalidationRefusesFIFO(t *testing.T) {
path := filepath.Join(t.TempDir(), "trust.pipe")
if err := syscall.Mkfifo(path, 0600); err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
defer cancel()
child := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestOIDCCABundleRevalidationFIFOChild$", "-test.timeout=8s")
child.Env = append(os.Environ(), "PULSE_TEST_OIDC_CA_FIFO="+path)
output, err := child.CombinedOutput()
if ctx.Err() != nil {
t.Fatalf("CA revalidation did not reject the FIFO within its subprocess deadline: %v", ctx.Err())
}
if err != nil {
t.Fatalf("FIFO refusal subprocess: %v\n%s", err, output)
}
}
func TestOIDCCABundleRevalidationFIFOChild(t *testing.T) {
path := os.Getenv("PULSE_TEST_OIDC_CA_FIFO")
if path == "" {
t.Skip("only executed by the bounded FIFO subprocess")
}
hash, err := hashCABundle(path)
if hash != "" || !errors.Is(err, securityutil.ErrUnsafeStorageFile) {
t.Fatal("FIFO did not return the existing unsafe-file refusal")
}
}