Program: 20705
Project: 20705
Buggy source:
public void testPutWithValidUserWithNoWriteAccess() throws Exception {
  setupCleanRepo(repoRootInternal);
  String putUrl="String_Node_Str";
  InputStream is=getClass().getResourceAsStream("String_Node_Str");
  assertNotNull("String_Node_Str",is);
  WebRequest request=new PutMethodWebRequest(putUrl,is,"String_Node_Str");
  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.expectAndReturn(servletAuth.isAuthenticated(null,null),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()),new SimpleUser());
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndThrow(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),new UnauthorizedException("String_Node_Str"));
  httpAuthControl.replay();
  servletAuthControl.replay();
  servlet.service(ic.getRequest(),ic.getResponse());
  httpAuthControl.verify();
  servletAuthControl.verify();
}

Fixed version (ground truth):
@Test public void testPutWithValidUserWithNoWriteAccess() throws Exception {
  setupCleanRepo(repoRootInternal);
  String putUrl="String_Node_Str";
  InputStream is=getClass().getResourceAsStream("String_Node_Str");
  assertNotNull("String_Node_Str",is);
  WebRequest request=new PutMethodWebRequest(putUrl,is,"String_Node_Str");
  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.expectAndReturn(servletAuth.isAuthenticated(null,null),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()),new SimpleUser());
  servletAuthControl.expectAndReturn(servletAuth.isAuthenticated(null,result),true);
  servletAuthControl.expectAndThrow(servletAuth.isAuthorized(null,session,"String_Node_Str",ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD),new UnauthorizedException("String_Node_Str"));
  httpAuthControl.replay();
  servletAuthControl.replay();
  servlet.service(ic.getRequest(),ic.getResponse());
  httpAuthControl.verify();
  servletAuthControl.verify();
}