1 package org.apache.archiva.webdav;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import junit.framework.TestCase;
23 import org.apache.archiva.admin.model.RepositoryAdminException;
24 import org.apache.archiva.admin.model.beans.ManagedRepository;
25 import org.apache.archiva.admin.model.beans.RepositoryGroup;
26 import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
27 import org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator;
28 import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
29 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
30 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
31 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
32 import org.apache.archiva.configuration.ArchivaConfiguration;
33 import org.apache.archiva.configuration.Configuration;
34 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
35 import org.apache.archiva.proxy.DefaultRepositoryProxyConnectors;
36 import org.apache.archiva.proxy.model.ProxyFetchResult;
37 import org.apache.archiva.repository.ManagedRepositoryContent;
38 import org.apache.archiva.repository.RepositoryContentFactory;
39 import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
40 import org.apache.archiva.repository.content.maven2.RepositoryRequest;
41 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
42 import org.apache.commons.io.FileUtils;
43 import org.apache.jackrabbit.webdav.DavException;
44 import org.apache.jackrabbit.webdav.DavResourceLocator;
45 import org.apache.jackrabbit.webdav.DavServletRequest;
46 import org.apache.jackrabbit.webdav.DavServletResponse;
47 import org.easymock.IMocksControl;
48 import org.junit.After;
49 import org.junit.Before;
50 import org.junit.Test;
51 import org.junit.runner.RunWith;
52 import org.springframework.context.ApplicationContext;
53 import org.springframework.test.context.ContextConfiguration;
55 import javax.inject.Inject;
56 import java.io.IOException;
57 import java.nio.file.Path;
58 import java.nio.file.Paths;
59 import java.util.ArrayList;
60 import java.util.List;
62 import static org.easymock.EasyMock.*;
65 * ArchivaDavResourceFactoryTest
67 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
68 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
69 public class ArchivaDavResourceFactoryTest
72 private static final String RELEASES_REPO = "releases";
74 private static final String INTERNAL_REPO = "internal";
76 private static final String LOCAL_MIRROR_REPO = "local-mirror";
78 private static final String LEGACY_REPO = "legacy-repo";
80 private static final String LOCAL_REPO_GROUP = "local";
82 private OverridingArchivaDavResourceFactory resourceFactory;
84 private IMocksControl requestControl;
86 private DavServletRequest request;
88 private IMocksControl repoRequestControl;
90 private RepositoryRequest repoRequest;
92 private IMocksControl responseControl;
94 private DavServletResponse response;
96 private IMocksControl archivaConfigurationControl;
98 private ArchivaConfiguration archivaConfiguration;
100 private Configuration config;
102 private IMocksControl repoContentFactoryControl;
104 private RepositoryContentFactory repoFactory;
107 ApplicationContext applicationContext;
110 PlexusSisuBridge plexusSisuBridge;
113 DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin;
116 RemoteRepositoryAdmin remoteRepositoryAdmin;
120 DefaultRepositoryGroupAdmin defaultRepositoryGroupAdmin;
130 requestControl = createControl();
131 request = requestControl.createMock( DavServletRequest.class );
133 responseControl = createControl();
134 response = responseControl.createMock( DavServletResponse.class );
135 //responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
137 archivaConfigurationControl = createControl();
138 archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class );
140 config = new Configuration();
141 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 5, 20 );
142 archivaConfiguration.save( config );
144 expectLastCall().times( 1, 4 );
145 archivaConfigurationControl.replay();
147 defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
148 ( (DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator() ).setArchivaConfiguration(
149 archivaConfiguration );
150 if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
152 defaultManagedRepositoryAdmin.addManagedRepository(
153 createManagedRepository( RELEASES_REPO, Paths.get( "target/test-classes/" + RELEASES_REPO ).toString(),
154 "default" ), false, null );
156 if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
158 defaultManagedRepositoryAdmin.addManagedRepository(
159 createManagedRepository( INTERNAL_REPO, Paths.get( "target/test-classes/" + INTERNAL_REPO ).toString(),
160 "default" ), false, null );
162 RepositoryGroup repoGroupConfig = new RepositoryGroup();
163 repoGroupConfig.setId( LOCAL_REPO_GROUP );
164 repoGroupConfig.addRepository( RELEASES_REPO );
165 repoGroupConfig.addRepository( INTERNAL_REPO );
167 defaultRepositoryGroupAdmin.setArchivaConfiguration( archivaConfiguration );
168 if ( defaultManagedRepositoryAdmin.getManagedRepository( LOCAL_REPO_GROUP ) == null )
170 defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
173 repoContentFactoryControl = createControl();
174 repoFactory = repoContentFactoryControl.createMock( RepositoryContentFactory.class );
176 repoRequestControl = createControl();
177 repoRequest = repoRequestControl.createMock( RepositoryRequest.class );
180 new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration );
181 resourceFactory.setArchivaConfiguration( archivaConfiguration );
182 resourceFactory.setRepositoryFactory( repoFactory );
183 resourceFactory.setRepositoryRequest( repoRequest );
184 resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
185 resourceFactory.setRemoteRepositoryAdmin( remoteRepositoryAdmin );
186 resourceFactory.setManagedRepositoryAdmin( defaultManagedRepositoryAdmin );
189 private ManagedRepository createManagedRepository( String id, String location, String layout )
191 ManagedRepository repoConfig = new ManagedRepository();
192 repoConfig.setId( id );
193 repoConfig.setName( id );
194 repoConfig.setLocation( location );
195 repoConfig.setLayout( layout );
200 private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
201 throws RepositoryAdminException
203 ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
204 repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );
211 public void tearDown()
217 // MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
219 public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
222 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
223 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
224 new ArchivaDavLocatorFactory() );
226 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
227 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
231 archivaConfigurationControl.reset();
233 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 3 );
235 expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
237 expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
239 expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo );
241 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
243 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
245 expect( request.getContextPath() ).andReturn( "" ).times( 2 );
247 expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( true );
250 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
253 expect( repoRequest.toArtifactReference(
254 "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null );
256 expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
257 internalRepo ) ).andReturn(
258 Paths.get( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
259 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).toString());
261 expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
263 expect( repoRequest.isArchetypeCatalog(
264 "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
265 archivaConfigurationControl.replay();
266 requestControl.replay();
267 repoContentFactoryControl.replay();
268 repoRequestControl.replay();
270 resourceFactory.createResource( locator, request, response );
272 archivaConfigurationControl.verify();
273 requestControl.verify();
274 repoContentFactoryControl.verify();
275 repoRequestControl.verify();
277 fail( "A DavException with 401 error code should have been thrown." );
279 catch ( DavException e )
281 assertEquals( 401, e.getErrorCode() );
286 public void testRepositoryGroupLastRepositoryRequiresAuthentication()
289 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
290 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
291 new ArchivaDavLocatorFactory() );
293 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<>();
294 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
295 repoGroup.setId( LOCAL_REPO_GROUP );
296 repoGroup.addRepository( INTERNAL_REPO );
297 repoGroup.addRepository( RELEASES_REPO );
299 repoGroups.add( repoGroup );
301 config.setRepositoryGroups( repoGroups );
303 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
305 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
309 archivaConfigurationControl.reset();
311 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 3 );
313 expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
315 expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
317 expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
319 expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo );
321 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
323 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
325 expect( request.getContextPath() ).andReturn( "" ).times( 2 );
327 expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
330 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
333 expect( repoRequest.toArtifactReference(
334 "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null );
336 expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
337 internalRepo ) ).andReturn(
338 Paths.get( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
339 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).toString());
342 expect( repoRequest.isArchetypeCatalog(
343 "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
344 archivaConfigurationControl.replay();
345 requestControl.replay();
346 repoContentFactoryControl.replay();
347 repoRequestControl.replay();
349 resourceFactory.createResource( locator, request, response );
351 archivaConfigurationControl.verify();
352 requestControl.verify();
353 repoContentFactoryControl.verify();
354 repoRequestControl.verify();
356 fail( "A DavException with 401 error code should have been thrown." );
358 catch ( DavException e )
360 assertEquals( 401, e.getErrorCode() );
365 public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
368 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
369 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
370 new ArchivaDavLocatorFactory() );
372 defaultManagedRepositoryAdmin.addManagedRepository(
373 createManagedRepository( LOCAL_MIRROR_REPO, Paths.get( "target/test-classes/local-mirror" ).toString(),
374 "default" ), false, null );
376 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<>();
377 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
378 repoGroup.setId( LOCAL_REPO_GROUP );
379 repoGroup.addRepository( INTERNAL_REPO );
380 repoGroup.addRepository( LOCAL_MIRROR_REPO );
382 repoGroups.add( repoGroup );
384 config.setRepositoryGroups( repoGroups );
386 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
387 ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
391 archivaConfigurationControl.reset();
393 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 3 );
395 expect( request.getMethod() ).andReturn( "GET" ).times( 5 );
397 expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
399 expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
401 expect( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ) ).andReturn( localMirrorRepo );
403 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 4 );
405 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 4 );
407 expect( request.getContextPath() ).andReturn( "" ).times( 2 );
409 expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
412 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
415 expect( repoRequest.toArtifactReference(
416 "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null ).times( 2 );
418 expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
419 internalRepo ) ).andReturn(
420 Paths.get( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
421 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).toString() );
423 expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
425 .andReturn( Paths.get( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
426 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).toString());
428 expect( repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
429 archivaConfigurationControl.replay();
430 requestControl.replay();
431 repoContentFactoryControl.replay();
432 repoRequestControl.replay();
434 resourceFactory.createResource( locator, request, response );
436 archivaConfigurationControl.verify();
437 requestControl.verify();
438 repoContentFactoryControl.verify();
439 repoRequestControl.verify();
441 fail( "A DavException with 404 error code should have been thrown." );
443 catch ( DavException e )
445 assertEquals( 404, e.getErrorCode() );
451 public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
454 // should fetch metadata
455 DavResourceLocator locator =
456 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
457 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
459 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
461 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
462 RepositoryRequest repoRequest = new RepositoryRequest( );
463 resourceFactory.setRepositoryRequest( repoRequest );
467 archivaConfigurationControl.reset();
469 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2 );
471 expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
473 expect( request.getMethod() ).andReturn( "GET" ).times( 4 );
475 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
477 expect( request.getContextPath() ).andReturn( "" ).times( 1 );
479 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
481 expect( request.getRequestURI() ).andReturn( "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" );
482 response.setHeader( "Pragma", "no-cache" );
486 response.setHeader( "Cache-Control", "no-cache" );
490 response.setDateHeader( eq("Last-Modified"), anyLong() );
493 archivaConfigurationControl.replay();
494 repoContentFactoryControl.replay();
495 requestControl.replay();
496 responseControl.replay();
498 resourceFactory.createResource( locator, request, response );
500 archivaConfigurationControl.verify();
501 repoContentFactoryControl.verify();
502 requestControl.verify();
503 responseControl.verify();
505 catch ( DavException e )
507 fail( "A DavException should not have been thrown!" );
512 public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
515 // should not fetch metadata
516 DavResourceLocator locator =
517 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
518 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
520 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
522 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
523 RepositoryRequest repoRequest = new RepositoryRequest( );
524 resourceFactory.setRepositoryRequest( repoRequest );
528 archivaConfigurationControl.reset();
530 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2 );
532 expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
534 expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
536 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
538 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
540 expect( request.getContextPath() ).andReturn( "" ).times( 2 );
542 archivaConfigurationControl.replay();
543 repoContentFactoryControl.replay();
544 requestControl.replay();
546 resourceFactory.createResource( locator, request, response );
548 archivaConfigurationControl.verify();
549 repoContentFactoryControl.verify();
550 requestControl.verify();
552 fail( "A 404 error should have been thrown!" );
554 catch ( DavException e )
556 assertEquals( 404, e.getErrorCode() );
561 public void testRequestMetadataRepoIsLegacy()
564 defaultManagedRepositoryAdmin.addManagedRepository(
565 createManagedRepository( LEGACY_REPO, Paths.get( "target/test-classes/" + LEGACY_REPO ).toString(),
566 "legacy" ), false, null );
567 DavResourceLocator locator =
568 new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
569 LEGACY_REPO, new ArchivaDavLocatorFactory() );
571 ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
573 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
574 RepositoryRequest repoRequest = new RepositoryRequest( );
575 resourceFactory.setRepositoryRequest( repoRequest );
579 archivaConfigurationControl.reset();
581 expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2 );
583 expect( repoFactory.getManagedRepositoryContent( LEGACY_REPO ) ).andReturn( legacyRepo );
585 expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
587 expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
589 expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
591 expect( request.getContextPath() ).andReturn( "" ).times( 2 );
593 archivaConfigurationControl.replay();
594 repoContentFactoryControl.replay();
595 requestControl.replay();
597 resourceFactory.createResource( locator, request, response );
599 archivaConfigurationControl.verify();
600 repoContentFactoryControl.verify();
601 requestControl.verify();
603 fail( "A 404 error should have been thrown!" );
605 catch ( DavException e )
607 assertEquals( 404, e.getErrorCode() );
611 class OverridingArchivaDavResourceFactory
612 extends ArchivaDavResourceFactory
615 OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
616 ArchivaConfiguration archivaConfiguration )
617 throws PlexusSisuBridgeException
619 super( applicationContext, plexusSisuBridge, archivaConfiguration );
623 protected boolean isAuthorized( DavServletRequest request, String repositoryId )
626 if ( RELEASES_REPO.equals( repositoryId ) )
628 throw new UnauthorizedDavException( repositoryId,
629 "You are not authenticated and authorized to access any repository." );
638 protected String getActivePrincipal( DavServletRequest request )
644 class OverridingRepositoryProxyConnectors
645 extends DefaultRepositoryProxyConnectors
648 public ProxyFetchResult fetchMetadataFromProxies( ManagedRepositoryContent repository, String logicalPath )
650 Path target = Paths.get(repository.getRepoRoot(), logicalPath );
653 FileUtils.copyFile( Paths.get( "target/test-classes/maven-metadata.xml" ).toFile(), target.toFile() );
655 catch ( IOException e )
660 return new ProxyFetchResult( target, true );