]> source.dussan.org Git - archiva.git/blob
b4a355ac960e55399b717e3f292e06707d6ad876
[archiva.git] /
1 package org.apache.maven.archiva.webdav;
2
3 /*
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
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import junit.framework.TestCase;
23 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
24 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
25 import org.apache.commons.io.FileUtils;
26 import org.apache.jackrabbit.webdav.DavException;
27 import org.apache.jackrabbit.webdav.DavResourceLocator;
28 import org.apache.jackrabbit.webdav.DavServletRequest;
29 import org.apache.jackrabbit.webdav.DavServletResponse;
30 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
31 import org.apache.maven.archiva.configuration.Configuration;
32 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
33 import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
34 import org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors;
35 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
36 import org.apache.maven.archiva.repository.RepositoryContentFactory;
37 import org.apache.maven.archiva.repository.content.LegacyPathParser;
38 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
39 import org.apache.maven.archiva.repository.content.RepositoryRequest;
40 import org.easymock.MockControl;
41 import org.easymock.classextension.MockClassControl;
42 import org.junit.After;
43 import org.junit.Before;
44 import org.junit.Test;
45 import org.junit.runner.RunWith;
46 import org.springframework.context.ApplicationContext;
47 import org.springframework.test.context.ContextConfiguration;
48 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
49
50 import javax.inject.Inject;
51 import java.io.File;
52 import java.io.IOException;
53 import java.util.ArrayList;
54 import java.util.List;
55
56 /**
57  * ArchivaDavResourceFactoryTest
58  */
59 @RunWith( SpringJUnit4ClassRunner.class )
60 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
61 public class ArchivaDavResourceFactoryTest
62     extends TestCase
63 {
64     private static final String RELEASES_REPO = "releases";
65
66     private static final String INTERNAL_REPO = "internal";
67
68     private static final String LOCAL_MIRROR_REPO = "local-mirror";
69
70     private static final String LEGACY_REPO = "legacy-repo";
71
72     private static final String LOCAL_REPO_GROUP = "local";
73
74     private OverridingArchivaDavResourceFactory resourceFactory;
75
76     private MockControl requestControl;
77
78     private DavServletRequest request;
79
80     private MockControl repoRequestControl;
81
82     private RepositoryRequest repoRequest;
83
84     private MockControl responseControl;
85
86     private DavServletResponse response;
87
88     private MockControl archivaConfigurationControl;
89
90     private ArchivaConfiguration archivaConfiguration;
91
92     private Configuration config;
93
94     private MockControl repoContentFactoryControl;
95
96     private RepositoryContentFactory repoFactory;
97
98     @Inject
99     ApplicationContext applicationContext;
100
101     @Inject
102     PlexusSisuBridge plexusSisuBridge;
103
104     @Before
105     public void setUp()
106         throws Exception
107     {
108         super.setUp();
109
110         requestControl = MockControl.createControl( DavServletRequest.class );
111         request = (DavServletRequest) requestControl.getMock();
112
113         responseControl = MockControl.createControl( DavServletResponse.class );
114         response = (DavServletResponse) responseControl.getMock();
115         responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
116
117         archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
118         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
119
120         config = new Configuration();
121         config.addManagedRepository(
122             createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
123                                      "default" ) );
124         config.addManagedRepository(
125             createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
126                                      "default" ) );
127
128         RepositoryGroupConfiguration repoGroupConfig = new RepositoryGroupConfiguration();
129         repoGroupConfig.setId( LOCAL_REPO_GROUP );
130         repoGroupConfig.addRepository( RELEASES_REPO );
131         repoGroupConfig.addRepository( INTERNAL_REPO );
132
133         config.addRepositoryGroup( repoGroupConfig );
134
135         repoContentFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
136         repoFactory = (RepositoryContentFactory) repoContentFactoryControl.getMock();
137
138         repoRequestControl = MockClassControl.createControl( RepositoryRequest.class );
139         repoRequest = (RepositoryRequest) repoRequestControl.getMock();
140
141         resourceFactory =
142             new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration );
143         resourceFactory.setArchivaConfiguration( archivaConfiguration );
144         resourceFactory.setRepositoryFactory( repoFactory );
145         resourceFactory.setRepositoryRequest( repoRequest );
146         resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
147     }
148
149     private ManagedRepositoryConfiguration createManagedRepository( String id, String location, String layout )
150     {
151         ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
152         repoConfig.setId( id );
153         repoConfig.setName( id );
154         repoConfig.setLocation( location );
155         repoConfig.setLayout( layout );
156
157         return repoConfig;
158     }
159
160     private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
161     {
162         ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
163         repoContent.setRepository( config.findManagedRepositoryById( repoId ) );
164
165         return repoContent;
166     }
167
168     @After
169     public void tearDown()
170         throws Exception
171     {
172         super.tearDown();
173     }
174
175     // MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
176     @Test
177     public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
178         throws Exception
179     {
180         DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
181             + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
182                                                                     new ArchivaDavLocatorFactory() );
183
184         ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
185
186         try
187         {
188             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
189             requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
190             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
191                                                        createManagedRepositoryContent( RELEASES_REPO ) );
192             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
193             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
194             repoRequestControl.expectAndReturn(
195                 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
196                 false );
197             repoRequestControl.expectAndReturn(
198                 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
199             repoRequestControl.expectAndReturn(
200                 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
201                 null );
202             repoRequestControl.expectAndReturn(
203                 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
204                                           internalRepo ),
205                 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
206                           "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
207             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
208                                                        internalRepo );
209
210             archivaConfigurationControl.replay();
211             requestControl.replay();
212             repoContentFactoryControl.replay();
213             repoRequestControl.replay();
214
215             resourceFactory.createResource( locator, request, response );
216
217             archivaConfigurationControl.verify();
218             requestControl.verify();
219             repoContentFactoryControl.verify();
220             repoRequestControl.verify();
221
222             fail( "A DavException with 401 error code should have been thrown." );
223         }
224         catch ( DavException e )
225         {
226             assertEquals( 401, e.getErrorCode() );
227         }
228     }
229
230     @Test
231     public void testRepositoryGroupLastRepositoryRequiresAuthentication()
232         throws Exception
233     {
234         DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
235             + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
236                                                                     new ArchivaDavLocatorFactory() );
237
238         List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
239         RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
240         repoGroup.setId( LOCAL_REPO_GROUP );
241         repoGroup.addRepository( INTERNAL_REPO );
242         repoGroup.addRepository( RELEASES_REPO );
243
244         repoGroups.add( repoGroup );
245
246         config.setRepositoryGroups( repoGroups );
247
248         ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
249
250         try
251         {
252             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
253             requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
254             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
255                                                        internalRepo );
256             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
257                                                        createManagedRepositoryContent( RELEASES_REPO ) );
258             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
259             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
260             repoRequestControl.expectAndReturn(
261                 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
262                 false );
263             repoRequestControl.expectAndReturn(
264                 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
265             repoRequestControl.expectAndReturn(
266                 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
267                 null );
268             repoRequestControl.expectAndReturn(
269                 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
270                                           internalRepo ),
271                 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
272                           "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
273
274             archivaConfigurationControl.replay();
275             requestControl.replay();
276             repoContentFactoryControl.replay();
277             repoRequestControl.replay();
278
279             resourceFactory.createResource( locator, request, response );
280
281             archivaConfigurationControl.verify();
282             requestControl.verify();
283             repoContentFactoryControl.verify();
284             repoRequestControl.verify();
285
286             fail( "A DavException with 401 error code should have been thrown." );
287         }
288         catch ( DavException e )
289         {
290             assertEquals( 401, e.getErrorCode() );
291         }
292     }
293
294     @Test
295     public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
296         throws Exception
297     {
298         DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
299             + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
300                                                                     new ArchivaDavLocatorFactory() );
301
302         config.addManagedRepository(
303             createManagedRepository( LOCAL_MIRROR_REPO, new File( "target/test-classes/local-mirror" ).getPath(),
304                                      "default" ) );
305
306         List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
307         RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
308         repoGroup.setId( LOCAL_REPO_GROUP );
309         repoGroup.addRepository( INTERNAL_REPO );
310         repoGroup.addRepository( LOCAL_MIRROR_REPO );
311
312         repoGroups.add( repoGroup );
313
314         config.setRepositoryGroups( repoGroups );
315
316         ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
317         ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
318
319         try
320         {
321             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
322             requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
323             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
324                                                        internalRepo );
325             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ),
326                                                        localMirrorRepo );
327             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
328             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
329             repoRequestControl.expectAndReturn(
330                 repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false,
331                 2 );
332             repoRequestControl.expectAndReturn(
333                 repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 );
334             repoRequestControl.expectAndReturn(
335                 repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
336                 null, 2 );
337             repoRequestControl.expectAndReturn(
338                 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
339                                           internalRepo ),
340                 new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
341                           "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
342
343             repoRequestControl.expectAndReturn(
344                 repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
345                                           localMirrorRepo ),
346                 new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
347                           "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
348
349             archivaConfigurationControl.replay();
350             requestControl.replay();
351             repoContentFactoryControl.replay();
352             repoRequestControl.replay();
353
354             resourceFactory.createResource( locator, request, response );
355
356             archivaConfigurationControl.verify();
357             requestControl.verify();
358             repoContentFactoryControl.verify();
359             repoRequestControl.verify();
360
361             fail( "A DavException with 404 error code should have been thrown." );
362         }
363         catch ( DavException e )
364         {
365             assertEquals( 404, e.getErrorCode() );
366         }
367     }
368
369     // MRM-1239
370     @Test
371     public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
372         throws Exception
373     {
374         // should fetch metadata 
375         DavResourceLocator locator =
376             new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
377                                            INTERNAL_REPO, new ArchivaDavLocatorFactory() );
378
379         ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
380
381         // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
382         RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
383         resourceFactory.setRepositoryRequest( repoRequest );
384
385         try
386         {
387             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
388             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
389                                                        internalRepo );
390             requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
391             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
392             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
393             requestControl.expectAndReturn( request.getRequestURI(),
394                                             "http://localhost:8080/archiva/repository/" + INTERNAL_REPO
395                                                 + "/eclipse/jdtcore/maven-metadata.xml" );
396             response.addHeader( "Pragma", "no-cache" );
397             responseControl.setVoidCallable();
398
399             response.addHeader( "Cache-Control", "no-cache" );
400             responseControl.setVoidCallable();
401
402             long date = 2039842134;
403             response.addDateHeader( "last-modified", date );
404             responseControl.setVoidCallable();
405
406             archivaConfigurationControl.replay();
407             repoContentFactoryControl.replay();
408             requestControl.replay();
409             responseControl.replay();
410
411             resourceFactory.createResource( locator, request, response );
412
413             archivaConfigurationControl.verify();
414             repoContentFactoryControl.verify();
415             requestControl.verify();
416             responseControl.verify();
417         }
418         catch ( DavException e )
419         {
420             fail( "A DavException should not have been thrown!" );
421         }
422     }
423
424     @Test
425     public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
426         throws Exception
427     {
428         // should not fetch metadata
429         DavResourceLocator locator =
430             new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
431                                            INTERNAL_REPO, new ArchivaDavLocatorFactory() );
432
433         ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
434
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 );
438
439         try
440         {
441             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
442             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
443                                                        internalRepo );
444             requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
445             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
446             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
447
448             archivaConfigurationControl.replay();
449             repoContentFactoryControl.replay();
450             requestControl.replay();
451
452             resourceFactory.createResource( locator, request, response );
453
454             archivaConfigurationControl.verify();
455             repoContentFactoryControl.verify();
456             requestControl.verify();
457
458             fail( "A 404 error should have been thrown!" );
459         }
460         catch ( DavException e )
461         {
462             assertEquals( 404, e.getErrorCode() );
463         }
464     }
465
466     @Test
467     public void testRequestMetadataRepoIsLegacy()
468         throws Exception
469     {
470         config.addManagedRepository(
471             createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" + LEGACY_REPO ).getPath(),
472                                      "legacy" ) );
473         DavResourceLocator locator =
474             new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
475                                            LEGACY_REPO, new ArchivaDavLocatorFactory() );
476
477         ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
478
479         // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
480         RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
481         resourceFactory.setRepositoryRequest( repoRequest );
482
483         try
484         {
485             archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
486             repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
487                                                        legacyRepo );
488             requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
489             requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
490             requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
491
492             archivaConfigurationControl.replay();
493             repoContentFactoryControl.replay();
494             requestControl.replay();
495
496             resourceFactory.createResource( locator, request, response );
497
498             archivaConfigurationControl.verify();
499             repoContentFactoryControl.verify();
500             requestControl.verify();
501
502             fail( "A 404 error should have been thrown!" );
503         }
504         catch ( DavException e )
505         {
506             assertEquals( 404, e.getErrorCode() );
507         }
508     }
509
510     class OverridingArchivaDavResourceFactory
511         extends ArchivaDavResourceFactory
512     {
513
514         OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
515                                              ArchivaConfiguration archivaConfiguration )
516             throws PlexusSisuBridgeException
517         {
518             super( applicationContext, plexusSisuBridge, archivaConfiguration );
519         }
520
521         protected boolean isAuthorized( DavServletRequest request, String repositoryId )
522             throws DavException
523         {
524             if ( RELEASES_REPO.equals( repositoryId ) )
525             {
526                 throw new UnauthorizedDavException( repositoryId,
527                                                     "You are not authenticated and authorized to access any repository." );
528             }
529             else
530             {
531                 return true;
532             }
533         }
534
535         protected String getActivePrincipal( DavServletRequest request )
536         {
537             return "guest";
538         }
539     }
540
541     class OverridingRepositoryProxyConnectors
542         extends DefaultRepositoryProxyConnectors
543     {
544         public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
545         {
546             File target = new File( repository.getRepoRoot(), logicalPath );
547             try
548             {
549                 FileUtils.copyFile( new File( "target/test-classes/maven-metadata.xml" ), target );
550             }
551             catch ( IOException e )
552             {
553
554             }
555
556             return target;
557         }
558     }
559 }