use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method shortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList.
@Test
public void shortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList() throws Exception {
AccountState account1 = newAccount(1);
AccountState account2 = newInactiveAccount(2);
TestSearcher searcher1 = new TestSearcher("foo", true, account2);
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("foo", false, account1, account2);
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
// searcher1 matched and then filtered out all candidates because account2 is inactive, but
// still short-circuited.
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).isEmpty();
assertThat(filteredInactiveIds(result)).containsExactlyElementsIn(ids(2));
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method filterInactiveEventuallyFindingNoResults.
@Test
public void filterInactiveEventuallyFindingNoResults() throws Exception {
TestSearcher searcher1 = new TestSearcher("foo", false, newInactiveAccount(1));
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("f.*", false, newInactiveAccount(2));
searcher2.setCallerShouldFilterOutInactiveCandidates();
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).isEmpty();
assertThat(filteredInactiveIds(result)).containsExactlyElementsIn(ids(1, 2));
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method filterInactiveEventuallyFindingResults.
@Test
public void filterInactiveEventuallyFindingResults() throws Exception {
TestSearcher searcher1 = new TestSearcher("foo", false, newInactiveAccount(1));
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("f.*", false, newAccount(2));
searcher2.setCallerShouldFilterOutInactiveCandidates();
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(search("foo", searchers, AccountResolverTest::allVisiblePredicate).asIdSet()).containsExactlyElementsIn(ids(2));
// No info about inactive results exposed if there was at least one active result.
assertThat(filteredInactiveIds(result)).isEmpty();
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverTest method dontShortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList.
@Test
public void dontShortCircuitAfterFilteringInactiveCandidatesResultsInEmptyList() throws Exception {
AccountState account1 = newAccount(1);
AccountState account2 = newInactiveAccount(2);
TestSearcher searcher1 = new TestSearcher("foo", false, account2);
searcher1.setCallerShouldFilterOutInactiveCandidates();
TestSearcher searcher2 = new TestSearcher("foo", false, account1, account2);
ImmutableList<Searcher<?>> searchers = ImmutableList.of(searcher1, searcher2);
// searcher1 matched, but filtered out all candidates because account2 is inactive. Actual
// result came from searcher2 instead.
Result result = search("foo", searchers, AccountResolverTest::allVisiblePredicate);
assertThat(result.asIdSet()).containsExactlyElementsIn(ids(1, 2));
}
use of com.google.gerrit.server.account.AccountResolver.Result in project gerrit by GerritCodeReview.
the class AccountResolverIT method bySelf.
@Test
public void bySelf() throws Exception {
assertThat(resolve("Self")).isEmpty();
accountOperations.newAccount().fullname("self").create();
Result result = resolveAsResult("self");
assertThat(result.asIdSet()).containsExactly(admin.id());
assertThat(result.isSelf()).isTrue();
assertThat(result.asUniqueUser()).isSameInstanceAs(self.get());
result = resolveAsResult("me");
assertThat(result.asIdSet()).containsExactly(admin.id());
assertThat(result.isSelf()).isTrue();
assertThat(result.asUniqueUser()).isSameInstanceAs(self.get());
requestScopeOperations.setApiUserAnonymous();
checkBySelfFails();
requestScopeOperations.setApiUserInternal();
checkBySelfFails();
}
Aggregations