by jlgaddis · 10y ago · 0 comments
http://www.nytimes.com/interactive/2015/07/03/upshot/a-quick...
You're totally right that you should have a unit test that verifies failure with invalid credentials, not just success with valid credentials. But a lot of programmers are not as smart as you are here!
> verifies that known invalid credentials don't permit access
you need a second test: "use invalid credentials, then try to download file, expect failure", i.e. a sequence of actions in a single test.
That test is evidently missing from my heating system's web interface, which has exactly this problem. There's a box to type in a PIN code, and it lets you proceed / retry correctly. But it's not necessary to bother with this, you can change the temperature without authenticating if you know the URL.
I actually uncovered a bug in a JWT library once when I wrote a test for my application to verify that an invalid token would be rejected.
Let's just say there was no corresponding test in the libraries test suite.