Natakarica.py failing test

The test “test_http400_when_amount_unusual” isn’t included in the original code and there’s no indication of what it’s testing, how are we supposed to complete this task?

Hey James, I can see you have already solved the challenge :clap: so I will not give away specific hints.

Two things for other reading this:

  1. If you want to effectively fix this challenge read about Patriot bug.
  2. If you are stuck, there is a hint in the level/challenge page.

Yeah, I was more raising the fact that it’s impossible to solve the challenge locally, which isn’t explained in any of the prompts. Could it be made clearer that participants will have to discover the tests through inference? It’s incredibly confusing.

In the Start Here challenge we can read challenges have different level of complexity. Some don’t come with full set of tests for a reason.

Challenges with restriction on the number of attempts,
Challenges with local copy of security tests (trivial mode),
Challenges with no local copy of security tests but tests outputs can been seen when commits are tested, and
Challenges with no local copy of security tests and tests outputs (hacker mode).

Also there is an explicit failing test:

def test_complete_security_tests(self):`
        self.assertEqual(0, 1)`

Also there is a hint in the challenge description about
Got stuck? Push a commit and run the tests on the server. Look at the test outputs. They will put you on the right track.

Please let me know if you think there is any better way to make it clearer.

I guess I missed that part in the first exercise and it felt strange being an “easy” task with intentionally obscured tests on a learning platform. Thanks for the clarification.

Glad to see this cleared up
Keep crushing champ!

1 Like

Well, this task is not clear at all :slight_smile:

Even when you fix the “vulnerability” tests are failing:

- FAIL: test_http400_when_amount_unusual (program.test_security.ProgramSecurityTestCase)

- ----------------------------------------------------------------------

- Traceback (most recent call last):

- File "/drone/src/code/src/program/test_security.py", line 24, in test_http400_when_amount_unusual

- self.assertEqual(res.status_code, 400)

- AssertionError: 200 != 400

Simple fix: Using decimal instead of default float and some magic in the view.

And, of course, local test is bugged:

    def test_complete_security_tests(self):
        self.assertEqual(0, 1)

This one will always fail…

The local test intentionally includes the test that will fail, this indicates that there will be additional tests run against your patched code when the repository is pushed.
If you want the security test to pass locally simply comment out the lines or replace the 0 with 1.

I have just confirmed that the auto-tests when the code is pushed are working as expected.

By what you have said about how you fixed your code is certainly on the right track. A hint: Have a read of Learn - SecDim

1 Like