Program: 34783
Project: 34783
Buggy source:
/** 
 * Test method for  {@link com.ibm.ws.security.authorization.builtin.internal.BuiltinAuthorizationService#isAuthorized(java.lang.Object,java.util.List,javax.security.auth.Subject)} .
 * @throws CredentialDestroyedException
 * @throws CredentialExpiredException
 */
@Test public void testIsAuthorized_multipleTablesAnswer() throws Exception {
  WSPrincipal princ=new WSPrincipal(subject1,accessId1,authMethod);
  Set<Principal> principals=new HashSet<Principal>();
  principals.add(princ);
  HashSet<Object> pubCredentials=new HashSet<Object>();
  pubCredentials.add(wsCred);
  HashSet<Object> privCredentials=new HashSet<Object>();
  final Subject subject=new Subject(false,principals,pubCredentials,privCredentials);
  requiredRoles.add(role1);
  assignedRoles=new RoleSet(requiredRoles);
  builtinAuthz.setAuthorizationTableService(authzTableService2Ref);
  builtinAuthz.setAuthorizationTableService(authzTableService3Ref);
  context.checking(new Expectations(){
{
      one(authzTableService).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService2).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService3).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,null);
      will(returnValue(Boolean.FALSE));
      one(wsCred).isUnauthenticated();
      will(returnValue(Boolean.FALSE));
      one(wsCred).isBasicAuth();
      will(returnValue(Boolean.FALSE));
      one(authzTableService).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService2).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService3).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,subject);
      will(returnValue(Boolean.FALSE));
      one(wsCred).getAccessId();
      will(returnValue(accessId1));
      one(authzTableService).getRolesForAccessId(resourceName,accessId1);
      will(returnValue(assignedRoles));
      one(authzTableService2).getRolesForAccessId(resourceName,accessId1);
      will(returnValue(assignedRoles));
      one(authzTableService3).getRolesForAccessId(resourceName,accessId1);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,subject);
      will(returnValue(Boolean.TRUE));
    }
  }
);
  builtinAuthz.isAuthorized(resourceName,requiredRoles,subject);
  assertTrue("String_Node_Str",outputMgr.checkForMessages("String_Node_Str" + resourceName + "String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Test method for  {@link com.ibm.ws.security.authorization.builtin.internal.BuiltinAuthorizationService#isAuthorized(java.lang.Object,java.util.List,javax.security.auth.Subject)} .
 * @throws CredentialDestroyedException
 * @throws CredentialExpiredException
 */
@Test public void testIsAuthorized_multipleTablesAnswer() throws Exception {
  WSPrincipal princ=new WSPrincipal(subject1,accessId1,authMethod);
  Set<Principal> principals=new HashSet<Principal>();
  principals.add(princ);
  HashSet<Object> pubCredentials=new HashSet<Object>();
  pubCredentials.add(wsCred);
  HashSet<Object> privCredentials=new HashSet<Object>();
  final Subject subject=new Subject(false,principals,pubCredentials,privCredentials);
  requiredRoles.add(role1);
  assignedRoles=new RoleSet(requiredRoles);
  builtinAuthz.setAuthorizationTableService(authzTableService2Ref);
  builtinAuthz.setAuthorizationTableService(authzTableService3Ref);
  context.checking(new Expectations(){
{
      one(authzTableService).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService2).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService3).getRolesForSpecialSubject(resourceName,AuthorizationTableService.EVERYONE);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,null);
      will(returnValue(Boolean.FALSE));
      one(wsCred).isUnauthenticated();
      will(returnValue(Boolean.FALSE));
      one(wsCred).isBasicAuth();
      will(returnValue(Boolean.FALSE));
      one(authzTableService).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService2).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(RoleSet.EMPTY_ROLESET));
      one(authzTableService3).getRolesForSpecialSubject(resourceName,AuthorizationTableService.ALL_AUTHENTICATED_USERS);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,subject);
      will(returnValue(Boolean.FALSE));
      one(wsCred).getAccessId();
      will(returnValue(accessId1));
      one(wsCred).getRealmName();
      will(returnValue(realmName1));
      one(authzTableService).getRolesForAccessId(resourceName,accessId1,realmName1);
      will(returnValue(assignedRoles));
      one(authzTableService2).getRolesForAccessId(resourceName,accessId1,realmName1);
      will(returnValue(assignedRoles));
      one(authzTableService3).getRolesForAccessId(resourceName,accessId1,realmName1);
      will(returnValue(null));
      one(accessDecisionService).isGranted(resourceName,requiredRoles,null,subject);
      will(returnValue(Boolean.TRUE));
    }
  }
);
  builtinAuthz.isAuthorized(resourceName,requiredRoles,subject);
  assertTrue("String_Node_Str",outputMgr.checkForMessages("String_Node_Str" + resourceName + "String_Node_Str"));
}