@Test
public void testGetOAuth2UserScopeNotAllowed() throws Exception {

  when(config.getScopeExpression()).thenReturn(AuthScopeExpressions.interpret(SCOPES));
  when(oauthService.getAuthorizedScopes(SCOPES)).thenThrow(new OAuthRequestException("any"))
      .thenReturn(null).thenReturn(new String[] {"scope3"});
  for (int i = 0; i < 3; i++) {
    assertNull(authenticator.getOAuth2User(request, config));
  }
}