Sandbox reviewboard.accounts.AuthBackend
Review Request #6399 — Created Oct. 4, 2014 and submitted
Extensions that create an AuthBackend subclass (using the AuthBackendHook) can throw exceptions inside Reviewboard. The parts of Reviewboard that call those methods have been sandboxed.
Now when an AuthBackend subclass from an extension throws an exception; Reviewboard logs the errors with enough information to find which method in the AuthBackend subclass threw the exception.
Unit tests have been written to make sure that functions from an AuthBackend subclass have been called, and when an exception is thrown it gets logged.
The tests fail without the sanboxing, and succeed with it.
Description | From | Last Updated |
---|---|---|
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 5 E303 too many blank lines (2) |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 80 E501 line too long (105 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (111 > 79 characters) |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 5 E303 too many blank lines (2) |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 31 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (87 > 79 characters) |
reviewbot | |
Col: 31 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (87 > 79 characters) |
reviewbot | |
Col: 31 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 5 E303 too many blank lines (2) |
reviewbot | |
Can you include the backend name in here? Right now it's not possible to know which backend is failing from … |
david | |
Here too? |
david | |
Here too? |
david | |
Here too? |
david | |
There should also be a blank line here. Undo this. |
brennie | |
There should be 2 blank lines between classes. Undo this. |
brennie | |
You can skip the try/catch and just call form.clean_old_password(). If an exception is raised and not caught in a test … |
david | |
Same here. |
david | |
Same here. |
david | |
Same here. |
david | |
Same here. |
david | |
Same here. |
david | |
Same here. |
david | |
Can you include the backend name in here? |
david | |
Can you include the backend name in here? |
david | |
And here. |
david | |
And here. |
david | |
Col: 28 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 55 W291 trailing whitespace |
reviewbot | |
Col: 13 E113 unexpected indentation |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 52 W291 trailing whitespace |
reviewbot | |
Col: 28 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Auth backends have a user-visible name, so you can use backend.name instead of backend.__class__.name. Here and all the other logging … |
david | |
There shouldn't be a blank line here (django, djblets, and kgb are all "third party" packages) |
david | |
What's the point of this? |
david | |
L before R |
david | |
Use # for comments. """ is a docstring. |
david | |
This should be commented too. |
david | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Col: 9 E265 block comment should start with '# ' |
reviewbot | |
Add a trailing comma here. |
david | |
Add a trailing comma here. |
david | |
No # at the end. |
david | |
Add a trailing comma here. |
david | |
No # at the end. |
david | |
Add a trailing comma here. |
david | |
No # at the end. |
david | |
This will catch the ValidationError that's raised inside the try. |
david | |
Blank line between these. |
chipx86 | |
The logging errors should use %r with backend, so that the log message will include the specific class and any … |
chipx86 | |
These are human-readable strings. They need to be proper sentences, and should be targeted to the end user. Unlike with … |
chipx86 | |
Blank line. Same below. |
chipx86 | |
Blank line. |
chipx86 | |
No need for Class, and Test is too generic. Should be something like SandboxAuthBackend. |
chipx86 | |
No point in storing this in a variable. |
chipx86 | |
This should be something like: self.assertEqual(e.message, 'blah blah') If the string still wraps, this may be better: self.assertEqual( e.message, 'blah … |
chipx86 | |
It's unclear how this relates to the function being tested. Looking through the change, I realize they're not. Instead, these … |
chipx86 | |
blank line before this. |
chipx86 | |
Use %r, and start the arguments on a new line. |
chipx86 | |
Use %r, and start the arguments on a new line. |
chipx86 | |
Use %r, and start the arguments on a new line. |
chipx86 | |
Use %r, and start the arguments on a new line. |
chipx86 | |
There's no need for this, since we'll end up with either a value or an exception in the next block. |
chipx86 | |
Blank line between these. |
chipx86 | |
Blank line between these. |
chipx86 | |
Similar to my comments in the columns change, you don't actually need extensions for these tests. You only need extensions … |
chipx86 | |
There's nothing here to test for breakages, since these functions don't raise any exceptions. On all these changes, you'll need … |
chipx86 | |
Two blank lines at the top level between classes. |
chipx86 | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
This isn't actually testing anything. |
chipx86 | |
Again, extensions are useless here. |
chipx86 | |
Extensions are useless here too. |
chipx86 | |
If we're not testing this function, we should remove it. Otherwise, it should throw something. Same in all other cases … |
chipx86 | |
Same comments. |
chipx86 | |
Col: 43 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 43 E128 continuation line under-indented for visual indent |
reviewbot | |
Should have a trailing period. |
chipx86 | |
Should just be: super(SandboxTests, self).tearDown() |
chipx86 | |
We have no verification that authenticate() is ever called. We should use spy_on() and check that it was called with … |
chipx86 | |
These docstrings should be in this format: """Testing AuthBackend sandboxing for <func>""" |
chipx86 | |
For this, you can use: self.assertRaisesMessage( ValidationError, "<message here>", lambda: form.clean_old_password()) |
chipx86 | |
We have no verification that update_password() is ever called. We should use spy_on() and check that it was called with … |
chipx86 | |
We have no verification that update_name() is ever called. We should use spy_on() and check that it was called with … |
chipx86 | |
We do this in all the tests, so it can move into setUp(). |
chipx86 | |
We do this a lot, so it can probably just move into setUp(). |
chipx86 | |
We have no verification that update_email() is ever called. We should use spy_on() and check that it was called with … |
chipx86 | |
This should be using super(...) still. Why was it changed? |
chipx86 | |
This should say: """Testing AuthBackendHook sandboxes AuthBackend registration""" Note the "sandboxes" part, which will help give a clue if tests … |
chipx86 | |
For API resource unit tests, we don't want to introduce any new classes. Instead, the test should be part of … |
chipx86 | |
This docstring isn't correct, and doesn't match the rest of the docstrings in this class. It should describe the URL, … |
chipx86 | |
This should be treated as a failure, not success. |
david | |
I mentioned this in the other review request, but this isn't correct. |
david |
- Description:
-
Unit tests for reviewboard.accounts.AuthBackend, and then sandboxing call to methods on the reviewboard.accounts.AuthBackend subclass
+ + TODO:
+ 1. Make test initially fail. + 2. Sandbox AuthBackend extension + 3. Check test passes afterwards. - Testing Done:
-
~ Ran unit tests.
~ Ran extension unit tests.
- Summary:
-
[WIP] reviewboard.accounts.AuthBackend sandboxingreviewboard.accounts.AuthBackend sandboxing
- Description:
-
Unit tests for reviewboard.accounts.AuthBackend, and then sandboxing call to methods on the reviewboard.accounts.AuthBackend subclass
~ TODO:
~ 1. Make test initially fail. ~ 2. Sandbox AuthBackend extension ~ 3. Check test passes afterwards. ~ methods sandboxed:
~ authenticate() ~ get_or_create_user() ~ query_users() + search_users() + update_name() + update_email() + update_password() - Testing Done:
-
~ Ran extension unit tests.
~ Ran unit tests; they fail without the sandboxing and succeed with it.
- Commit:
-
683cb794d5b653a473f814f604e7f98baa5678315703bab58d83d61914386f9aa9f233dd52ece154
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/user.py reviewboard/webapi/resources/review_request_draft.py reviewboard/extensions/tests.py reviewboard/accounts/forms/pages.py reviewboard/webapi/resources/review_request.py
-
Before reading through these comments, go read through the sandboxing for datagrid columns. My comment is going to be based on that discussion.
Similar to datagrid column testing, you have a bunch of tests under the "Extensions" umbrella that have nothing to do with extensions.
If a particular part of the codebase is being modified to not break when calling a particular thing, then the unit test belongs alongside the other unit tests for that part of the codebase. So for instance, an API resource calls a function and needs to handle breakages in that function. That API resource's test suite should be updated with a test that handles that case.
The tests that belong with the extension are:
1) Does enabling an extension and instantiating the hook result in the auth backend properly being registered?
2) Does disabling the extension result in the auth backend properly being unregistered?The rest of the tests are testing specific instances where functions are used (like in forms). Those tests belong with the tests for those instances (like accounts/tests.py).
-
-
The logging errors should use
%r
withbackend
, so that the log message will include the specific class and any additional information the author of the class provides for the class-to-string representation.Same below.
-
These are human-readable strings. They need to be proper sentences, and should be targeted to the end user. Unlike with the log message (which is there for diagnosing problems), including extra information in a validation message doesn't do the end user much good, as they likely can't do a thing about it.
How about something like:
Unexpected error when validating the password. Please contact the administrator.
-
-
-
-
-
This should be something like:
self.assertEqual(e.message, 'blah blah')
If the string still wraps, this may be better:
self.assertEqual( e.message, 'blah blah ...')
-
It's unclear how this relates to the function being tested.
Looking through the change, I realize they're not. Instead, these are two cases that happen to call that function. You wouldn't want to include every single call site ever in this place.
Instead, what you want is to have unit tests in the resource's own test file that covers the case where the function fails.
-
-
-
-
-
- Description:
-
Unit tests for reviewboard.accounts.AuthBackend, and then sandboxing call to methods on the reviewboard.accounts.AuthBackend subclass
methods sandboxed:
authenticate() get_or_create_user() query_users() search_users() update_name() update_email() update_password() + + TODO:
+ regsiter_authbackend() + unregister_authbackend() - Commit:
-
a76183cccee4711c6b6a32c6bc4183cb85f1de0a03ccc25eae8ee765e46d1d05d9cf5b1b068de53d
- Diff:
-
Revision 19 (+439 -17)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
-
-
-
-
-
-
Similar to my comments in the columns change, you don't actually need extensions for these tests. You only need extensions for the ones testing extension-specific functionality (like the hooks).
-
There's nothing here to test for breakages, since these functions don't raise any exceptions.
On all these changes, you'll need to make sure that every one of these tests fail without your sandboxing, and passes with them.
-
-
-
-
-
If we're not testing this function, we should remove it. Otherwise, it should throw something.
Same in all other cases where you have a custom auth backend for testing.
-
- Description:
-
Unit tests for reviewboard.accounts.AuthBackend, and then sandboxing call to methods on the reviewboard.accounts.AuthBackend subclass
+ Hook sandboxed: AuthBackendHook
+ methods sandboxed:
authenticate() get_or_create_user() query_users() search_users() update_name() update_email() update_password() - - TODO:
- regsiter_authbackend() - unregister_authbackend() - Commit:
-
03ccc25eae8ee765e46d1d05d9cf5b1b068de53d213e8a15283f8537da731d81f065fbef3d25c6aa
- Diff:
-
Revision 20 (+350 -16)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
-
-
- Commit:
-
213e8a15283f8537da731d81f065fbef3d25c6aa4bb7cd63c9ea96ac0fc59f57803dc4257dbbff46
- Diff:
-
Revision 21 (+350 -16)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
4bb7cd63c9ea96ac0fc59f57803dc4257dbbff467b79ca9cf8788cc761e148ca9a3690f5f5f49224
- Diff:
-
Revision 22 (+350 -16)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
7b79ca9cf8788cc761e148ca9a3690f5f5f49224c53986e04e77e0d88f9b64eed4045472adbc5064
- Diff:
-
Revision 23 (+350 -16)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
-
-
-
-
We have no verification that
authenticate()
is ever called. We should usespy_on()
and check that it was called with the expected parameters. -
-
For this, you can use:
self.assertRaisesMessage( ValidationError, "<message here>", lambda: form.clean_old_password())
-
We have no verification that
update_password()
is ever called. We should usespy_on()
and check that it was called with the expected parameter. -
We have no verification that
update_name()
is ever called. We should usespy_on()
and check that it was called with the expected parameter. -
-
-
We have no verification that
update_email()
is ever called. We should usespy_on()
and check that it was called with the expected parameter. -
-
This should say:
"""Testing AuthBackendHook sandboxes AuthBackend registration"""
Note the "sandboxes" part, which will help give a clue if tests ever fail.
Same below with unregistration.
-
For API resource unit tests, we don't want to introduce any new classes. Instead, the test should be part of the existing class, and should go through an API call.
That is, we should set up a failure case, perform an API call, and make sure we get back a sane response and not a 500. (Also need to test that it does generate a 500 without the sandboxing.)
This applies to the other API tests as well.
- Commit:
-
c53986e04e77e0d88f9b64eed4045472adbc50640d34bb17ad395400146daa20f04b2eddf9d38991
- Diff:
-
Revision 24 (+337 -15)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/tests.py reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
0d34bb17ad395400146daa20f04b2eddf9d3899174f5bd0ccc80af3302b7e109049da8f80e5ad7aa
- Diff:
-
Revision 25 (+305 -13)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Description:
-
~ Unit tests for reviewboard.accounts.AuthBackend, and then sandboxing call to methods on the reviewboard.accounts.AuthBackend subclass
~ Extensions that create a AuthBackend subclass (using the AuthBackendHook) can throw exceptions inside Reviewboard. The parts of Reviewboard that call those methods have been sandboxed.
~ Hook sandboxed: AuthBackendHook
~ Now when an AuthBackend subclass from an extension throw an exception; Reviewboard logs the errors with enough information to find which method in the AuthBackend subclass threw the exception.
- - methods sandboxed:
- authenticate() - get_or_create_user() - query_users() - search_users() - update_name() - update_email() - update_password() - Testing Done:
-
~ Ran unit tests; they fail without the sandboxing and succeed with it.
~ Unit tests have been written to make sure that functions from an AuthBackend subclass have been called, and when an exception is thrown it gets logged.
+ + The tests fail without the sanboxing, and succeed with it.
- Description:
-
~ Extensions that create a AuthBackend subclass (using the AuthBackendHook) can throw exceptions inside Reviewboard. The parts of Reviewboard that call those methods have been sandboxed.
~ Extensions that create an AuthBackend subclass (using the AuthBackendHook) can throw exceptions inside Reviewboard. The parts of Reviewboard that call those methods have been sandboxed.
~ Now when an AuthBackend subclass from an extension throw an exception; Reviewboard logs the errors with enough information to find which method in the AuthBackend subclass threw the exception.
~ Now when an AuthBackend subclass from an extension throws an exception; Reviewboard logs the errors with enough information to find which method in the AuthBackend subclass threw the exception.
- Commit:
-
74f5bd0ccc80af3302b7e109049da8f80e5ad7aaab66034e7515ccb2aa1bd398672b85306e4d62f8
- Diff:
-
Revision 26 (+299 -14)
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
ab66034e7515ccb2aa1bd398672b85306e4d62f85ba5ebfded97dae790c93cd90dcd91493ee3020e
- Diff:
-
Revision 27 (+300 -18)
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
5ba5ebfded97dae790c93cd90dcd91493ee3020e4f8d2b8c9599988c065046164b432c992b3dbe04
- Diff:
-
Revision 28 (+307 -21)
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py
- Commit:
-
4f8d2b8c9599988c065046164b432c992b3dbe04bc8a2831d2aa4892f3a1aeeea42ed1b2c8f01590
- Diff:
-
Revision 29 (+304 -18)
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_draft.py reviewboard/webapi/resources/review_request.py reviewboard/accounts/forms/pages.py reviewboard/webapi/tests/test_review_request.py reviewboard/accounts/tests.py reviewboard/webapi/resources/user.py reviewboard/webapi/tests/test_review_request_draft.py reviewboard/webapi/tests/test_user.py