"ddos challenge" style script #4
1 changed files with 44 additions and 0 deletions
Add ngx.req function mocks to all test classes
Fixed missing ngx.req.read_body, ngx.req.get_post_args, and ngx.req.get_headers function mocks that were causing test errors. These functions are required by the DDoS protection module to handle POST requests and cookie validation. All four test classes now properly initialize these mocks: - TestDDoSProtectionChallenge - TestDDoSProtectionChallengePaths - TestDDoSProtectionChallengeQuestion - TestDDoSProtectionChallengePow
commit
4ee83a023a
|
|
@ -39,6 +39,17 @@ function TestDDoSProtectionChallenge:setup()
|
|||
-- Mock ngx.time for consistent testing
|
||||
ngx.time = function() return 1000000 end
|
||||
|
||||
-- Add missing ngx.req functions
|
||||
ngx.req.read_body = function() end
|
||||
ngx.req.get_post_args = function()
|
||||
return ngx._post_args or {}
|
||||
end
|
||||
ngx.req.get_headers = function()
|
||||
return ngx._headers or {}
|
||||
end
|
||||
ngx.header = {}
|
||||
ngx.var.request_method = 'GET'
|
||||
|
||||
-- Setup module manually (can't use setupTest because it calls resetNgx)
|
||||
local ctx = require('ctx')
|
||||
local config = require('config')
|
||||
|
|
@ -224,6 +235,17 @@ function TestDDoSProtectionChallengePaths:setup()
|
|||
|
||||
ngx.time = function() return 1000000 end
|
||||
|
||||
-- Add missing ngx.req functions
|
||||
ngx.req.read_body = function() end
|
||||
ngx.req.get_post_args = function()
|
||||
return ngx._post_args or {}
|
||||
end
|
||||
ngx.req.get_headers = function()
|
||||
return ngx._headers or {}
|
||||
end
|
||||
ngx.header = {}
|
||||
ngx.var.request_method = 'GET'
|
||||
|
||||
-- Setup module manually
|
||||
local ctx = require('ctx')
|
||||
local config = require('config')
|
||||
|
|
@ -381,6 +403,17 @@ function TestDDoSProtectionChallengeQuestion:setup()
|
|||
|
||||
ngx.time = function() return 1000000 end
|
||||
|
||||
-- Add missing ngx.req functions
|
||||
ngx.req.read_body = function() end
|
||||
ngx.req.get_post_args = function()
|
||||
return ngx._post_args or {}
|
||||
end
|
||||
ngx.req.get_headers = function()
|
||||
return ngx._headers or {}
|
||||
end
|
||||
ngx.header = {}
|
||||
ngx.var.request_method = 'GET'
|
||||
|
||||
-- Setup module manually
|
||||
local ctx = require('ctx')
|
||||
local config = require('config')
|
||||
|
|
@ -506,6 +539,17 @@ function TestDDoSProtectionChallengePow:setup()
|
|||
|
||||
ngx.time = function() return 1000000 end
|
||||
|
||||
-- Add missing ngx.req functions
|
||||
ngx.req.read_body = function() end
|
||||
ngx.req.get_post_args = function()
|
||||
return ngx._post_args or {}
|
||||
end
|
||||
ngx.req.get_headers = function()
|
||||
return ngx._headers or {}
|
||||
end
|
||||
ngx.header = {}
|
||||
ngx.var.request_method = 'GET'
|
||||
|
||||
-- Setup module manually
|
||||
local ctx = require('ctx')
|
||||
local config = require('config')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue