Fix commit validation and add unit tests
The ValidateServiceUserCommits was broken in many ways. In this [1]
change the else clause was mistakenly removed. After [1], even if there
are active owners the creator status is still checked and when the
creator is inactive the validation fails.
However, even before [1] the code was broken: if the owner group was set
and all members were inactive then validation would immediately fail
without checking the creator status. So even if the creator was
active the validation would fail in this case.
This change makes the code easier to read by checking the positive cases
first and exiting early, as soon as it detects that the validation will
pass.
Add unit tests to cover all possible combinations of the creator and
owner group status.
[1] https://gerrit-review.googlesource.com/c/plugins/serviceuser/+/108158/3/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ValidateServiceUserCommits.java
Change-Id: I3e86eadb4caea85170184566f475a81856b628d2
2 files changed