Program: 20703
Project: 20703
Buggy source:
public void testGetWithInvalidUserAndGuestHasReadAccess() throws Exception {
  String commonsLangJar="String_Node_Str";
  String expectedArtifactContents="String_Node_Str";
  File artifactFile=new File(repoRootInternal,commonsLangJar);
  artifactFile.getParentFile().mkdirs();
  FileUtils.writeStringToFile(artifactFile,expectedArtifactContents,null);
  WebRequest request=new GetMethodWebRequest("String_Node_Str" + commonsLangJar);
  InvocationContext ic=sc.newInvocation(request);
  servlet=(RepositoryServlet)ic.getServlet();
  servlet.setDavSessionProvider(davSessionProvider);
  ArchivaDavResourceFactory archivaDavResourceFactory=(ArchivaDavResourceFactory)servlet.getResourceFactory();
  archivaDavResourceFactory.setHttpAuth(httpAuth);
  archivaDavResourceFactory.setServletAuth(servletAuth);
  servlet.setResourceFactory(archivaDavResourceFactory);
  AuthenticationResult result=new AuthenticationResult();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  servletAuthControl.expectAndThrow(servletAuth.isAuthenticated(null,null),new AuthenticationException("String_Node_Str"));
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized("String_Node_Str","String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS),true);
  SecuritySession session=new DefaultSecuritySession();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  httpAuthControl.expectAndReturn(httpAuth.getSecuritySession(ic.getRequest().getSession(true)),session);
  httpAuthControl.expectAndReturn(httpAuth.getSessionUser(ic.getRequest().getSession()),null);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),true);
  httpAuthControl.replay();
  servletAuthControl.replay();
  WebResponse response=sc.getResponse(request);
  httpAuthControl.verify();
  servletAuthControl.verify();
  assertEquals(HttpServletResponse.SC_OK,response.getResponseCode());
  assertEquals("String_Node_Str",expectedArtifactContents,response.getText());
}

Fixed version (ground truth):
@Test public void testGetWithInvalidUserAndGuestHasReadAccess() throws Exception {
  String commonsLangJar="String_Node_Str";
  String expectedArtifactContents="String_Node_Str";
  File artifactFile=new File(repoRootInternal,commonsLangJar);
  artifactFile.getParentFile().mkdirs();
  FileUtils.writeStringToFile(artifactFile,expectedArtifactContents,null);
  WebRequest request=new GetMethodWebRequest("String_Node_Str" + commonsLangJar);
  InvocationContext ic=sc.newInvocation(request);
  servlet=(RepositoryServlet)ic.getServlet();
  servlet.setDavSessionProvider(davSessionProvider);
  ArchivaDavResourceFactory archivaDavResourceFactory=(ArchivaDavResourceFactory)servlet.getResourceFactory();
  archivaDavResourceFactory.setHttpAuth(httpAuth);
  archivaDavResourceFactory.setServletAuth(servletAuth);
  servlet.setResourceFactory(archivaDavResourceFactory);
  AuthenticationResult result=new AuthenticationResult();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  servletAuthControl.expectAndThrow(servletAuth.isAuthenticated(null,null),new AuthenticationException("String_Node_Str"));
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized("String_Node_Str","String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS),true);
  SecuritySession session=new DefaultSecuritySession();
  httpAuthControl.expectAndReturn(httpAuth.getAuthenticationResult(null,null),result);
  httpAuthControl.expectAndReturn(httpAuth.getSecuritySession(ic.getRequest().getSession(true)),session);
  httpAuthControl.expectAndReturn(httpAuth.getSessionUser(ic.getRequest().getSession()),null);
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndReturn(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),true);
  httpAuthControl.replay();
  servletAuthControl.replay();
  WebResponse response=sc.getResponse(request);
  httpAuthControl.verify();
  servletAuthControl.verify();
  assertEquals(HttpServletResponse.SC_OK,response.getResponseCode());
  assertEquals("String_Node_Str",expectedArtifactContents,response.getText());
}