def test_filter_by_params_post(): f1 = context.gen_filter_by_params(context.cmp_contains, 'Session') f2 = context.gen_filter_by_params(context.cmp_contains, 'Cookie', context.cmp_contains, 'CookieVal') r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.raw_data = 'foo=bar' assert not f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.raw_data = 'Session=bar' assert f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.raw_data = 'Session=bar&Cookie=foo' assert f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.raw_data = 'Session=bar&CookieThing=CookieValue' assert f1(r) assert f2(r)
def test_filter_by_params_post(): f1 = context.gen_filter_by_params(['ct', 'Session']) f2 = context.gen_filter_by_params(['ct', 'Cookie', 'ct', 'CookieVal']) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.body = 'foo=bar' assert not f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.body = 'Session=bar' assert f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.body = 'Session=bar&Cookie=foo' assert f1(r) assert not f2(r) r = Request(('GET / HTTP/1.1\r\n' 'Content-Type: application/x-www-form-urlencoded\r\n\r\n')) r.body = 'Session=bar&CookieThing=CookieValue' assert f1(r) assert f2(r)
def test_filter_by_params_get(): f1 = context.gen_filter_by_params(['ct', 'Session']) f2 = context.gen_filter_by_params(['ct', 'Cookie', 'ct', 'CookieVal']) r = Request('GET / HTTP/1.1\r\n\r\n') assert not f1(r) assert not f2(r) r = Request('GET /?Session=foo HTTP/1.1\r\n\r\n') assert f1(r) assert not f2(r) r = Request('GET /?Session=foo&CookieThing=Fail HTTP/1.1\r\n\r\n') assert f1(r) assert not f2(r) r = Request('GET /?Session=foo&CookieThing=CookieValue HTTP/1.1\r\n\r\n') assert f1(r) assert f2(r)