django-DefectDojo
django-DefectDojo copied to clipboard
changed type to regular django type to also pick up creation events f…
changed the type of user_post_save to generic Django user so all users created (ldap, oauth, ui) will trigger this function. This should fix #6626
@lme-nca please see the failing tests. You may have to base your change from the dev branch to make the helm lint test pass
Hi @cody-m-tibco I changed the base to dev and fixed a unused import. Let me know if there is anything else i'm supposed to do.
Hard to tell without testing it. The failing unit tests look like it might not work for the normal creation of users anymore. @lme-nca Have you tested it with creating users via OAuth2 and creating users with the user interface?
@StefanFl Hi Stefan, you were right it was not being triggered for Dojo users (created through the UI) now. I expected this to work because of inheritance, however I am not that familiar with how Python handles this. It seems the easiest solution is just adding both types as separate annotations. I tested this and it now works for both Dojo as well as Django Users.
I have not tested it with Oauth, as I don't have a test setup for this, however as this also creates a Django user type i'm confident this would fix the issue.
I am nervous about double dipping here. For example, if you edit a user in the UI (should be a Dojo_User) would the post save be triggered once for the Dojo_User, and then a second time for the Django user?
@Maffooch well clearly it wasn't being triggered for the Dojo_User, because the user was not added in the group and also the notification templates were not created, this triggered the test to fail.
however alternatively we could remove the sender restriction all together and do something like this: https://stackoverflow.com/questions/7792287/how-to-use-django-model-inheritance-with-signals i.e.
if isinstance(user, Dojo_User) or isinstance(user, User)
Personally I don't like this solution.
@Maffooch @StefanFl The test are passing now, ready for review ?
@Maffooch could you add a second reviewer for approval ?
created a new pull request from the DEV branch: https://github.com/DefectDojo/django-DefectDojo/pull/6918