Closed nrathaus closed 1 week ago
@nrathaus I like this way of testing and thanks for this recommendation. Cool way to find bugs within the code, however noticed there is a bit of a learning curve if others will want to join writing tests like these. Feel free to add more if you want.
For me this test fails, though.
test_tests.py::test_test_rfi PASSED test_tests.py::test_test_cmd_injection FAILED
Failed with message: We are expecting 2 'requests', got: 7
If I understand this correctly, this test fails, because test functions are used within the same context, so if we initialize stats dictionary and both functions consume it, stats will be shared and accessible across the board.
In other words, when we first run test_test_rfi
, stats["requests"] will be 5 as we send 5 RFI requests.
Afterwards, inside test_test_cmd_injection
, then number of requests would indeed be 2, (without previous RFI tests), but with the previous ones we should check if stats["requests"] == 5+2. Same thing for stats["vulns"].
I fixed the issue you raised: https://github.com/hansmach1ne/LFImap/pull/103
I recreated the branch to make it a bit easier to read
I did the following changes:
pwn
import - was causing a loopinit
to prevent the import from accessingargs
which is preventing us from usingpytest
(as args cannot be externally provided)If this flow is ok, let me know, I will add more pytest
I already found one bug using the pytest related to the rfi bug you already fixed