Fixes #7369 - External user groups update on login

This forces external user groups associated to the auth source of the user logging in to update, so that users get their external permissions updated on login.
Also there are a few unit tests that were large and I tried to tidy that up.
Plus few lines below, there's `rescue => error`, not sure how did that slip in and I know others don't like to mix refactoring into feature PRs but I think if you'll touch this area you could fix this as well. If it's too hard to name all possible exceptions, could you please `logger.debug error.backtrace.join("\n")`