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.repository.content.legacy.LegacyPathParser;
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.MockControl;
48 import org.easymock.classextension.MockClassControl;
49 import org.junit.After;
50 import org.junit.Before;
51 import org.junit.Test;
52 import org.junit.runner.RunWith;
53 import org.springframework.context.ApplicationContext;
54 import org.springframework.test.context.ContextConfiguration;
56 import javax.inject.Inject;
58 import java.io.IOException;
59 import java.util.ArrayList;
60 import java.util.List;
63 * ArchivaDavResourceFactoryTest
65 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
66 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
67 public class ArchivaDavResourceFactoryTest
70 private static final String RELEASES_REPO = "releases";
72 private static final String INTERNAL_REPO = "internal";
74 private static final String LOCAL_MIRROR_REPO = "local-mirror";
76 private static final String LEGACY_REPO = "legacy-repo";
78 private static final String LOCAL_REPO_GROUP = "local";
80 private OverridingArchivaDavResourceFactory resourceFactory;
82 private MockControl requestControl;
84 private DavServletRequest request;
86 private MockControl repoRequestControl;
88 private RepositoryRequest repoRequest;
90 private MockControl responseControl;
92 private DavServletResponse response;
94 private MockControl archivaConfigurationControl;
96 private ArchivaConfiguration archivaConfiguration;
98 private Configuration config;
100 private MockControl repoContentFactoryControl;
102 private RepositoryContentFactory repoFactory;
105 ApplicationContext applicationContext;
108 PlexusSisuBridge plexusSisuBridge;
111 DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin;
114 RemoteRepositoryAdmin remoteRepositoryAdmin;
118 DefaultRepositoryGroupAdmin defaultRepositoryGroupAdmin;
127 requestControl = MockControl.createControl( DavServletRequest.class );
128 request = (DavServletRequest) requestControl.getMock();
130 responseControl = MockControl.createControl( DavServletResponse.class );
131 response = (DavServletResponse) responseControl.getMock();
132 responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
134 archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
135 archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
137 config = new Configuration();
138 archivaConfiguration.getConfiguration();
139 archivaConfigurationControl.setReturnValue( config, 5, 20 );
140 archivaConfiguration.save( config );
141 archivaConfigurationControl.setVoidCallable( 1, 4 );
142 archivaConfigurationControl.replay();
144 defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
145 ( (DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator() ).setArchivaConfiguration(
146 archivaConfiguration );
147 if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
149 defaultManagedRepositoryAdmin.addManagedRepository(
150 createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
151 "default" ), false, null );
153 if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
155 defaultManagedRepositoryAdmin.addManagedRepository(
156 createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
157 "default" ), false, null );
159 RepositoryGroup repoGroupConfig = new RepositoryGroup();
160 repoGroupConfig.setId( LOCAL_REPO_GROUP );
161 repoGroupConfig.addRepository( RELEASES_REPO );
162 repoGroupConfig.addRepository( INTERNAL_REPO );
164 defaultRepositoryGroupAdmin.setArchivaConfiguration( archivaConfiguration );
165 if ( defaultManagedRepositoryAdmin.getManagedRepository( LOCAL_REPO_GROUP ) == null )
167 defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
170 repoContentFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
171 repoFactory = (RepositoryContentFactory) repoContentFactoryControl.getMock();
173 repoRequestControl = MockClassControl.createControl( RepositoryRequest.class );
174 repoRequest = (RepositoryRequest) repoRequestControl.getMock();
177 new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration );
178 resourceFactory.setArchivaConfiguration( archivaConfiguration );
179 resourceFactory.setRepositoryFactory( repoFactory );
180 resourceFactory.setRepositoryRequest( repoRequest );
181 resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
182 resourceFactory.setRemoteRepositoryAdmin( remoteRepositoryAdmin );
185 private ManagedRepository createManagedRepository( String id, String location, String layout )
187 ManagedRepository repoConfig = new ManagedRepository();
188 repoConfig.setId( id );
189 repoConfig.setName( id );
190 repoConfig.setLocation( location );
191 repoConfig.setLayout( layout );
196 private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
197 throws RepositoryAdminException
199 ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
200 repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );
206 public void tearDown()
212 // MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
214 public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
217 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
218 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
219 new ArchivaDavLocatorFactory() );
221 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
222 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
226 archivaConfigurationControl.reset();
227 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
228 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
229 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
230 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
232 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
233 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
235 repoRequestControl.expectAndReturn(
236 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
238 repoRequestControl.expectAndReturn(
239 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
240 repoRequestControl.expectAndReturn(
241 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
243 repoRequestControl.expectAndReturn(
244 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
246 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
247 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
248 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
250 repoRequestControl.expectAndReturn(
251 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
254 archivaConfigurationControl.replay();
255 requestControl.replay();
256 repoContentFactoryControl.replay();
257 repoRequestControl.replay();
259 resourceFactory.createResource( locator, request, response );
261 archivaConfigurationControl.verify();
262 requestControl.verify();
263 repoContentFactoryControl.verify();
264 repoRequestControl.verify();
266 fail( "A DavException with 401 error code should have been thrown." );
268 catch ( DavException e )
270 assertEquals( 401, e.getErrorCode() );
275 public void testRepositoryGroupLastRepositoryRequiresAuthentication()
278 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
279 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
280 new ArchivaDavLocatorFactory() );
282 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
283 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
284 repoGroup.setId( LOCAL_REPO_GROUP );
285 repoGroup.addRepository( INTERNAL_REPO );
286 repoGroup.addRepository( RELEASES_REPO );
288 repoGroups.add( repoGroup );
290 config.setRepositoryGroups( repoGroups );
292 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
294 ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
298 archivaConfigurationControl.reset();
299 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
300 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
301 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
302 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
304 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
306 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
307 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
308 repoRequestControl.expectAndReturn(
309 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
311 repoRequestControl.expectAndReturn(
312 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
313 repoRequestControl.expectAndReturn(
314 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
316 repoRequestControl.expectAndReturn(
317 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
319 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
320 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
321 repoRequestControl.expectAndReturn(
322 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
325 archivaConfigurationControl.replay();
326 requestControl.replay();
327 repoContentFactoryControl.replay();
328 repoRequestControl.replay();
330 resourceFactory.createResource( locator, request, response );
332 archivaConfigurationControl.verify();
333 requestControl.verify();
334 repoContentFactoryControl.verify();
335 repoRequestControl.verify();
337 fail( "A DavException with 401 error code should have been thrown." );
339 catch ( DavException e )
341 assertEquals( 401, e.getErrorCode() );
346 public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
349 DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
350 + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
351 new ArchivaDavLocatorFactory() );
353 defaultManagedRepositoryAdmin.addManagedRepository(
354 createManagedRepository( LOCAL_MIRROR_REPO, new File( "target/test-classes/local-mirror" ).getPath(),
355 "default" ), false, null );
357 List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
358 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
359 repoGroup.setId( LOCAL_REPO_GROUP );
360 repoGroup.addRepository( INTERNAL_REPO );
361 repoGroup.addRepository( LOCAL_MIRROR_REPO );
363 repoGroups.add( repoGroup );
365 config.setRepositoryGroups( repoGroups );
367 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
368 ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
372 archivaConfigurationControl.reset();
373 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
374 requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
375 requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
376 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
378 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ),
380 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
381 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
382 repoRequestControl.expectAndReturn(
383 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false,
385 repoRequestControl.expectAndReturn(
386 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 );
387 repoRequestControl.expectAndReturn(
388 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
390 repoRequestControl.expectAndReturn(
391 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
393 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
394 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
396 repoRequestControl.expectAndReturn(
397 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
399 new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
400 "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
402 repoRequestControl.expectAndReturn(
403 repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
406 archivaConfigurationControl.replay();
407 requestControl.replay();
408 repoContentFactoryControl.replay();
409 repoRequestControl.replay();
411 resourceFactory.createResource( locator, request, response );
413 archivaConfigurationControl.verify();
414 requestControl.verify();
415 repoContentFactoryControl.verify();
416 repoRequestControl.verify();
418 fail( "A DavException with 404 error code should have been thrown." );
420 catch ( DavException e )
422 assertEquals( 404, e.getErrorCode() );
428 public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
431 // should fetch metadata
432 DavResourceLocator locator =
433 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
434 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
436 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
438 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
439 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
440 resourceFactory.setRepositoryRequest( repoRequest );
444 archivaConfigurationControl.reset();
445 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
446 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
448 requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
449 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
450 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
451 requestControl.expectAndReturn( request.getRequestURI(),
452 "http://localhost:8080/archiva/repository/" + INTERNAL_REPO
453 + "/eclipse/jdtcore/maven-metadata.xml" );
454 response.setHeader( "Pragma", "no-cache" );
455 responseControl.setVoidCallable();
457 response.setHeader( "Cache-Control", "no-cache" );
458 responseControl.setVoidCallable();
460 long date = 2039842134;
461 response.setDateHeader( "last-modified", date );
462 responseControl.setVoidCallable();
464 archivaConfigurationControl.replay();
465 repoContentFactoryControl.replay();
466 requestControl.replay();
467 responseControl.replay();
469 resourceFactory.createResource( locator, request, response );
471 archivaConfigurationControl.verify();
472 repoContentFactoryControl.verify();
473 requestControl.verify();
474 responseControl.verify();
476 catch ( DavException e )
478 fail( "A DavException should not have been thrown!" );
483 public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
486 // should not fetch metadata
487 DavResourceLocator locator =
488 new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
489 INTERNAL_REPO, new ArchivaDavLocatorFactory() );
491 ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
493 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
494 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
495 resourceFactory.setRepositoryRequest( repoRequest );
499 archivaConfigurationControl.reset();
500 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
501 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
503 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
504 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
505 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
507 archivaConfigurationControl.replay();
508 repoContentFactoryControl.replay();
509 requestControl.replay();
511 resourceFactory.createResource( locator, request, response );
513 archivaConfigurationControl.verify();
514 repoContentFactoryControl.verify();
515 requestControl.verify();
517 fail( "A 404 error should have been thrown!" );
519 catch ( DavException e )
521 assertEquals( 404, e.getErrorCode() );
526 public void testRequestMetadataRepoIsLegacy()
529 defaultManagedRepositoryAdmin.addManagedRepository(
530 createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" + LEGACY_REPO ).getPath(),
531 "legacy" ), false, null );
532 DavResourceLocator locator =
533 new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
534 LEGACY_REPO, new ArchivaDavLocatorFactory() );
536 ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
538 // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
539 RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
540 resourceFactory.setRepositoryRequest( repoRequest );
544 archivaConfigurationControl.reset();
545 archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
546 repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
548 requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
549 requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
550 requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
552 archivaConfigurationControl.replay();
553 repoContentFactoryControl.replay();
554 requestControl.replay();
556 resourceFactory.createResource( locator, request, response );
558 archivaConfigurationControl.verify();
559 repoContentFactoryControl.verify();
560 requestControl.verify();
562 fail( "A 404 error should have been thrown!" );
564 catch ( DavException e )
566 assertEquals( 404, e.getErrorCode() );
570 class OverridingArchivaDavResourceFactory
571 extends ArchivaDavResourceFactory
574 OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
575 ArchivaConfiguration archivaConfiguration )
576 throws PlexusSisuBridgeException
578 super( applicationContext, plexusSisuBridge, archivaConfiguration );
581 protected boolean isAuthorized( DavServletRequest request, String repositoryId )
584 if ( RELEASES_REPO.equals( repositoryId ) )
586 throw new UnauthorizedDavException( repositoryId,
587 "You are not authenticated and authorized to access any repository." );
595 protected String getActivePrincipal( DavServletRequest request )
601 class OverridingRepositoryProxyConnectors
602 extends DefaultRepositoryProxyConnectors
604 public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
606 File target = new File( repository.getRepoRoot(), logicalPath );
609 FileUtils.copyFile( new File( "target/test-classes/maven-metadata.xml" ), target );
611 catch ( IOException e )