Skip to content

Conversation

@aaronwalker
Copy link
Member

@aaronwalker aaronwalker commented May 23, 2025

Add Tests for WAF Component

This PR adds a comprehensive test suite for the WAF Classic component, including both cftest configurations and RSpec tests.

Changes

  • Added test configuration for WAF Classic resources
  • Added RSpec test suite
  • Added GitHub Actions workflow
  • Fixed test configuration to prevent duplication
  • Updated tests to match WAF Classic resource structure

Test Coverage

The test suite covers:

  • Component compilation validation
  • IPSet configuration and properties
  • WAF Rule configuration
  • WebACL properties and rules
  • Output validation

Testing

To run the tests locally:

# Run all tests
VALIDATE=--no-validate rspec

# Run specific test file
VALIDATE=--no-validate rspec spec/default_spec.rb

# Run cfhighlander test
cfhighlander cftest --tests tests/default.test.yaml

Test Configuration Example

control_ipset:
  - name: wafrBlacklistIpSet
    ipsetdescriptors:
      - type: IPV4
        value: 192.0.2.44/32

wafrules:
  - ruleid: wafrIPBlockRule
    predicates:
      - conditionName: wafrBlacklistIpSet
        negated: false
        type: IPMatch

wafacl:
  name: test-waf
  metricName: TestWAF
  rules:
    - ruleid: wafrIPBlockRule
      action: BLOCK
      priority: 1

Aaron Walker added 2 commits May 23, 2025 17:28
Added test suite including:
- Default test configuration for regional WAF
- CloudFront WAF test configuration
- RSpec tests for both configurations
- GitHub Actions workflow

Tests cover:
- Component compilation
- WAF ACL properties
- Rule configurations
- Rule actions and statements
- Output validation
- Update test configuration to match WAF Classic format
- Clear default config to prevent duplication
- Update RSpec tests to match WAF Classic resource structure
- Fix resource property validation
- Add proper test documentation
@aaronwalker aaronwalker deleted the feature/add-tests branch May 26, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants