"ddos challenge" style script #4
1 changed files with 12 additions and 0 deletions
Fix test setup: call resetNgx() before accessing ngx global
All test setup methods were trying to access ngx.shared before the ngx global was initialized, causing 'attempt to index global ngx (a nil value)' errors. Fixed by calling resetNgx() at the start of each setup() method to ensure the ngx global exists before setting up ngx.shared and other mock properties.
commit
4cbd4e04ad
|
|
@ -27,6 +27,9 @@ local function createMockSharedDict()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TestDDoSProtectionChallenge:setup()
|
function TestDDoSProtectionChallenge:setup()
|
||||||
|
-- First reset ngx to get the base ngx object
|
||||||
|
resetNgx()
|
||||||
|
|
||||||
-- Create mock shared dictionaries
|
-- Create mock shared dictionaries
|
||||||
ngx.shared = {
|
ngx.shared = {
|
||||||
aproxy_bans = createMockSharedDict(),
|
aproxy_bans = createMockSharedDict(),
|
||||||
|
|
@ -206,6 +209,9 @@ end
|
||||||
TestDDoSProtectionChallengePaths = {}
|
TestDDoSProtectionChallengePaths = {}
|
||||||
|
|
||||||
function TestDDoSProtectionChallengePaths:setup()
|
function TestDDoSProtectionChallengePaths:setup()
|
||||||
|
-- First reset ngx to get the base ngx object
|
||||||
|
resetNgx()
|
||||||
|
|
||||||
-- Create mock shared dictionaries
|
-- Create mock shared dictionaries
|
||||||
ngx.shared = {
|
ngx.shared = {
|
||||||
aproxy_bans = createMockSharedDict(),
|
aproxy_bans = createMockSharedDict(),
|
||||||
|
|
@ -352,6 +358,9 @@ end
|
||||||
TestDDoSProtectionChallengeQuestion = {}
|
TestDDoSProtectionChallengeQuestion = {}
|
||||||
|
|
||||||
function TestDDoSProtectionChallengeQuestion:setup()
|
function TestDDoSProtectionChallengeQuestion:setup()
|
||||||
|
-- First reset ngx to get the base ngx object
|
||||||
|
resetNgx()
|
||||||
|
|
||||||
ngx.shared = {
|
ngx.shared = {
|
||||||
aproxy_bans = createMockSharedDict(),
|
aproxy_bans = createMockSharedDict(),
|
||||||
aproxy_tokens = createMockSharedDict()
|
aproxy_tokens = createMockSharedDict()
|
||||||
|
|
@ -464,6 +473,9 @@ end
|
||||||
TestDDoSProtectionChallengePow = {}
|
TestDDoSProtectionChallengePow = {}
|
||||||
|
|
||||||
function TestDDoSProtectionChallengePow:setup()
|
function TestDDoSProtectionChallengePow:setup()
|
||||||
|
-- First reset ngx to get the base ngx object
|
||||||
|
resetNgx()
|
||||||
|
|
||||||
ngx.shared = {
|
ngx.shared = {
|
||||||
aproxy_bans = createMockSharedDict(),
|
aproxy_bans = createMockSharedDict(),
|
||||||
aproxy_tokens = createMockSharedDict()
|
aproxy_tokens = createMockSharedDict()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue