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.repository.ManagedRepositoryContent;
37 import org.apache.archiva.repository.RepositoryContentFactory;
38 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
39 import org.apache.commons.io.FileUtils;
40 import org.apache.jackrabbit.webdav.DavException;
41 import org.apache.jackrabbit.webdav.DavResourceLocator;
42 import org.apache.jackrabbit.webdav.DavServletRequest;
43 import org.apache.jackrabbit.webdav.DavServletResponse;
44 import org.easymock.MockControl;
45 import org.easymock.classextension.MockClassControl;
46 import org.junit.After;
47 import org.junit.Before;
48 import org.junit.Test;
49 import org.junit.runner.RunWith;
50 import org.springframework.context.ApplicationContext;
51 import org.springframework.test.context.ContextConfiguration;
53 import javax.inject.Inject;
55 import java.io.IOException;
56 import java.util.ArrayList;
57 import java.util.List;
60 * ArchivaDavResourceFactoryTest
62 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
63 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
64 public class ArchivaDavResourceFactoryTest
67 private static final String RELEASES_REPO = "releases";
69 private static final String INTERNAL_REPO = "internal";
71 private static final String LOCAL_MIRROR_REPO = "local-mirror";
73 private static final String LEGACY_REPO = "legacy-repo";
75 private static final String LOCAL_REPO_GROUP = "local";
77 private OverridingArchivaDavResourceFactory resourceFactory;
79 private MockControl requestControl;
81 private DavServletRequest request;
83 private MockControl repoRequestControl;
85 private RepositoryRequest repoRequest;
87 private MockControl responseControl;
89 private DavServletResponse response;
91 private MockControl archivaConfigurationControl;
93 private ArchivaConfiguration archivaConfiguration;
95 private Configuration config;
97 private MockControl repoContentFactoryControl;
99 private RepositoryContentFactory repoFactory;
102 ApplicationContext applicationContext;
105 PlexusSisuBridge plexusSisuBridge;
108 DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin;
111 RemoteRepositoryAdmin remoteRepositoryAdmin;
115 DefaultRepositoryGroupAdmin defaultRepositoryGroupAdmin;
124 requestControl = MockControl.createControl( DavServletRequest.class );
125 request = (DavServletRequest) requestControl.getMock();
127 responseControl = MockControl.createControl( DavServletResponse.class );
128 response = (DavServletResponse) responseControl.getMock();
129 responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
131 archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
132 archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
134 config = new Configuration();
135 archivaConfiguration.getConfiguration();
136 archivaConfigurationControl.setReturnValue( config, 5, 20 );
137 archivaConfiguration.save( config );
138 archivaConfigurationControl.setVoidCallable( 1, 4 );
139 archivaConfigurationControl.replay();
141 defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
142 ( (DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator() ).setArchivaConfiguration(
143 archivaConfiguration );
144 if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
146 defaultManagedRepositoryAdmin.addManagedRepository(
147 createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
148 "default" ), false, null );
150 if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
152 defaultManagedRepositoryAdmin.addManagedRepository(
153 createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
154 "default" ), false, null );
156 RepositoryGroup repoGroupConfig = new RepositoryGroup();
157 repoGroupConfig.setId( LOCAL_REPO_GROUP );
158 repoGroupConfig.addRepository( RELEASES_REPO );
159 repoGroupConfig.addRepository( INTERNAL_REPO );
161 defaultRepositoryGroupAdmin.setArchivaConfiguration( archivaConfiguration );
162 if ( defaultManagedRepositoryAdmin.getManagedRepository( LOCAL_REPO_GROUP ) == null )
164 defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
167 repoContentFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
168 repoFactory = (RepositoryContentFactory) repoContentFactoryControl.getMock();
170 repoRequestControl = MockClassControl.createControl( RepositoryRequest.class );
171 repoRequest = (RepositoryRequest) repoRequestControl.getMock();
174 new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration );
175 resourceFactory.setArchivaConfiguration( archivaConfiguration );
176 resourceFactory.setRepositoryFactory( repoFactory );
177 resourceFactory.setRepositoryRequest( repoRequest );
178 resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
179 resourceFactory.setRemoteRepositoryAdmin( remoteRepositoryAdmin );
182 private ManagedRepository createManagedRepository( String id, String location, String layout )
184 ManagedRepository repoConfig = new ManagedRepository();
185 repoConfig.setId( id );
186 repoConfig.setName( id );
187 repoConfig.setLocation( location );
188 repoConfig.setLayout( layout );
193 private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
194 throws RepositoryAdminException
196 ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
197 repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );
203 public void tearDown()
209 // MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
211 public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
214 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
215 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
216 new ArchivaDavLocatorFactory() );
218 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
219 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
223 archivaConfigurationControl.reset();
224 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
225 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
226 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
227 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
229 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
230 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
232 repoRequestControl.expectAndReturn(
233 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
235 repoRequestControl.expectAndReturn(
236 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
237 repoRequestControl.expectAndReturn(
238 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
240 repoRequestControl.expectAndReturn(
241 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
243 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
244 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
245 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
247 repoRequestControl.expectAndReturn(
248 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
251 archivaConfigurationControl.replay();
252 requestControl.replay();
253 repoContentFactoryControl.replay();
254 repoRequestControl.replay();
256 resourceFactory.createResource( locator, request, response );
258 archivaConfigurationControl.verify();
259 requestControl.verify();
260 repoContentFactoryControl.verify();
261 repoRequestControl.verify();
263 fail( "A DavException with 401 error code should have been thrown." );
265 catch ( DavException e )
267 assertEquals( 401, e.getErrorCode() );
272 public void testRepositoryGroupLastRepositoryRequiresAuthentication()
275 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
276 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
277 new ArchivaDavLocatorFactory() );
279 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
280 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
281 repoGroup.setId( LOCAL_REPO_GROUP );
282 repoGroup.addRepository( INTERNAL_REPO );
283 repoGroup.addRepository( RELEASES_REPO );
285 repoGroups.add( repoGroup );
287 config.setRepositoryGroups( repoGroups );
289 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
291 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
295 archivaConfigurationControl.reset();
296 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
297 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
298 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
299 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
301 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
303 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
304 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
305 repoRequestControl.expectAndReturn(
306 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
308 repoRequestControl.expectAndReturn(
309 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
310 repoRequestControl.expectAndReturn(
311 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
313 repoRequestControl.expectAndReturn(
314 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
316 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
317 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
318 repoRequestControl.expectAndReturn(
319 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
322 archivaConfigurationControl.replay();
323 requestControl.replay();
324 repoContentFactoryControl.replay();
325 repoRequestControl.replay();
327 resourceFactory.createResource( locator, request, response );
329 archivaConfigurationControl.verify();
330 requestControl.verify();
331 repoContentFactoryControl.verify();
332 repoRequestControl.verify();
334 fail( "A DavException with 401 error code should have been thrown." );
336 catch ( DavException e )
338 assertEquals( 401, e.getErrorCode() );
343 public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
346 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
347 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
348 new ArchivaDavLocatorFactory() );
350 defaultManagedRepositoryAdmin.addManagedRepository(
351 createManagedRepository( LOCAL_MIRROR_REPO, new File( "target/test-classes/local-mirror" ).getPath(),
352 "default" ), false, null );
354 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
355 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
356 repoGroup.setId( LOCAL_REPO_GROUP );
357 repoGroup.addRepository( INTERNAL_REPO );
358 repoGroup.addRepository( LOCAL_MIRROR_REPO );
360 repoGroups.add( repoGroup );
362 config.setRepositoryGroups( repoGroups );
364 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
365 ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
369 archivaConfigurationControl.reset();
370 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
371 requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
372 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
373 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
375 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ),
377 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
378 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
379 repoRequestControl.expectAndReturn(
380 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false,
382 repoRequestControl.expectAndReturn(
383 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 );
384 repoRequestControl.expectAndReturn(
385 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
387 repoRequestControl.expectAndReturn(
388 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
390 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
391 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
393 repoRequestControl.expectAndReturn(
394 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
396 new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
397 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
399 repoRequestControl.expectAndReturn(
400 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
403 archivaConfigurationControl.replay();
404 requestControl.replay();
405 repoContentFactoryControl.replay();
406 repoRequestControl.replay();
408 resourceFactory.createResource( locator, request, response );
410 archivaConfigurationControl.verify();
411 requestControl.verify();
412 repoContentFactoryControl.verify();
413 repoRequestControl.verify();
415 fail( "A DavException with 404 error code should have been thrown." );
417 catch ( DavException e )
419 assertEquals( 404, e.getErrorCode() );
425 public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
428 // should fetch metadata
429 DavResourceLocator locator =
430 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
431 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
433 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
435 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
436 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
437 resourceFactory.setRepositoryRequest( repoRequest );
441 archivaConfigurationControl.reset();
442 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
443 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
445 requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
446 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
447 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
448 requestControl.expectAndReturn( request.getRequestURI(),
449 "http://localhost:8080/archiva/repository/" + INTERNAL_REPO
450 + "/eclipse/jdtcore/maven-metadata.xml" );
451 response.setHeader( "Pragma", "no-cache" );
452 responseControl.setVoidCallable();
454 response.setHeader( "Cache-Control", "no-cache" );
455 responseControl.setVoidCallable();
457 long date = 2039842134;
458 response.setDateHeader( "last-modified", date );
459 responseControl.setVoidCallable();
461 archivaConfigurationControl.replay();
462 repoContentFactoryControl.replay();
463 requestControl.replay();
464 responseControl.replay();
466 resourceFactory.createResource( locator, request, response );
468 archivaConfigurationControl.verify();
469 repoContentFactoryControl.verify();
470 requestControl.verify();
471 responseControl.verify();
473 catch ( DavException e )
475 fail( "A DavException should not have been thrown!" );
480 public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
483 // should not fetch metadata
484 DavResourceLocator locator =
485 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
486 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
488 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
490 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
491 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
492 resourceFactory.setRepositoryRequest( repoRequest );
496 archivaConfigurationControl.reset();
497 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
498 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
500 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
501 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
502 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
504 archivaConfigurationControl.replay();
505 repoContentFactoryControl.replay();
506 requestControl.replay();
508 resourceFactory.createResource( locator, request, response );
510 archivaConfigurationControl.verify();
511 repoContentFactoryControl.verify();
512 requestControl.verify();
514 fail( "A 404 error should have been thrown!" );
516 catch ( DavException e )
518 assertEquals( 404, e.getErrorCode() );
523 public void testRequestMetadataRepoIsLegacy()
526 defaultManagedRepositoryAdmin.addManagedRepository(
527 createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" + LEGACY_REPO ).getPath(),
528 "legacy" ), false, null );
529 DavResourceLocator locator =
530 new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
531 LEGACY_REPO, new ArchivaDavLocatorFactory() );
533 ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
535 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
536 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
537 resourceFactory.setRepositoryRequest( repoRequest );
541 archivaConfigurationControl.reset();
542 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
543 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
545 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
546 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
547 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
549 archivaConfigurationControl.replay();
550 repoContentFactoryControl.replay();
551 requestControl.replay();
553 resourceFactory.createResource( locator, request, response );
555 archivaConfigurationControl.verify();
556 repoContentFactoryControl.verify();
557 requestControl.verify();
559 fail( "A 404 error should have been thrown!" );
561 catch ( DavException e )
563 assertEquals( 404, e.getErrorCode() );
567 class OverridingArchivaDavResourceFactory
568 extends ArchivaDavResourceFactory
571 OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
572 ArchivaConfiguration archivaConfiguration )
573 throws PlexusSisuBridgeException
575 super( applicationContext, plexusSisuBridge, archivaConfiguration );
578 protected boolean isAuthorized( DavServletRequest request, String repositoryId )
581 if ( RELEASES_REPO.equals( repositoryId ) )
583 throw new UnauthorizedDavException( repositoryId,
584 "You are not authenticated and authorized to access any repository." );
592 protected String getActivePrincipal( DavServletRequest request )
598 class OverridingRepositoryProxyConnectors
599 extends DefaultRepositoryProxyConnectors
601 public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
603 File target = new File( repository.getRepoRoot(), logicalPath );
606 FileUtils.copyFile( new File( "target/test-classes/maven-metadata.xml" ), target );
608 catch ( IOException e )