Skip to content

Latest commit

 

History

History
130 lines (93 loc) · 2.74 KB

File metadata and controls

130 lines (93 loc) · 2.74 KB

ClawShield Test Suite - Quick Reference

📊 Test Status: ✅ ALL PASSING

Coverage: 96.0% overall | Tests: 89 unit tests | Race Conditions: None


Quick Start

Run All Tests

# Basic test run
go test -v ./proxy/internal/... ./firewall/internal/...

# With coverage
go test -cover ./...

# With race detection
go test -race -v ./...

Test by Component

# Policy engine (91.2% coverage)
go test -v ./proxy/internal/engine/

# Config loader (100% coverage)
go test -v ./proxy/internal/config/

# Hash functions (92.9% coverage)
go test -v ./proxy/internal/audit/hashlined/

# iptables generator (100% coverage)
go test -v ./firewall/internal/compile/iptables/

# SQLite writer
go test -v ./proxy/internal/audit/sqlite/

# Integration tests
go test -tags=integration -v ./integration/...

Test Files Created

Unit Tests ✅

  • proxy/internal/engine/evaluator_test.go - Policy evaluation logic
  • proxy/internal/config/loader_test.go - YAML policy loading
  • proxy/internal/audit/hashlined/hash_test.go - Sensitive data hashing
  • proxy/internal/audit/sqlite/writer_test.go - Async audit writer
  • firewall/internal/compile/iptables/generator_test.go - Firewall rule generation

Integration Tests ✅

  • integration/proxy_integration_test.go - Full proxy flow + audit
  • integration/firewall_integration_test.go - Firewall policy to rules

Coverage by Package

Package Coverage Status
engine 91.2%
config 100.0%
hashlined 92.9%
iptables 100.0%
sqlite Ready

Key Test Scenarios Covered

Policy Engine

  • ✅ Allow/deny decisions
  • ✅ Allowlist/denylist enforcement
  • ✅ Argument filtering (regex)
  • ✅ Domain allowlists (wildcards)
  • ✅ Timeout handling
  • ✅ Edge cases & invalid input

Config Loader

  • ✅ Valid/invalid YAML
  • ✅ Default value application
  • ✅ Large policies (1000+ entries)
  • ✅ Error handling
  • ✅ Special characters

Hash Functions

  • ✅ Sensitive field redaction
  • ✅ Hash consistency
  • ✅ Case-insensitive matching
  • ✅ Collision resistance

iptables Generator

  • ✅ Rule generation & ordering
  • ✅ DNS resolution
  • ✅ Error handling
  • ✅ IPv4/IPv6 support

Audit Writer

  • ✅ Batch processing
  • ✅ Concurrent writes
  • ✅ Flush intervals
  • ✅ Data integrity

Generate Coverage Report

# Generate coverage file
go test -coverprofile=coverage.out ./...

# View in terminal
go tool cover -func=coverage.out

# Generate HTML report
go tool cover -html=coverage.out -o coverage.html

Full Report

See clawshield-test-report.md for comprehensive test results, recommendations, and analysis.

Last Updated: 2026-02-09