openresty / test-nginx

Data-driven test scaffold for Nginx C module and OpenResty Lua library development
http://search.cpan.org/dist/Test-Nginx
438 stars 105 forks source link

Faking ngx.var.remote_addr #155

Open bluemmb opened 1 year ago

bluemmb commented 1 year ago

Hi.

I'm testing some parts of my code which rely on ngx.var.remote_addr. Also I need to fake this value sometimes, like testing a rate limiter in which keys are generated from remote_addr value.

Is there any way to fake the values like ngx.var.remote_addr, ngx.var.host or ... for testing purposes?

zhuizhuhaomeng commented 1 year ago

There is no way to fake the ngx.var.remote_addr. you can bind the local address when sending the request