/**
* HVAC Community Events - AJAX Security Comprehensive Test Suite
*
* Tests for AJAX endpoint security including:
* - Nonce verification on all AJAX endpoints
* - Rate limiting implementation
* - Input sanitization and validation
* - Authorization checks and access control
* - CSRF protection mechanisms
* - Error handling and information disclosure
*
* AJAX SECURITY AREAS TESTED:
* 1. Nonce verification and CSRF protection
* 2. Rate limiting and brute force protection
* 3. Input sanitization and SQL injection prevention
* 4. Authorization and access control
* 5. Error handling and information disclosure
* 6. Session management and authentication
*
* @package HVAC_Community_Events
* @since 2.0.0
*/
const { test, expect } = require('@playwright/test');
const crypto = require('crypto');
// AJAX Security test configuration
const AJAX_SECURITY_CONFIG = {
BASE_URL: process.env.BASE_URL || 'http://localhost:8080',
AJAX_ENDPOINTS: {
// WordPress core AJAX endpoints
ADMIN_AJAX: '/wp-admin/admin-ajax.php',
REST_API: '/wp-json/',
// Plugin-specific AJAX endpoints (discovered dynamically)
PLUGIN_ENDPOINTS: [
'/wp-json/hvac/v1/',
'/wp-admin/admin-ajax.php?action=hvac_',
]
},
// Test payloads for various attack vectors
ATTACK_PAYLOADS: {
// SQL Injection payloads
SQL_INJECTION: [
"' OR 1=1 --",
"'; DROP TABLE wp_users; --",
"' UNION SELECT * FROM wp_options --",
"%27%20OR%201=1%20--",
"1' UNION SELECT user_pass FROM wp_users WHERE user_login='admin'--"
],
// XSS payloads
XSS_INJECTION: [
"",
"javascript:alert('XSS')",
"
",
"