<artifactId>activation</artifactId>
<scope>provided</scope>
</dependency>
- <!-- Test Scoped -->
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>httpunit</groupId>
- <artifactId>httpunit</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-quartz</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-taskqueue</artifactId>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus.redback</groupId>
- <artifactId>redback-keys-memory</artifactId>
- <version>${redback.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus.redback</groupId>
- <artifactId>redback-rbac-memory</artifactId>
- <version>${redback.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus.redback</groupId>
- <artifactId>redback-users-memory</artifactId>
- <version>${redback.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.webdav.util.MimeTypes;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * Custom Archiva MimeTypes loader for plexus-webdav's {@link MimeTypes}
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- * @todo Support custom mime types from archiva-configuration.
- *
- * @plexus.component role="org.apache.maven.archiva.web.repository.ArchivaMimeTypeLoader"
- */
-public class ArchivaMimeTypeLoader
- implements Initializable
-{
- /**
- * @plexus.requirement
- */
- private MimeTypes mimeTypes;
-
- public void initialize()
- throws InitializationException
- {
- // TODO: Make mime types loading configurable.
- // Load the mime types from archiva location.
- if ( mimeTypes.getMimeType( "sha1" ) == null )
- {
- URL url = this.getClass().getClassLoader().getResource( "/archiva-mime-types.txt" );
- if ( url == null )
- {
- url = this.getClass().getClassLoader().getResource( "archiva-mime-types.txt" );
- }
-
- if ( url != null )
- {
- try
- {
- mimeTypes.load( url.openStream() );
- }
- catch ( IOException e )
- {
- throw new InitializationException( "Unable to load archiva-mime-types.txt : " + e.getMessage(), e );
- }
- }
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-/**
- * PolicingServletRequest is for policing the incoming request for naughty bits, such as a double slashes,
- * or paths that include "/../" type syntax, or query string. Stripping out all things that are
- * not appropriate.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class PolicingServletRequest
- extends HttpServletRequestWrapper
- implements HttpServletRequest
-{
- private String fixedPathInfo;
-
- public PolicingServletRequest( HttpServletRequest originalRequest )
- {
- super( originalRequest );
-
- fixedPathInfo = originalRequest.getPathInfo();
-
- if ( StringUtils.isNotBlank( fixedPathInfo ) )
- {
- /* Perform a simple security normalization of the requested pathinfo.
- * This is to cleanup requests that use "/../" or "///" type hacks.
- */
- fixedPathInfo = FilenameUtils.normalize( fixedPathInfo );
- if ( SystemUtils.IS_OS_WINDOWS )
- {
- // Adjust paths back to unix & url format expectations (when on windows)
- fixedPathInfo = FilenameUtils.separatorsToUnix( fixedPathInfo );
- }
- }
- }
-
- @Override
- public String getPathInfo()
- {
- return fixedPathInfo;
- }
-
- @Override
- public String getQueryString()
- {
- // No query string allowed.
- return null;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ConfigurationEvent;
-import org.apache.maven.archiva.configuration.ConfigurationListener;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.webdav.*;
-import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
-import org.apache.jackrabbit.webdav.*;
-import org.codehaus.plexus.spring.PlexusToSpringUtils;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * RepositoryServlet
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServlet
- extends AbstractWebdavServlet
- implements ConfigurationListener
-{
- private Logger log = LoggerFactory.getLogger( RepositoryServlet.class );
-
- private ArchivaConfiguration configuration;
-
- private Map<String, ManagedRepositoryConfiguration> repositoryMap;
-
- private DavLocatorFactory locatorFactory;
-
- private DavResourceFactory resourceFactory;
-
- private DavSessionProvider sessionProvider;
-
- private final Object reloadLock = new Object();
-
- public void init( javax.servlet.ServletConfig servletConfig )
- throws ServletException
- {
- super.init( servletConfig );
- initServers( servletConfig );
- }
-
- /**
- * Service the given request. This method has been overridden and copy/pasted to allow better exception handling and
- * to support different realms
- *
- * @param request
- * @param response
- * @throws ServletException
- * @throws java.io.IOException
- */
- @Override
- protected void service( HttpServletRequest request, HttpServletResponse response )
- throws ServletException, IOException
- {
- WebdavRequest webdavRequest = new WebdavRequestImpl( request, getLocatorFactory() );
- // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'.
- int methodCode = DavMethods.getMethodCode( request.getMethod() );
- boolean noCache =
- DavMethods.isDeltaVMethod( webdavRequest ) &&
- !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode );
- WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
-
- try
- {
- // make sure there is a authenticated user
- if ( !getDavSessionProvider().attachSession( webdavRequest ) )
- {
- return;
- }
-
- // check matching if=header for lock-token relevant operations
- DavResource resource =
- getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest, webdavResponse );
-
- if ( !isPreconditionValid( webdavRequest, resource ) )
- {
- webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED );
- return;
- }
- if ( !execute( webdavRequest, webdavResponse, methodCode, resource ) )
- {
- super.service( request, response );
- }
-
- }
- catch ( UnauthorizedDavException e )
- {
- webdavResponse.setHeader( "WWW-Authenticate", getAuthenticateHeaderValue( e.getRepositoryName() ) );
- webdavResponse.sendError( e.getErrorCode(), e.getStatusPhrase() );
- }
- catch ( BrowserRedirectException e )
- {
- response.sendRedirect( e.getLocation() );
- }
- catch ( DavException e )
- {
- if ( e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED )
- {
- final String msg = "Should throw " + UnauthorizedDavException.class.getName();
- log.error( msg );
- webdavResponse.sendError( e.getErrorCode(), msg );
- }
- else if ( e.getCause() != null )
- {
- webdavResponse.sendError( e.getErrorCode(), e.getCause().getMessage() );
- }
- else
- {
- webdavResponse.sendError( e.getErrorCode(), e.getMessage() );
- }
- }
- finally
- {
- getDavSessionProvider().releaseSession( webdavRequest );
- }
- }
-
- public synchronized void initServers( ServletConfig servletConfig )
- {
- WebApplicationContext wac =
- WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() );
-
- configuration =
- (ArchivaConfiguration) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaConfiguration.class.getName() ) );
- configuration.addListener( this );
-
- repositoryMap = configuration.getConfiguration().getManagedRepositoriesAsMap();
-
- for ( ManagedRepositoryConfiguration repo : repositoryMap.values() )
- {
- File repoDir = new File( repo.getLocation() );
-
- if ( !repoDir.exists() )
- {
- if ( !repoDir.mkdirs() )
- {
- // Skip invalid directories.
- log( "Unable to create missing directory for " + repo.getLocation() );
- continue;
- }
- }
- }
-
- resourceFactory =
- (DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class ) );
- locatorFactory = new ArchivaDavLocatorFactory();
- sessionProvider = new ArchivaDavSessionProvider( wac );
- }
-
- public void configurationEvent( ConfigurationEvent event )
- {
- if ( event.getType() == ConfigurationEvent.SAVED )
- {
- initRepositories();
- }
- }
-
- private void initRepositories()
- {
- synchronized ( repositoryMap )
- {
- repositoryMap.clear();
- repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
- }
-
- synchronized ( reloadLock )
- {
- initServers( getServletConfig() );
- }
- }
-
- public synchronized ManagedRepositoryConfiguration getRepository( String prefix )
- {
- if ( repositoryMap.isEmpty() )
- {
- repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
- }
- return repositoryMap.get( prefix );
- }
-
- ArchivaConfiguration getConfiguration()
- {
- return configuration;
- }
-
- protected boolean isPreconditionValid( final WebdavRequest request, final DavResource davResource )
- {
- // check for read or write access to the resource when resource-based permission is implemented
-
- return true;
- }
-
- public DavSessionProvider getDavSessionProvider()
- {
- return sessionProvider;
- }
-
- public void setDavSessionProvider( final DavSessionProvider davSessionProvider )
- {
- this.sessionProvider = davSessionProvider;
- }
-
- public DavLocatorFactory getLocatorFactory()
- {
- return locatorFactory;
- }
-
- public void setLocatorFactory( final DavLocatorFactory davLocatorFactory )
- {
- locatorFactory = davLocatorFactory;
- }
-
- public DavResourceFactory getResourceFactory()
- {
- return resourceFactory;
- }
-
- public void setResourceFactory( final DavResourceFactory davResourceFactory )
- {
- resourceFactory = davResourceFactory;
- }
-
- public String getAuthenticateHeaderValue()
- {
- throw new UnsupportedOperationException();
- }
-
- public String getAuthenticateHeaderValue( String repository )
- {
- return "Basic realm=\"Repository Archiva Managed " + repository + " Repository\"";
- }
-}
<servlet>
<servlet-name>RepositoryServlet</servlet-name>
- <servlet-class>org.apache.maven.archiva.web.repository.RepositoryServlet</servlet-class>
+ <servlet-class>org.apache.maven.archiva.webdav.RepositoryServlet</servlet-class>
<!-- Loading this on startup so as to take advantage of configuration listeners -->
<load-on-startup>1</load-on-startup>
</servlet>
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
-import org.custommonkey.xmlunit.DetailedDiff;
-import org.custommonkey.xmlunit.Diff;
-
-/**
- * Abstract TestCase for RepositoryServlet Tests, Proxied, Get of Metadata.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public abstract class AbstractRepositoryServletProxiedMetadataTestCase
- extends AbstractRepositoryServletProxiedTestCase
-{
- protected RemoteRepoInfo remotePrivateSnapshots;
-
- protected void assertExpectedMetadata( String expectedMetadata, String actualMetadata )
- throws Exception
- {
- DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
- if ( !detailedDiff.similar() )
- {
- // If it isn't similar, dump the difference.
- assertEquals( expectedMetadata, actualMetadata );
- }
- // XMLAssert.assertXMLEqual( "Expected Metadata:", expectedMetadata, actualMetadata );
- }
-
- protected String requestMetadataOK( String path )
- throws Exception
- {
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
- return response.getText();
- }
-
- protected String createVersionMetadata( String groupId, String artifactId, String version )
- {
- return createVersionMetadata( groupId, artifactId, version, null, null, null );
- }
-
- protected String createVersionMetadata( String groupId, String artifactId, String version, String timestamp,
- String buildNumber, String lastUpdated )
- {
- StringBuffer buf = new StringBuffer();
-
- buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
- buf.append( "<metadata>\n" );
- buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
- buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
- buf.append( " <version>" ).append( version ).append( "</version>\n" );
-
- boolean hasSnapshot = StringUtils.isNotBlank( timestamp ) || StringUtils.isNotBlank( buildNumber );
- boolean hasLastUpdated = StringUtils.isNotBlank( lastUpdated );
-
- if ( hasSnapshot || hasLastUpdated )
- {
- buf.append( " <versioning>\n" );
- if ( hasSnapshot )
- {
- buf.append( " <snapshot>\n" );
- buf.append( " <buildNumber>" ).append( buildNumber ).append( "</buildNumber>\n" );
- buf.append( " <timestamp>" ).append( timestamp ).append( "</timestamp>\n" );
- buf.append( " </snapshot>\n" );
- }
- if ( hasLastUpdated )
- {
- buf.append( " <lastUpdated>" ).append( lastUpdated ).append( "</lastUpdated>\n" );
- }
- buf.append( " </versioning>\n" );
- }
- buf.append( "</metadata>" );
-
- return buf.toString();
- }
-
- protected String createProjectMetadata( String groupId, String artifactId, String latest, String release,
- String[] versions )
- {
- StringBuffer buf = new StringBuffer();
-
- buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
- buf.append( "<metadata>\n" );
- buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
- buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
-
- boolean hasLatest = StringUtils.isNotBlank( latest );
- boolean hasRelease = StringUtils.isNotBlank( release );
- boolean hasVersions = !ArrayUtils.isEmpty( versions );
-
- if ( hasLatest || hasRelease || hasVersions )
- {
- buf.append( " <versioning>\n" );
- if ( hasLatest )
- {
- buf.append( " <latest>" ).append( latest ).append( "</latest>\n" );
- }
- if ( hasRelease )
- {
- buf.append( " <release>" ).append( release ).append( "</release>\n" );
- }
- if ( hasVersions )
- {
- buf.append( " <versions>\n" );
- for ( String availVersion : versions )
- {
- buf.append( " <version>" ).append( availVersion ).append( "</version>\n" );
- }
- buf.append( " </versions>\n" );
- }
- buf.append( " </versioning>\n" );
- }
- buf.append( "</metadata>" );
-
- return buf.toString();
- }
-
- protected String createGroupMetadata( String groupId, String[] plugins )
- {
- StringBuffer buf = new StringBuffer();
-
- buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
- buf.append( "<metadata>\n" );
- buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
-
- boolean hasPlugins = !ArrayUtils.isEmpty( plugins );
-
- if ( hasPlugins )
- {
- buf.append( " <plugins>\n" );
- for ( String plugin : plugins )
- {
- buf.append( " <plugin>\n" );
- buf.append( " <prefix>" ).append( plugin ).append( "</prefix>\n" );
- buf.append( " <artifactId>" ).append( plugin + "-maven-plugin" ).append( "</artifactId>\n" );
- buf.append( " <name>" ).append( "The " + plugin + " Plugin" ).append( "</name>\n" );
- buf.append( " </plugin>\n" );
- }
- buf.append( " </plugins>\n" );
- }
- buf.append( "</metadata>" );
-
- return buf.toString();
- }
-
- protected void setupPrivateSnapshotsRemoteRepo()
- throws Exception
- {
- remotePrivateSnapshots = createServer( "private-snapshots" );
-
- assertServerSetupCorrectly( remotePrivateSnapshots );
- archivaConfiguration.getConfiguration().addRemoteRepository( remotePrivateSnapshots.config );
- setupCleanRepo( remotePrivateSnapshots.root );
- }
-
-// private void assertGetProxiedSnapshotMetadata( int expectation, boolean hasManagedCopy,
-// long deltaManagedToRemoteTimestamp )
-// throws Exception
-// {
-// // --- Setup
-// setupSnapshotsRemoteRepo();
-// setupCleanInternalRepo();
-//
-// String resourcePath = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
-// String expectedRemoteContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n"
-// + " <groupId>org.apache.maven.plugins</groupId>\n" + " <artifactId>maven-assembly-plugin</artifactId>\n"
-// + " <version>2.2-beta-2-SNAPSHOT</version>\n" + " <versioning>\n" + " <snapshot>\n"
-// + " <timestamp>20071017.162810</timestamp>\n" + " <buildNumber>20</buildNumber>\n"
-// + " </snapshot>\n" + " <lastUpdated>20071017162814</lastUpdated>\n" + " </versioning>\n"
-// + "</metadata>";
-// String expectedManagedContents = null;
-// File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
-//
-// if ( hasManagedCopy )
-// {
-// expectedManagedContents = "<metadata>\n" + " <groupId>org.apache.maven.plugins</groupId>\n"
-// + " <artifactId>maven-assembly-plugin</artifactId>\n" + " <version>2.2-beta-2-SNAPSHOT</version>\n"
-// + "</metadata>";
-//
-// File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
-// managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
-// }
-//
-// setupConnector( REPOID_INTERNAL, remoteSnapshots );
-// saveConfiguration();
-//
-// // --- Execution
-// // process the response code later, not via an exception.
-// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-//
-// WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
-// WebResponse response = sc.getResponse( request );
-//
-// // --- Verification
-//
-// switch ( expectation )
-// {
-// case EXPECT_MANAGED_CONTENTS:
-// assertResponseOK( response );
-// assertTrue( "Invalid Test Case: Can't expect managed contents with "
-// + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
-// String actualContents = response.getText();
-// XMLAssert.assertXMLEqual( expectedManagedContents, actualContents );
-// // assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
-// break;
-// case EXPECT_REMOTE_CONTENTS:
-// assertResponseOK( response );
-// assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
-// break;
-// case EXPECT_NOT_FOUND:
-// assertResponseNotFound( response );
-// assertManagedFileNotExists( repoRootInternal, resourcePath );
-// break;
-// }
-// }
-
- protected void tearDown()
- throws Exception
- {
- shutdownServer( remotePrivateSnapshots );
-
- super.tearDown();
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.WebConversation;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.policies.CachedFailuresPolicy;
-import org.apache.maven.archiva.policies.ChecksumPolicy;
-import org.apache.maven.archiva.policies.ReleasesPolicy;
-import org.apache.maven.archiva.policies.SnapshotsPolicy;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.bio.SocketConnector;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.servlet.DefaultServlet;
-import org.mortbay.jetty.servlet.ServletHandler;
-
-import java.io.File;
-
-/**
- * AbstractRepositoryServletProxiedTestCase
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public abstract class AbstractRepositoryServletProxiedTestCase
- extends AbstractRepositoryServletTestCase
-{
- class RemoteRepoInfo
- {
- public String id;
-
- public String url;
-
- public String context;
-
- public Server server;
-
- public File root;
-
- public RemoteRepositoryConfiguration config;
- }
-
- protected static final long ONE_SECOND = ( 1000 /* milliseconds */ );
-
- protected static final long ONE_MINUTE = ( ONE_SECOND * 60 );
-
- protected static final long ONE_HOUR = ( ONE_MINUTE * 60 );
-
- protected static final long ONE_DAY = ( ONE_HOUR * 24 );
-
- protected static final long OVER_ONE_HOUR = ( ONE_HOUR + ONE_MINUTE );
-
- protected static final long OVER_ONE_DAY = ( ONE_DAY + ONE_HOUR );
-
- protected static final long OLDER = ( -1 );
-
- protected static final long NEWER = 0;
-
- protected static final int EXPECT_MANAGED_CONTENTS = 1;
-
- protected static final int EXPECT_REMOTE_CONTENTS = 2;
-
- protected static final int EXPECT_NOT_FOUND = 3;
-
- protected static final boolean HAS_MANAGED_COPY = true;
-
- protected static final boolean NO_MANAGED_COPY = false;
-
- protected RemoteRepoInfo remoteCentral;
-
- protected RemoteRepoInfo remoteSnapshots;
-
- protected RemoteRepoInfo remotePrivateSnapshots;
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- protected RemoteRepoInfo createServer( String id )
- throws Exception
- {
- RemoteRepoInfo repo = new RemoteRepoInfo();
- repo.id = id;
- repo.context = "/" + id;
- repo.root = getTestFile( "target/remote-repos/" + id + "/" );
-
- // Remove exising root contents.
- if ( repo.root.exists() )
- {
- FileUtils.deleteDirectory( repo.root );
- }
-
- // Establish root directory.
- if ( !repo.root.exists() )
- {
- repo.root.mkdirs();
- }
-
- repo.server = new Server();
- ContextHandlerCollection contexts = new ContextHandlerCollection();
- repo.server.setHandler( contexts );
-
- SocketConnector connector = new SocketConnector();
- connector.setPort( 0 ); // 0 means, choose and empty port. (we'll find out which, later)
-
- repo.server.setConnectors( new Connector[] { connector } );
-
- ContextHandler context = new ContextHandler();
- context.setContextPath( repo.context );
- context.setResourceBase( repo.root.getAbsolutePath() );
- context.setAttribute( "dirAllowed", true );
- context.setAttribute( "maxCacheSize", 0 );
- ServletHandler servlet = new ServletHandler();
- servlet.addServletWithMapping( DefaultServlet.class.getName(), "/" );
- context.setHandler( servlet );
- contexts.addHandler( context );
-
- repo.server.start();
-
- int port = connector.getLocalPort();
- repo.url = "http://localhost:" + port + repo.context;
- System.out.println( "Remote HTTP Server started on " + repo.url );
-
- repo.config = createRemoteRepository( repo.id, "Testable [" + repo.id + "] Remote Repo", repo.url );
-
- return repo;
- }
-
- protected void assertServerSetupCorrectly( RemoteRepoInfo remoteRepo )
- throws Exception
- {
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( remoteRepo.url );
- assertResponseOK( response );
- }
-
- private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy, String snapshotsPolicy )
- {
- ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
- connector.setSourceRepoId( repoId );
- connector.setTargetRepoId( remoteRepo.id );
- connector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, releasesPolicy );
- connector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotsPolicy );
- connector.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE );
- connector.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO );
-
- archivaConfiguration.getConfiguration().addProxyConnector( connector );
- }
-
- protected void shutdownServer( RemoteRepoInfo remoteRepo )
- {
- if ( remoteRepo != null )
- {
- if ( remoteRepo.server != null )
- {
- if ( remoteRepo.server.isRunning() )
- {
- try
- {
- remoteRepo.server.stop();
- // int graceful = remoteRepo.server.getGracefulShutdown();
- // System.out.println( "server set to graceful shutdown: " + graceful );
- // remoteRepo = null;
- }
- catch ( Exception e )
- {
- e.printStackTrace( System.err );
- }
- }
- }
- }
- }
-
- protected File populateRepo( RemoteRepoInfo remoteRepo, String path, String contents )
- throws Exception
- {
- File destFile = new File( remoteRepo.root, path );
- destFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( destFile, contents, null );
- return destFile;
- }
-
- protected void setupCentralRemoteRepo()
- throws Exception
- {
- remoteCentral = createServer( "central" );
-
- assertServerSetupCorrectly( remoteCentral );
- archivaConfiguration.getConfiguration().addRemoteRepository( remoteCentral.config );
- setupCleanRepo( remoteCentral.root );
- }
-
- protected void setupConnector( String repoId, RemoteRepoInfo remoteRepo )
- {
- setupConnector( repoId, remoteRepo, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS );
- }
-
- protected void setupReleaseConnector( String managedRepoId, RemoteRepoInfo remoteRepo, String releasePolicy )
- {
- setupConnector( managedRepoId, remoteRepo, releasePolicy, SnapshotsPolicy.ALWAYS );
- }
-
- protected void setupSnapshotConnector( String managedRepoId, RemoteRepoInfo remoteRepo, String snapshotsPolicy )
- {
- setupConnector( managedRepoId, remoteRepo, ReleasesPolicy.ALWAYS, snapshotsPolicy );
- }
-
- protected void setupSnapshotsRemoteRepo()
- throws Exception
- {
- remoteSnapshots = createServer( "snapshots" );
-
- assertServerSetupCorrectly( remoteSnapshots );
- archivaConfiguration.getConfiguration().addRemoteRepository( remoteSnapshots.config );
- setupCleanRepo( remoteSnapshots.root );
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- shutdownServer( remoteCentral );
- shutdownServer( remoteSnapshots );
- super.tearDown();
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.WebResponse;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.ServletUnitClient;
-import net.sf.ehcache.CacheManager;
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * AbstractRepositoryServletTestCase
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public abstract class AbstractRepositoryServletTestCase
- extends PlexusInSpringTestCase
-{
- protected static final String REPOID_INTERNAL = "internal";
-
- protected ServletUnitClient sc;
-
- protected File repoRootInternal;
-
- private ServletRunner sr;
-
- protected ArchivaConfiguration archivaConfiguration;
-
- protected void saveConfiguration()
- throws Exception
- {
- saveConfiguration( archivaConfiguration );
- }
-
- protected void assertFileContents( String expectedContents, File repoRoot, String path )
- throws IOException
- {
- File actualFile = new File( repoRoot, path );
- assertTrue( "File <" + actualFile.getAbsolutePath() + "> should exist.", actualFile.exists() );
- assertTrue( "File <" + actualFile.getAbsolutePath() + "> should be a file (not a dir/link/device/etc).",
- actualFile.isFile() );
-
- String actualContents = FileUtils.readFileToString( actualFile, null );
- assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents );
- }
-
- protected void assertRepositoryValid( RepositoryServlet servlet, String repoId )
- {
- ManagedRepositoryConfiguration repository = servlet.getRepository( repoId );
- assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
- File repoRoot = new File( repository.getLocation() );
- assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repoRoot
- .exists()
- && repoRoot.isDirectory() );
- }
-
- protected void assertResponseOK( WebResponse response )
- {
- assertNotNull( "Should have recieved a response", response );
- assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() );
- }
-
- protected void assertResponseNotFound( WebResponse response )
- {
- assertNotNull( "Should have recieved a response", response );
- assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response
- .getResponseCode() );
- }
-
- protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location )
- {
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
- repo.setId( id );
- repo.setName( name );
- repo.setLocation( location.getAbsolutePath() );
- return repo;
- }
-
- protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
- {
- RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
- repo.setId( id );
- repo.setName( name );
- repo.setUrl( url );
- return repo;
- }
-
- protected void dumpResponse( WebResponse response )
- {
- System.out.println( "---(response)---" );
- System.out.println( "" + response.getResponseCode() + " " + response.getResponseMessage() );
-
- String headerNames[] = response.getHeaderFieldNames();
- for ( String headerName : headerNames )
- {
- System.out.println( "[header] " + headerName + ": " + response.getHeaderField( headerName ) );
- }
-
- System.out.println( "---(text)---" );
- try
- {
- System.out.println( response.getText() );
- }
- catch ( IOException e )
- {
- System.err.print( "[Exception] : " );
- e.printStackTrace( System.err );
- }
- }
-
- protected void saveConfiguration( ArchivaConfiguration archivaConfiguration )
- throws Exception
- {
- archivaConfiguration.save( archivaConfiguration.getConfiguration() );
- }
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
- System.setProperty( "appserver.base", appserverBase );
-
- File testConf = getTestFile( "src/test/resources/repository-archiva.xml" );
- File testConfDest = new File( appserverBase, "conf/archiva.xml" );
- FileUtils.copyFile( testConf, testConfDest );
-
- archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
- repoRootInternal = new File( appserverBase, "data/repositories/internal" );
- Configuration config = archivaConfiguration.getConfiguration();
-
- config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
- saveConfiguration( archivaConfiguration );
-
- CacheManager.getInstance().removeCache( "url-failures-cache" );
-
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- sr = new ServletRunner( getTestFile( "src/test/webapp/WEB-INF/web.xml" ) );
- sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
- sc = sr.newClient();
- }
-
- @Override
- protected String getPlexusConfigLocation()
- {
- return "org/apache/maven/archiva/web/repository/RepositoryServletTest.xml";
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- if ( sc != null )
- {
- sc.clearContents();
- }
-
- if ( sr != null )
- {
- sr.shutDown();
- }
-
- super.tearDown();
- }
-
- protected void setupCleanRepo( File repoRootDir )
- throws IOException
- {
- FileUtils.deleteDirectory( repoRootDir );
- if ( !repoRootDir.exists() )
- {
- repoRootDir.mkdirs();
- }
- }
-
- protected void assertManagedFileNotExists( File repoRootInternal, String resourcePath )
- {
- File repoFile = new File( repoRootInternal, resourcePath );
- assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.", repoFile
- .exists() );
- }
-
- protected void setupCleanInternalRepo()
- throws Exception
- {
- setupCleanRepo( repoRootInternal );
- }
-
- protected File populateRepo( File repoRootManaged, String path, String contents )
- throws Exception
- {
- File destFile = new File( repoRootManaged, path );
- destFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( destFile, contents, null );
- return destFile;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.redback.authentication.AuthenticationDataSource;
-import org.codehaus.plexus.redback.authentication.AuthenticationException;
-import org.codehaus.plexus.redback.authentication.AuthenticationResult;
-import org.codehaus.plexus.redback.authorization.AuthorizationException;
-import org.codehaus.plexus.redback.authorization.AuthorizationResult;
-import org.codehaus.plexus.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.memory.MemoryKeyManager;
-import org.codehaus.plexus.redback.policy.AccountLockedException;
-import org.codehaus.plexus.redback.policy.DefaultUserSecurityPolicy;
-import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
-import org.codehaus.plexus.redback.system.DefaultSecuritySession;
-import org.codehaus.plexus.redback.system.DefaultSecuritySystem;
-import org.codehaus.plexus.redback.system.SecuritySession;
-import org.codehaus.plexus.redback.system.SecuritySystem;
-import org.codehaus.plexus.redback.users.UserManager;
-import org.codehaus.plexus.redback.users.UserNotFoundException;
-import org.codehaus.plexus.redback.users.memory.MemoryUserManager;
-
-/**
- * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
- * for every request to respond as success / true.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- *
- * @plexus.component
- * role="org.codehaus.plexus.redback.system.SecuritySystem"
- */
-public class BypassSecuritySystem
- extends DefaultSecuritySystem
- implements SecuritySystem
-{
- private KeyManager bypassKeyManager;
- private UserSecurityPolicy bypassPolicy;
- private UserManager bypassUserManager;
-
- public BypassSecuritySystem()
- {
- bypassKeyManager = new MemoryKeyManager();
- bypassPolicy = new DefaultUserSecurityPolicy();
- bypassUserManager = new MemoryUserManager();
- }
-
- public SecuritySession authenticate( AuthenticationDataSource source )
- throws AuthenticationException, UserNotFoundException, AccountLockedException
- {
- AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
- return new DefaultSecuritySession( result );
- }
-
- public AuthorizationResult authorize( SecuritySession session, Object permission )
- throws AuthorizationException
- {
- return new AuthorizationResult( true, session.getUser(), null );
- }
-
- public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
- throws AuthorizationException
- {
- return new AuthorizationResult( true, session.getUser(), null );
- }
-
- public String getAuthenticatorId()
- {
- return "bypass-authenticator";
- }
-
- public String getAuthorizerId()
- {
- return "bypass-authorizer";
- }
-
- public KeyManager getKeyManager()
- {
- return bypassKeyManager;
- }
-
- public UserSecurityPolicy getPolicy()
- {
- return bypassPolicy;
- }
-
- public String getUserManagementId()
- {
- return "bypass-managementid";
- }
-
- public UserManager getUserManager()
- {
- return bypassUserManager;
- }
-
- public boolean isAuthenticated( AuthenticationDataSource source )
- throws AuthenticationException, UserNotFoundException, AccountLockedException
- {
- // Always true
- return true;
- }
-
- public boolean isAuthorized( SecuritySession session, Object permission )
- throws AuthorizationException
- {
- // Always true
- return true;
- }
-
- public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
- throws AuthorizationException
- {
- // Always true
- return true;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.webdav.util.MimeTypes;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-
-/**
- * ArchivaMimeTypesTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class MimeTypesLoaderTest
- extends PlexusInSpringTestCase
-{
- public void testArchivaTypes()
- throws Exception
- {
- lookup( MimeTypes.class );
- MimeTypes mimeTypes = (MimeTypes) lookup( MimeTypes.class );
- assertNotNull( mimeTypes );
-
- // Test for some added types.
- assertEquals( "sha1", "text/plain", mimeTypes.getMimeType( "foo.sha1" ) );
- assertEquals( "md5", "text/plain", mimeTypes.getMimeType( "foo.md5" ) );
- assertEquals( "pgp", "application/pgp-encrypted", mimeTypes.getMimeType( "foo.pgp" ) );
- assertEquals( "jar", "application/java-archive", mimeTypes.getMimeType( "foo.jar" ) );
- assertEquals( "Default", "application/octet-stream", mimeTypes.getMimeType(".SomeUnknownExtension"));
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebLink;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import java.io.File;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * RepositoryServletBrowseTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletBrowseTest
- extends AbstractRepositoryServletTestCase
-{
- public void testBrowse()
- throws Exception
- {
- new File( repoRootInternal, "org/apache/archiva" ).mkdirs();
- new File( repoRootInternal, "net/sourceforge" ).mkdirs();
- new File( repoRootInternal, "commons-lang" ).mkdirs();
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" );
- WebResponse response = sc.getResponse( request );
- assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
-
- // dumpResponse( response );
-
- WebLink links[] = response.getLinks();
- String expectedLinks[] = new String[] { "./commons-lang/", "./net/", "./org/" };
-
- assertEquals( "Links.length", expectedLinks.length, links.length );
- for ( int i = 0; i < links.length; i++ )
- {
- assertEquals( "Link[" + i + "]", expectedLinks[i], links[i].getURLString() );
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.PutMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import java.io.InputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Deploy / Put Test cases for RepositoryServlet.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletDeployTest
- extends AbstractRepositoryServletTestCase
-{
- public void testPutWithMissingParentCollection()
- throws Exception
- {
- setupCleanRepo( repoRootInternal );
-
- String putUrl = "http://machine.com/repository/internal/path/to/artifact.jar";
- InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
- assertNotNull( "artifact.jar inputstream", is );
-
- WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
-
- WebResponse response = sc.getResponse( request );
- assertResponseCreated( response );
- assertFileContents( "artifact.jar\n", repoRootInternal, "path/to/artifact.jar" );
- }
-
- protected void assertResponseCreated( WebResponse response )
- {
- assertNotNull( "Should have recieved a response", response );
- assertEquals( "Should have been a 201/CREATED response code.", HttpServletResponse.SC_CREATED, response
- .getResponseCode() );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-
-/**
- * RepositoryServletTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletNoProxyMetadataTest
- extends AbstractRepositoryServletTestCase
-{
- public void testGetVersionMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
- String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
-
- File checksumFile = new File( repoRootInternal, commonsLangMetadata );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetProjectMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
-
- File checksumFile = new File( repoRootInternal, commonsLangMetadata );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetGroupMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "metadata-for-commons-lang-group";
-
- File checksumFile = new File( repoRootInternal, commonsLangMetadata );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetSnapshotVersionMetadataDefaultLayout()
- throws Exception
- {
- String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
- String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
-
- File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-
-/**
- * RepositoryServletTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletNoProxyTest
- extends AbstractRepositoryServletTestCase
-{
- public void testGetNoProxyChecksumDefaultLayout()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- File checksumFile = new File( repoRootInternal, commonsLangSha1 );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
- }
-
- public void testGetNoProxyChecksumLegacyLayout()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- File checksumFile = new File( repoRootInternal, commonsLangSha1 );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
- + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
- }
-
- public void testGetNoProxyVersionedMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
- String expectedMetadataContents = "dummy-versioned-metadata";
-
- File metadataFile = new File( repoRootInternal, commonsLangMetadata );
- metadataFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetNoProxyProjectMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-project-metadata";
-
- File metadataFile = new File( repoRootInternal, commonsLangMetadata );
- metadataFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetNoProxyGroupMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-group-metadata";
-
- File metadataFile = new File( repoRootInternal, commonsLangMetadata );
- metadataFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
- }
-
- public void testGetNoProxyArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- public void testGetNoProxyArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
- + "commons-lang/jars/commons-lang-2.1.jar" );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- public void testGetNoProxySnapshotArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- public void testGetNoProxySnapshotArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
- + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- File artifactFile = new File( repoRootInternal, commonsLangJar );
- artifactFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
- + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
- }
-
- /**
- * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
- */
- public void testGetNoProxyDualExtensionDefaultLayout()
- throws Exception
- {
- String expectedContents = "the-contents-of-the-dual-extension";
- String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
-
- File checksumFile = new File( repoRootInternal, dualExtensionPath );
- checksumFile.getParentFile().mkdirs();
-
- FileUtils.writeStringToFile( checksumFile, expectedContents, null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedContents, response.getText() );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Metadata, exists on local managed repository only.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedMetadataLocalOnlyTest
- extends AbstractRepositoryServletProxiedMetadataTestCase
-{
- public void testGetProxiedSnapshotVersionMetadataLocalOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
- String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
- "4.0-alpha-1-SNAPSHOT" );
-
- populateRepo( repoRootInternal, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedVersionMetadataLocalOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
- String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
- "4.0-alpha-2" );
-
- populateRepo( repoRootInternal, path, expectedMetadata );
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedProjectMetadataLocalOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
- String version = "1.0-alpha-4";
- String release = "1.0-alpha-4";
- String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin", version,
- release, new String[] { "1.0-alpha-4" } );
-
- populateRepo( repoRootInternal, path, expectedMetadata );
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedGroupMetadataLocalOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/maven-metadata.xml";
- String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
-
- populateRepo( repoRootInternal, path, expectedMetadata );
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedMetadataRemoteOnlyTest
- extends AbstractRepositoryServletProxiedMetadataTestCase
-{
- public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
- String version = "4.0-alpha-1-SNAPSHOT";
- String timestamp = "20040305.112233";
- String buildNumber = "2";
- String lastUpdated = "20040305112233";
- String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
- version, timestamp, buildNumber, lastUpdated);
-
- File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
- saveConfiguration();
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
- String version = "2.2-beta-2-SNAPSHOT";
- String timestamp = "20071017.162810";
- String buildNumber = "20";
- String lastUpdated = "20071017162810";
- String expectedMetadata = createVersionMetadata( "org.apache.maven.plugins", "maven-assembly-plugin", version,
- timestamp, buildNumber, lastUpdated );
-
- File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
- saveConfiguration();
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedVersionMetadataRemoteOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
- String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
- "4.0-alpha-2" );
-
- File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
- saveConfiguration();
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedProjectMetadataRemoteOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
- String latest = "1.0-alpha-4";
- String release = "1.0-alpha-4";
- String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin",
- latest, release, new String[] { "1.0-alpha-4" } );
-
- File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
- saveConfiguration();
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-
- public void testGetProxiedGroupMetadataRemoteOnly()
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupPrivateSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String path = "org/apache/archiva/maven-metadata.xml";
- String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
-
- File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
-
- setupConnector( REPOID_INTERNAL, remoteSnapshots );
- setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
- saveConfiguration();
-
- // --- Execution
- String actualMetadata = requestMetadataOK( path );
-
- // --- Verification
- assertExpectedMetadata( expectedMetadata, actualMetadata );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.maven.archiva.policies.SnapshotsPolicy;
-
-import java.io.File;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedPluginSnapshotPolicyTest
- extends AbstractRepositoryServletProxiedTestCase
-{
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
- HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_HOUR ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOncePass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy )
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String resourcePath = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42.jar";
- String expectedRemoteContents = "archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42|jar-remote-contents";
- String expectedManagedContents = null;
- File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
-
- if ( hasManagedCopy )
- {
- expectedManagedContents = "archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42|jar-managed-contents";
- File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
- managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
- }
-
- setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
- saveConfiguration();
-
- // --- Execution
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
- WebResponse response = sc.getResponse( request );
-
- // --- Verification
-
- switch ( expectation )
- {
- case EXPECT_MANAGED_CONTENTS:
- assertResponseOK( response );
- assertTrue( "Invalid Test Case: Can't expect managed contents with "
- + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
- assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
- break;
- case EXPECT_REMOTE_CONTENTS:
- assertResponseOK( response );
- assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
- break;
- case EXPECT_NOT_FOUND:
- assertResponseNotFound( response );
- assertManagedFileNotExists( repoRootInternal, resourcePath );
- break;
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.maven.archiva.policies.ReleasesPolicy;
-
-import java.io.File;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedReleasePolicyTest
- extends AbstractRepositoryServletProxiedTestCase
-{
- public void testGetProxiedReleaseArtifactPolicyAlwaysManagedNewer()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.ALWAYS, HAS_MANAGED_COPY,
- ( NEWER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyAlwaysManagedOlder()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ALWAYS, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyAlwaysNoManagedContent()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ALWAYS, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyDailyFail()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.DAILY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyDailyNoManagedContent()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyDailyPass()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyRejectFail()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyRejectNoManagedContentFail()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_NOT_FOUND, ReleasesPolicy.NEVER, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyRejectPass()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyHourlyFail()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.HOURLY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyHourlyNoManagedContent()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyHourlyPass()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_HOUR ) );
- }
-
- public void testGetProxiedReleaseArtifactPolicyOnceFail()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.ONCE, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyOnceNoManagedContent()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedReleaseArtifactPolicyOncePass()
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- private void assertGetProxiedReleaseArtifactWithPolicy( int expectation, String releasePolicy,
- boolean hasManagedCopy )
- throws Exception
- {
- assertGetProxiedReleaseArtifactWithPolicy( expectation, releasePolicy, hasManagedCopy, 0 );
- }
-
- private void assertGetProxiedReleaseArtifactWithPolicy( int expectation, String releasePolicy,
- boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
- throws Exception
- {
- // --- Setup
- setupCentralRemoteRepo();
- setupCleanInternalRepo();
-
- String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
- String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
- String expectedManagedContents = null;
- File remoteFile = populateRepo( remoteCentral, resourcePath, expectedRemoteContents );
-
- if ( hasManagedCopy )
- {
- expectedManagedContents = "archiva-test-1.0|jar-managed-contents";
- File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
- managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
- }
-
- setupReleaseConnector( REPOID_INTERNAL, remoteCentral, releasePolicy );
- saveConfiguration();
-
- // --- Execution
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
- WebResponse response = sc.getResponse( request );
-
- // --- Verification
-
- switch ( expectation )
- {
- case EXPECT_MANAGED_CONTENTS:
- assertResponseOK( response );
- assertTrue( "Invalid Test Case: Can't expect managed contents with "
- + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
- assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
- break;
- case EXPECT_REMOTE_CONTENTS:
- assertResponseOK( response );
- assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
- break;
- case EXPECT_NOT_FOUND:
- assertResponseNotFound( response );
- assertManagedFileNotExists( repoRootInternal, resourcePath );
- break;
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.maven.archiva.policies.ReleasesPolicy;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id: RepositoryServletProxiedReleasePolicyTest.java 590908 2007-11-01 06:21:26Z joakime $
- */
-public class RepositoryServletProxiedRelocatedTest
- extends AbstractRepositoryServletProxiedTestCase
-{
- public void testGetProxiedReleaseArtifactPolicyOncePass()
- throws Exception
- {
- // --- Setup
- setupCentralRemoteRepo();
- setupCleanInternalRepo();
-
- String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
- String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
- populateRepo( remoteCentral, resourcePath, expectedRemoteContents );
-
- resourcePath = "archiva/test/1.0/test-1.0.pom";
- String pom = "<project>" +
- "<modelVersion>4.0.0</modelVersion>" +
- "<groupId>archiva</groupId>" +
- "<artifactId>test</artifactId>" +
- "<version>1.0</version>" +
- "<distributionManagement>" +
- "<relocation>" +
- "<groupId>org.apache.archiva</groupId>" +
- "</relocation>" +
- "</distributionManagement>" +
- "</project>";
- populateRepo( remoteCentral, resourcePath, pom );
-
- resourcePath = "archiva/jars/test-1.0.jar";
-
- setupReleaseConnector( REPOID_INTERNAL, remoteCentral, ReleasesPolicy.ONCE );
- saveConfiguration();
-
- // --- Execution
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
- WebResponse response = sc.getResponse( request );
-
- // --- Verification
- assertResponseOK( response );
- assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.maven.archiva.policies.SnapshotsPolicy;
-
-import java.io.File;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Snapshot Artifacts, with varying policy settings.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedSnapshotPolicyTest
- extends AbstractRepositoryServletProxiedTestCase
-{
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
- HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_HOUR ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOncePass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy )
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String resourcePath = "org/apache/archiva/test/2.0-SNAPSHOT/test-2.0-SNAPSHOT.jar";
- String expectedRemoteContents = "archiva-test-2.0-SNAPSHOT|jar-remote-contents";
- String expectedManagedContents = null;
- File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
-
- if ( hasManagedCopy )
- {
- expectedManagedContents = "archiva-test-2.0-SNAPSHOT|jar-managed-contents";
- File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
- managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
- }
-
- setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
- saveConfiguration();
-
- // --- Execution
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
- WebResponse response = sc.getResponse( request );
-
- // --- Verification
-
- switch ( expectation )
- {
- case EXPECT_MANAGED_CONTENTS:
- assertResponseOK( response );
- assertTrue( "Invalid Test Case: Can't expect managed contents with "
- + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
- assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
- break;
- case EXPECT_REMOTE_CONTENTS:
- assertResponseOK( response );
- assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
- break;
- case EXPECT_NOT_FOUND:
- assertResponseNotFound( response );
- assertManagedFileNotExists( repoRootInternal, resourcePath );
- break;
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import org.apache.maven.archiva.policies.SnapshotsPolicy;
-
-import java.io.File;
-
-/**
- * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings.
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
- extends AbstractRepositoryServletProxiedTestCase
-{
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
- HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_DAY ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
- HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( NEWER * ONE_MINUTE ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
- ( OLDER * OVER_ONE_HOUR ) );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- public void testGetProxiedSnapshotsArtifactPolicyOncePass()
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy )
- throws Exception
- {
- assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
- }
-
- private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
- boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
- throws Exception
- {
- // --- Setup
- setupSnapshotsRemoteRepo();
- setupCleanInternalRepo();
-
- String resourcePath = "org/apache/archiva/test/3.0-SNAPSHOT/test-3.0-20070822.033400-42.jar";
- String expectedRemoteContents = "archiva-test-3.0-20070822.033400-42|jar-remote-contents";
- String expectedManagedContents = null;
- File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
-
- if ( hasManagedCopy )
- {
- expectedManagedContents = "archiva-test-3.0-20070822.033400-42|jar-managed-contents";
- File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
- managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
- }
-
- setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
- saveConfiguration();
-
- // --- Execution
- // process the response code later, not via an exception.
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
- WebResponse response = sc.getResponse( request );
-
- // --- Verification
-
- switch ( expectation )
- {
- case EXPECT_MANAGED_CONTENTS:
- assertResponseOK( response );
- assertTrue( "Invalid Test Case: Can't expect managed contents with "
- + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
- assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
- break;
- case EXPECT_REMOTE_CONTENTS:
- assertResponseOK( response );
- assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
- break;
- case EXPECT_NOT_FOUND:
- assertResponseNotFound( response );
- assertManagedFileNotExists( repoRootInternal, resourcePath );
- break;
- }
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.PutMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-
-/**
- * RepositoryServletRepositoryGroupTest
- *
- * Test Case 1. Accessing a valid repository group root url (e.g. http://machine.com/repository/repository-group/) returns a Bad Request (HTTP 400)
- * Test Case 2. Accessing an invalid repository group root url is forwarded to managed repository checking (this is not covered here)
- * Test Case 3. Accessing an artifact in a valid repository group will iterate over the managed repositories in the repository group
- * Test Case 3.a. If an invalid managed repository is encountered (managed repository doesn't exist),
- * a Not Found (HTTP 404) is returned and the iteration is broken
- * Test Case 3.b. If an artifact is not found in a valid managed repository (after proxying, etc.),
- * a Not Found (HTTP 404) is set but not returned yet, the iteration continues to the next managed repository.
- * The Not Found (HTTP 404) is returned after exhausting all valid managed repositories
- * Test Case 3.c. If an artifact is found in a valid managed repository,
- * the artifact is returned, the iteration is broken and any Not Found (HTTP 404) is disregarded
- * Test Case 4. Accessing a valid repository group with any http write method returns a Bad Request (HTTP 400)
- *
- * @author
- *
- */
-public class RepositoryServletRepositoryGroupTest
- extends AbstractRepositoryServletTestCase
-{
- protected File repoRootFirst;
-
- protected File repoRootLast;
-
- protected File repoRootInvalid;
-
- protected static final String MANAGED_REPO_FIRST = "first";
-
- protected static final String MANAGED_REPO_LAST = "last";
-
- protected static final String MANAGED_REPO_INVALID = "invalid";
-
- protected static final String REPO_GROUP_WITH_VALID_REPOS = "group-with-valid-repos";
-
- protected static final String REPO_GROUP_WITH_INVALID_REPOS = "group-with-invalid-repos";
-
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- String appserverBase = System.getProperty( "appserver.base" );
-
- Configuration configuration = archivaConfiguration.getConfiguration();
-
- repoRootFirst = new File( appserverBase, "data/repositories/" + MANAGED_REPO_FIRST );
- repoRootLast = new File( appserverBase, "data/repositories/" + MANAGED_REPO_LAST );
-
- configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
- configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
-
- List<String> managedRepoIds = new ArrayList<String>();
- managedRepoIds.add( MANAGED_REPO_FIRST );
- managedRepoIds.add( MANAGED_REPO_LAST );
-
- configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_VALID_REPOS, managedRepoIds ) );
-
- // Create the repository group with an invalid managed repository
- repoRootInvalid = new File( appserverBase, "data/repositories/" + MANAGED_REPO_INVALID );
- ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid );
-
- configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
- configuration.addManagedRepository( managedRepositoryConfiguration );
- configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
-
- List<String> invalidManagedRepoIds = new ArrayList<String>();
- invalidManagedRepoIds.add( MANAGED_REPO_FIRST );
- invalidManagedRepoIds.add( MANAGED_REPO_INVALID );
- invalidManagedRepoIds.add( MANAGED_REPO_LAST );
-
- configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds ) );
-
- configuration.removeManagedRepository( managedRepositoryConfiguration );
- FileUtils.deleteDirectory( repoRootInvalid );
-
- saveConfiguration( archivaConfiguration );
- }
-
- protected void tearDown()
- throws Exception
- {
- setupCleanRepo( repoRootFirst );
- setupCleanRepo( repoRootLast );
-
- super.tearDown();
- }
-
- /*
- * Test Case 3.c
- */
- public void testGetFromFirstManagedRepositoryReturnOk()
- throws Exception
- {
- String resourceName = "dummy/dummy-first-resource/1.0/dummy-first-resource-1.0.txt";
-
- File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
- dummyInternalResourceFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
- WebResponse response = sc.getResponse( request );
-
- assertResponseOK( response );
- assertEquals( "Expected file contents", "first", response.getText() );
- }
-
- /*
- * Test Case 3.c
- */
- public void testGetFromLastManagedRepositoryReturnOk()
- throws Exception
- {
- String resourceName = "dummy/dummy-last-resource/1.0/dummy-last-resource-1.0.txt";
-
- File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
- dummyReleasesResourceFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
- WebResponse response = sc.getResponse( request );
-
- assertResponseOK( response );
- assertEquals( "Expected file contents", "last", response.getText() );
- }
-
- /*
- * Test Case 3.b
- */
- public void testGetFromValidRepositoryGroupReturnNotFound()
- throws Exception
- {
- String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
- WebResponse response = sc.getResponse( request );
-
- assertResponseNotFound( response );
- }
-
- /*
- * Test Case 3.a
- */
- public void testGetInvalidManagedRepositoryInGroupReturnNotFound()
- throws Exception
- {
- String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName );
- WebResponse response = sc.getResponse( request );
-
- assertResponseNotFound( response );
- }
-
- /*
- * Test Case 4
- */
- public void testPutValidRepositoryGroupReturnBadRequest()
- throws Exception
- {
- String resourceName = "dummy/dummy-put-resource/1.0/dummy-put-resource-1.0.txt";
- String putUrl = "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName;
- InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
-
- WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" );
- WebResponse response = sc.getResponse( request );
-
- assertResponseMethodNotAllowed( response );
- }
-
- public void testBrowseRepositoryGroup()
- throws Exception
- {
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS );
- WebResponse response = sc.getResponse( request );
-
- assertNotNull( "Should have received a response", response );
- assertEquals( "Should have been an 401 response code.", HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode() );
- }
-
- protected void assertResponseMethodNotAllowed( WebResponse response )
- {
- assertNotNull( "Should have recieved a response", response );
- assertEquals( "Should have been an 405/Method Not Allowed response code.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getResponseCode() );
- }
-
- protected RepositoryGroupConfiguration createRepositoryGroup( String id, List<String> repositories )
- {
- RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration();
- repoGroupConfiguration.setId( id );
- repoGroupConfiguration.setRepositories( repositories );
- return repoGroupConfiguration;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/**
- * RepositoryServletSecurityTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletSecurityTest
- extends AbstractRepositoryServletTestCase
-{
- public void testSecuredGet()
- {
-
- }
-
- public void testSecuredBrowse()
- {
-
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpNotFoundException;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-
-import java.io.File;
-
-/**
- * RepositoryServletTest
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class RepositoryServletTest
- extends AbstractRepositoryServletTestCase
-{
- private static final String REQUEST_PATH = "http://machine.com/repository/internal/";
-
- private static final String NEW_REPOSITORY_ID = "new-id";
-
- private static final String NEW_REPOSITORY_NAME = "New Repository";
-
- public void testGetRepository()
- throws Exception
- {
- RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
- assertNotNull( servlet );
-
- assertRepositoryValid( servlet, REPOID_INTERNAL );
- }
-
- public void testGetRepositoryAfterDelete()
- throws Exception
- {
- RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
- assertNotNull( servlet );
-
- ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
- Configuration c = archivaConfiguration.getConfiguration();
- c.removeManagedRepository( c.findManagedRepositoryById( REPOID_INTERNAL ) );
- saveConfiguration( archivaConfiguration );
-
- ManagedRepositoryConfiguration repository = servlet.getRepository( REPOID_INTERNAL );
- assertNull( repository );
- }
-
- public void testGetRepositoryAfterAdd()
- throws Exception
- {
- RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
- assertNotNull( servlet );
-
- ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
- Configuration c = archivaConfiguration.getConfiguration();
- ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
- repo.setId( NEW_REPOSITORY_ID );
- repo.setName( NEW_REPOSITORY_NAME );
- File repoRoot = new File( getBasedir(), "target/test-repository-root" );
- if ( !repoRoot.exists() )
- {
- repoRoot.mkdirs();
- }
- repo.setLocation( repoRoot.getAbsolutePath() );
- c.addManagedRepository( repo );
- saveConfiguration( archivaConfiguration );
-
- ManagedRepositoryConfiguration repository = servlet.getRepository( NEW_REPOSITORY_ID );
- assertNotNull( repository );
- assertEquals( NEW_REPOSITORY_NAME, repository.getName() );
-
- // check other is still intact
- assertRepositoryValid( servlet, REPOID_INTERNAL );
- }
-
- public void testGetRepositoryInvalidPathPassthroughPresent()
- throws Exception
- {
- String path = REQUEST_PATH + ".index/filecontent/segments.gen";
-
- populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );
-
- WebRequest request = new GetMethodWebRequest( path );
- WebResponse response = sc.getResponse( request );
- assertResponseOK( response );
- assertEquals( "index file", response.getText() );
- }
-
- public void testGetRepositoryInvalidPathPassthroughMissing()
- throws Exception
- {
- String path = REQUEST_PATH + ".index/filecontent/foo.bar";
-
- WebRequest request = new GetMethodWebRequest( path );
- WebResponse response = sc.getResponse( request );
- assertResponseNotFound( response );
- assertEquals( "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path.", response.getResponseMessage() );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
-
-import java.util.List;
-
-public class StubRepositoryContentConsumers
- extends RepositoryContentConsumers
-{
- public List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
- {
- return getAvailableKnownConsumers();
- }
-
- public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
- {
- return getAvailableInvalidConsumers();
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavServletRequest;
-import org.apache.maven.archiva.webdav.ArchivaDavResourceFactory;
-
-/**
- * UnauthenticatedDavResourceFactory
- *
- * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
- * @version $Id:
- */
-public class UnauthenticatedDavResourceFactory
- extends ArchivaDavResourceFactory
-{
- @Override
- protected boolean isAuthorized( DavServletRequest request, String repositoryId )
- throws DavException
- {
- return true;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiva.webdav.ArchivaDavSessionProvider;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.WebdavRequest;
-import org.springframework.web.context.WebApplicationContext;
-
-/**
- * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
- */
-public class UnauthenticatedDavSessionProvider extends ArchivaDavSessionProvider
-{
- public UnauthenticatedDavSessionProvider(WebApplicationContext applicationContext)
- {
- super(applicationContext);
- }
-
- @Override
- public boolean attachSession( WebdavRequest request )
- throws DavException
- {
- return true;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.web.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
-import javax.servlet.ServletConfig;
-
-/**
- * UnauthenticatedRepositoryServlet
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- */
-public class UnauthenticatedRepositoryServlet
- extends RepositoryServlet
-{
- @Override
- public synchronized void initServers( ServletConfig servletConfig )
- {
- super.initServers(servletConfig);
-
- WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() );
-
- UnauthenticatedDavSessionProvider sessionProvider = new UnauthenticatedDavSessionProvider(wac);
- setDavSessionProvider(sessionProvider);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<plexus>
- <components>
- <!--
- | Logger manager
- -->
- <component>
- <role>org.codehaus.plexus.logging.LoggerManager</role>
- <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
- <lifecycle-handler>basic</lifecycle-handler>
- </component>
-
- <!--
- | Configuration
- -->
- <component>
- <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
- <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.registry.Registry</role>
- <role-hint>configured</role-hint>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
- <field-name>prePolicies</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
- <field-name>postPolicies</field-name>
- </requirement>
- </requirements>
- </component>
- <component>
- <role>org.codehaus.plexus.registry.Registry</role>
- <role-hint>configured</role-hint>
- <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
- <configuration>
- <properties>
- <system/>
- <xml fileName="${appserver.base}/conf/archiva.xml"
- config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
- </properties>
- </configuration>
- </component>
-
- <component>
- <role>org.apache.maven.archiva.webdav.DavServerManager</role>
- <role-hint>default</role-hint>
- <implementation>org.apache.maven.archiva.webdav.DefaultDavServerManager</implementation>
- <description>DefaultDavServerManager</description>
- <configuration>
- <provider-hint>proxied</provider-hint>
- </configuration>
- </component>
-
- <component>
- <role>org.codehaus.plexus.cache.Cache</role>
- <role-hint>url-failures-cache</role-hint>
- <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
- <description>URL Failure Cache</description>
- <configuration>
- <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
- <disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
- <disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
- <eternal>false</eternal>
- <max-elements-in-memory>1000</max-elements-in-memory>
- <memory-eviction-policy>LRU</memory-eviction-policy>
- <name>url-failures-cache</name>
- <overflow-to-disk>false</overflow-to-disk>
- <!-- 45 minutes = 2700 seconds -->
- <time-to-idle-seconds>2700</time-to-idle-seconds>
- <!-- 30 minutes = 1800 seconds -->
- <time-to-live-seconds>1800</time-to-live-seconds>
- </configuration>
- </component>
-
-
- <!-- Don't drag in the world just to test this -->
- <component>
- <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
- <role-hint>default</role-hint>
- <implementation>org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers</implementation>
- </component>
-
- <!-- TODO: shouldn't need so many components just to use in-memory - is flaky since these are auto-generated -->
- <component>
- <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
- <role-hint>default</role-hint>
- <implementation>org.codehaus.plexus.redback.system.DefaultSecuritySystem</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.authentication.AuthenticationManager</role>
- <field-name>authnManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
- <role-hint>rbac</role-hint>
- <field-name>authorizer</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.users.UserManager</role>
- <role-hint>memory</role-hint>
- <field-name>userManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.keys.KeyManager</role>
- <role-hint>memory</role-hint>
- <field-name>keyManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
- <field-name>policy</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.authentication.Authenticator</role>
- <role-hint>user-manager</role-hint>
- <implementation>org.codehaus.plexus.redback.authentication.users.UserManagerAuthenticator</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.users.UserManager</role>
- <role-hint>memory</role-hint>
- <field-name>userManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
- <field-name>securityPolicy</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.authentication.Authenticator</role>
- <role-hint>keystore</role-hint>
- <implementation>org.codehaus.plexus.redback.authentication.keystore.KeyStoreAuthenticator</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.keys.KeyManager</role>
- <role-hint>memory</role-hint>
- <field-name>keystore</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.users.UserManager</role>
- <role-hint>memory</role-hint>
- <field-name>userManager</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
- <role-hint>default</role-hint>
- <implementation>org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator
- </implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.users.UserManager</role>
- <role-hint>memory</role-hint>
- <field-name>userManager</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
- <role-hint>rbac</role-hint>
- <implementation>org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
- <role-hint>memory</role-hint>
- <field-name>manager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.users.UserManager</role>
- <role-hint>memory</role-hint>
- <field-name>userManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
- <role-hint>default</role-hint>
- <field-name>evaluator</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.role.RoleManager</role>
- <role-hint>default</role-hint>
- <implementation>org.codehaus.plexus.redback.role.DefaultRoleManager</implementation>
- <instantiation-strategy>singleton</instantiation-strategy>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.role.merger.RoleModelMerger</role>
- <role-hint>default</role-hint>
- <field-name>modelMerger</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.role.validator.RoleModelValidator</role>
- <role-hint>default</role-hint>
- <field-name>modelValidator</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
- <role-hint>default</role-hint>
- <field-name>modelProcessor</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
- <role-hint>default</role-hint>
- <field-name>templateProcessor</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
- <role-hint>memory</role-hint>
- <field-name>rbacManager</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.PlexusContainer</role>
- <field-name>container</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
- <role-hint>default</role-hint>
- <implementation>org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
- <role-hint>memory</role-hint>
- <field-name>rbacManager</field-name>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
- <role-hint>default</role-hint>
- <implementation>org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
- <role-hint>memory</role-hint>
- <field-name>rbacManager</field-name>
- </requirement>
- </requirements>
- </component>
- </components>
-</plexus>
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<plexus>
- <components>
- <!--
- | Logger manager
- -->
- <component>
- <role>org.codehaus.plexus.logging.LoggerManager</role>
- <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
- <lifecycle-handler>basic</lifecycle-handler>
- </component>
-
- <!--
- | Configuration
- -->
- <component>
- <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
- <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
- <requirements>
- <requirement>
- <role>org.codehaus.plexus.registry.Registry</role>
- <role-hint>configured</role-hint>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
- <field-name>prePolicies</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
- <field-name>postPolicies</field-name>
- </requirement>
- </requirements>
- </component>
- <component>
- <role>org.codehaus.plexus.registry.Registry</role>
- <role-hint>configured</role-hint>
- <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
- <configuration>
- <properties>
- <system/>
- <xml fileName="${appserver.base}/conf/archiva.xml"
- config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
- </properties>
- </configuration>
- </component>
-
- <component>
- <role>org.apache.maven.archiva.webdav.DavServerManager</role>
- <role-hint>default</role-hint>
- <implementation>org.apache.maven.archiva.webdav.DefaultDavServerManager</implementation>
- <description>DefaultDavServerManager</description>
- <requirements>
- <requirement>
- <role>org.apache.maven.archiva.webdav.DavServerComponent</role>
- <role-hint>proxied</role-hint>
- </requirement>
- </requirements>
- </component>
-
- <component>
- <role>org.codehaus.plexus.cache.Cache</role>
- <role-hint>url-failures-cache</role-hint>
- <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
- <description>URL Failure Cache</description>
- <configuration>
- <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
- <disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
- <disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
- <eternal>false</eternal>
- <max-elements-in-memory>1000</max-elements-in-memory>
- <memory-eviction-policy>LRU</memory-eviction-policy>
- <name>url-failures-cache</name>
- <overflow-to-disk>false</overflow-to-disk>
- <!-- 45 minutes = 2700 seconds -->
- <time-to-idle-seconds>2700</time-to-idle-seconds>
- <!-- 30 minutes = 1800 seconds -->
- <time-to-live-seconds>1800</time-to-live-seconds>
- </configuration>
- </component>
-
-
- <!-- Don't drag in the world just to test this -->
- <component>
- <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
- <role-hint>default</role-hint>
- <implementation>org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers</implementation>
- </component>
-
- <component>
- <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
- <role-hint>default</role-hint>
- <implementation>org.apache.maven.archiva.web.repository.BypassSecuritySystem</implementation>
- </component>
-
- <component>
- <role>org.apache.maven.archiva.webdav.ArchivaDavResourceFactory</role>
- <implementation>org.apache.maven.archiva.web.repository.UnauthenticatedDavResourceFactory</implementation>
- <requirements>
- <requirement>
- <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
- <field-name>archivaConfiguration</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
- <field-name>repositoryFactory</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.repository.content.RepositoryRequest</role>
- <field-name>repositoryRequest</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.proxy.RepositoryProxyConnectors</role>
- <field-name>connectors</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.repository.metadata.MetadataTools</role>
- <field-name>metadataTools</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.security.ServletAuthenticator</role>
- <field-name>servletAuth</field-name>
- </requirement>
- <requirement>
- <role>org.apache.maven.archiva.webdav.util.MimeTypes</role>
- <field-name>mimeTypes</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator</role>
- <role-hint>basic</role-hint>
- <field-name>httpAuth</field-name>
- </requirement>
- </requirements>
- </component>
- </components>
-</plexus>
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<configuration>
-
- <version>2</version>
-
- <repositoryScanning>
- <fileTypes>
- <fileType>
- <id>artifacts</id>
- <patterns>
- <pattern>**/*.pom</pattern>
- <pattern>**/*.jar</pattern>
- <pattern>**/*.ear</pattern>
- <pattern>**/*.war</pattern>
- <pattern>**/*.car</pattern>
- <pattern>**/*.sar</pattern>
- <pattern>**/*.mar</pattern>
- <pattern>**/*.rar</pattern>
- <pattern>**/*.dtd</pattern>
- <pattern>**/*.tld</pattern>
- <pattern>**/*.tar.gz</pattern>
- <pattern>**/*.tar.bz2</pattern>
- <pattern>**/*.zip</pattern>
- </patterns>
- </fileType>
- <fileType>
- <id>indexable-content</id>
- <patterns>
- <pattern>**/*.txt</pattern>
- <pattern>**/*.TXT</pattern>
- <pattern>**/*.block</pattern>
- <pattern>**/*.config</pattern>
- <pattern>**/*.pom</pattern>
- <pattern>**/*.xml</pattern>
- <pattern>**/*.xsd</pattern>
- <pattern>**/*.dtd</pattern>
- <pattern>**/*.tld</pattern>
- </patterns>
- </fileType>
- <fileType>
- <id>auto-remove</id>
- <patterns>
- <pattern>**/*.bak</pattern>
- <pattern>**/*~</pattern>
- <pattern>**/*-</pattern>
- </patterns>
- </fileType>
- <fileType>
- <id>ignored</id>
- <patterns>
- <pattern>**/.htaccess</pattern>
- <pattern>**/KEYS</pattern>
- <pattern>**/*.rb</pattern>
- <pattern>**/*.sh</pattern>
- <pattern>**/.svn/**</pattern>
- <pattern>**/.DAV/**</pattern>
- </patterns>
- </fileType>
- </fileTypes>
- <knownContentConsumers>
- <knownContentConsumer>update-db-artifact</knownContentConsumer>
- <knownContentConsumer>create-missing-checksums</knownContentConsumer>
- <knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
- <knownContentConsumer>validate-checksum</knownContentConsumer>
- <knownContentConsumer>validate-signature</knownContentConsumer>
- <knownContentConsumer>index-content</knownContentConsumer>
- <knownContentConsumer>auto-remove</knownContentConsumer>
- <knownContentConsumer>auto-rename</knownContentConsumer>
- </knownContentConsumers>
- <invalidContentConsumers>
- <invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
- </invalidContentConsumers>
- </repositoryScanning>
-
- <databaseScanning>
- <cronExpression>0 0 * * * ?</cronExpression>
- <unprocessedConsumers>
- <unprocessedConsumer>index-artifact</unprocessedConsumer>
- <unprocessedConsumer>update-db-project</unprocessedConsumer>
- <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
- <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
- <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
- <unprocessedConsumer>index-public-methods</unprocessedConsumer>
- </unprocessedConsumers>
- <cleanupConsumers>
- <cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer>
- <cleanupConsumer>not-present-remove-db-project</cleanupConsumer>
- <cleanupConsumer>not-present-remove-indexed</cleanupConsumer>
- </cleanupConsumers>
- </databaseScanning>
-
-</configuration>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus.redback</groupId>
+ <artifactId>redback-keys-memory</artifactId>
+ <version>${redback.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus.redback</groupId>
+ <artifactId>redback-rbac-memory</artifactId>
+ <version>${redback.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus.redback</groupId>
+ <artifactId>redback-users-memory</artifactId>
+ <version>${redback.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<!-- Required by it.could classes -->
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ConfigurationEvent;
+import org.apache.maven.archiva.configuration.ConfigurationListener;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
+import org.apache.jackrabbit.webdav.*;
+import org.codehaus.plexus.spring.PlexusToSpringUtils;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * RepositoryServlet
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServlet
+ extends AbstractWebdavServlet
+ implements ConfigurationListener
+{
+ private Logger log = LoggerFactory.getLogger( RepositoryServlet.class );
+
+ private ArchivaConfiguration configuration;
+
+ private Map<String, ManagedRepositoryConfiguration> repositoryMap;
+
+ private DavLocatorFactory locatorFactory;
+
+ private DavResourceFactory resourceFactory;
+
+ private DavSessionProvider sessionProvider;
+
+ private final Object reloadLock = new Object();
+
+ public void init( javax.servlet.ServletConfig servletConfig )
+ throws ServletException
+ {
+ super.init( servletConfig );
+ initServers( servletConfig );
+ }
+
+ /**
+ * Service the given request. This method has been overridden and copy/pasted to allow better exception handling and
+ * to support different realms
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws java.io.IOException
+ */
+ @Override
+ protected void service( HttpServletRequest request, HttpServletResponse response )
+ throws ServletException, IOException
+ {
+ WebdavRequest webdavRequest = new WebdavRequestImpl( request, getLocatorFactory() );
+ // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'.
+ int methodCode = DavMethods.getMethodCode( request.getMethod() );
+ boolean noCache =
+ DavMethods.isDeltaVMethod( webdavRequest ) &&
+ !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode );
+ WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
+
+ try
+ {
+ // make sure there is a authenticated user
+ if ( !getDavSessionProvider().attachSession( webdavRequest ) )
+ {
+ return;
+ }
+
+ // check matching if=header for lock-token relevant operations
+ DavResource resource =
+ getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest, webdavResponse );
+
+ if ( !isPreconditionValid( webdavRequest, resource ) )
+ {
+ webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+ if ( !execute( webdavRequest, webdavResponse, methodCode, resource ) )
+ {
+ super.service( request, response );
+ }
+
+ }
+ catch ( UnauthorizedDavException e )
+ {
+ webdavResponse.setHeader( "WWW-Authenticate", getAuthenticateHeaderValue( e.getRepositoryName() ) );
+ webdavResponse.sendError( e.getErrorCode(), e.getStatusPhrase() );
+ }
+ catch ( BrowserRedirectException e )
+ {
+ response.sendRedirect( e.getLocation() );
+ }
+ catch ( DavException e )
+ {
+ if ( e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED )
+ {
+ final String msg = "Should throw " + UnauthorizedDavException.class.getName();
+ log.error( msg );
+ webdavResponse.sendError( e.getErrorCode(), msg );
+ }
+ else if ( e.getCause() != null )
+ {
+ webdavResponse.sendError( e.getErrorCode(), e.getCause().getMessage() );
+ }
+ else
+ {
+ webdavResponse.sendError( e.getErrorCode(), e.getMessage() );
+ }
+ }
+ finally
+ {
+ getDavSessionProvider().releaseSession( webdavRequest );
+ }
+ }
+
+ public synchronized void initServers( ServletConfig servletConfig )
+ {
+ WebApplicationContext wac =
+ WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() );
+
+ configuration =
+ (ArchivaConfiguration) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaConfiguration.class.getName() ) );
+ configuration.addListener( this );
+
+ repositoryMap = configuration.getConfiguration().getManagedRepositoriesAsMap();
+
+ for ( ManagedRepositoryConfiguration repo : repositoryMap.values() )
+ {
+ File repoDir = new File( repo.getLocation() );
+
+ if ( !repoDir.exists() )
+ {
+ if ( !repoDir.mkdirs() )
+ {
+ // Skip invalid directories.
+ log( "Unable to create missing directory for " + repo.getLocation() );
+ continue;
+ }
+ }
+ }
+
+ resourceFactory =
+ (DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class ) );
+ locatorFactory = new ArchivaDavLocatorFactory();
+ sessionProvider = new ArchivaDavSessionProvider( wac );
+ }
+
+ public void configurationEvent( ConfigurationEvent event )
+ {
+ if ( event.getType() == ConfigurationEvent.SAVED )
+ {
+ initRepositories();
+ }
+ }
+
+ private void initRepositories()
+ {
+ synchronized ( repositoryMap )
+ {
+ repositoryMap.clear();
+ repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
+ }
+
+ synchronized ( reloadLock )
+ {
+ initServers( getServletConfig() );
+ }
+ }
+
+ public synchronized ManagedRepositoryConfiguration getRepository( String prefix )
+ {
+ if ( repositoryMap.isEmpty() )
+ {
+ repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
+ }
+ return repositoryMap.get( prefix );
+ }
+
+ ArchivaConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+ protected boolean isPreconditionValid( final WebdavRequest request, final DavResource davResource )
+ {
+ // check for read or write access to the resource when resource-based permission is implemented
+
+ return true;
+ }
+
+ public DavSessionProvider getDavSessionProvider()
+ {
+ return sessionProvider;
+ }
+
+ public void setDavSessionProvider( final DavSessionProvider davSessionProvider )
+ {
+ this.sessionProvider = davSessionProvider;
+ }
+
+ public DavLocatorFactory getLocatorFactory()
+ {
+ return locatorFactory;
+ }
+
+ public void setLocatorFactory( final DavLocatorFactory davLocatorFactory )
+ {
+ locatorFactory = davLocatorFactory;
+ }
+
+ public DavResourceFactory getResourceFactory()
+ {
+ return resourceFactory;
+ }
+
+ public void setResourceFactory( final DavResourceFactory davResourceFactory )
+ {
+ resourceFactory = davResourceFactory;
+ }
+
+ public String getAuthenticateHeaderValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAuthenticateHeaderValue( String repository )
+ {
+ return "Basic realm=\"Repository Archiva Managed " + repository + " Repository\"";
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+
+/**
+ * Abstract TestCase for RepositoryServlet Tests, Proxied, Get of Metadata.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRepositoryServletProxiedMetadataTestCase
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ protected RemoteRepoInfo remotePrivateSnapshots;
+
+ protected void assertExpectedMetadata( String expectedMetadata, String actualMetadata )
+ throws Exception
+ {
+ DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
+ if ( !detailedDiff.similar() )
+ {
+ // If it isn't similar, dump the difference.
+ assertEquals( expectedMetadata, actualMetadata );
+ }
+ // XMLAssert.assertXMLEqual( "Expected Metadata:", expectedMetadata, actualMetadata );
+ }
+
+ protected String requestMetadataOK( String path )
+ throws Exception
+ {
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+ return response.getText();
+ }
+
+ protected String createVersionMetadata( String groupId, String artifactId, String version )
+ {
+ return createVersionMetadata( groupId, artifactId, version, null, null, null );
+ }
+
+ protected String createVersionMetadata( String groupId, String artifactId, String version, String timestamp,
+ String buildNumber, String lastUpdated )
+ {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
+ buf.append( "<metadata>\n" );
+ buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
+ buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
+ buf.append( " <version>" ).append( version ).append( "</version>\n" );
+
+ boolean hasSnapshot = StringUtils.isNotBlank( timestamp ) || StringUtils.isNotBlank( buildNumber );
+ boolean hasLastUpdated = StringUtils.isNotBlank( lastUpdated );
+
+ if ( hasSnapshot || hasLastUpdated )
+ {
+ buf.append( " <versioning>\n" );
+ if ( hasSnapshot )
+ {
+ buf.append( " <snapshot>\n" );
+ buf.append( " <buildNumber>" ).append( buildNumber ).append( "</buildNumber>\n" );
+ buf.append( " <timestamp>" ).append( timestamp ).append( "</timestamp>\n" );
+ buf.append( " </snapshot>\n" );
+ }
+ if ( hasLastUpdated )
+ {
+ buf.append( " <lastUpdated>" ).append( lastUpdated ).append( "</lastUpdated>\n" );
+ }
+ buf.append( " </versioning>\n" );
+ }
+ buf.append( "</metadata>" );
+
+ return buf.toString();
+ }
+
+ protected String createProjectMetadata( String groupId, String artifactId, String latest, String release,
+ String[] versions )
+ {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
+ buf.append( "<metadata>\n" );
+ buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
+ buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
+
+ boolean hasLatest = StringUtils.isNotBlank( latest );
+ boolean hasRelease = StringUtils.isNotBlank( release );
+ boolean hasVersions = !ArrayUtils.isEmpty( versions );
+
+ if ( hasLatest || hasRelease || hasVersions )
+ {
+ buf.append( " <versioning>\n" );
+ if ( hasLatest )
+ {
+ buf.append( " <latest>" ).append( latest ).append( "</latest>\n" );
+ }
+ if ( hasRelease )
+ {
+ buf.append( " <release>" ).append( release ).append( "</release>\n" );
+ }
+ if ( hasVersions )
+ {
+ buf.append( " <versions>\n" );
+ for ( String availVersion : versions )
+ {
+ buf.append( " <version>" ).append( availVersion ).append( "</version>\n" );
+ }
+ buf.append( " </versions>\n" );
+ }
+ buf.append( " </versioning>\n" );
+ }
+ buf.append( "</metadata>" );
+
+ return buf.toString();
+ }
+
+ protected String createGroupMetadata( String groupId, String[] plugins )
+ {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
+ buf.append( "<metadata>\n" );
+ buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
+
+ boolean hasPlugins = !ArrayUtils.isEmpty( plugins );
+
+ if ( hasPlugins )
+ {
+ buf.append( " <plugins>\n" );
+ for ( String plugin : plugins )
+ {
+ buf.append( " <plugin>\n" );
+ buf.append( " <prefix>" ).append( plugin ).append( "</prefix>\n" );
+ buf.append( " <artifactId>" ).append( plugin + "-maven-plugin" ).append( "</artifactId>\n" );
+ buf.append( " <name>" ).append( "The " + plugin + " Plugin" ).append( "</name>\n" );
+ buf.append( " </plugin>\n" );
+ }
+ buf.append( " </plugins>\n" );
+ }
+ buf.append( "</metadata>" );
+
+ return buf.toString();
+ }
+
+ protected void setupPrivateSnapshotsRemoteRepo()
+ throws Exception
+ {
+ remotePrivateSnapshots = createServer( "private-snapshots" );
+
+ assertServerSetupCorrectly( remotePrivateSnapshots );
+ archivaConfiguration.getConfiguration().addRemoteRepository( remotePrivateSnapshots.config );
+ setupCleanRepo( remotePrivateSnapshots.root );
+ }
+
+// private void assertGetProxiedSnapshotMetadata( int expectation, boolean hasManagedCopy,
+// long deltaManagedToRemoteTimestamp )
+// throws Exception
+// {
+// // --- Setup
+// setupSnapshotsRemoteRepo();
+// setupCleanInternalRepo();
+//
+// String resourcePath = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+// String expectedRemoteContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n"
+// + " <groupId>org.apache.maven.plugins</groupId>\n" + " <artifactId>maven-assembly-plugin</artifactId>\n"
+// + " <version>2.2-beta-2-SNAPSHOT</version>\n" + " <versioning>\n" + " <snapshot>\n"
+// + " <timestamp>20071017.162810</timestamp>\n" + " <buildNumber>20</buildNumber>\n"
+// + " </snapshot>\n" + " <lastUpdated>20071017162814</lastUpdated>\n" + " </versioning>\n"
+// + "</metadata>";
+// String expectedManagedContents = null;
+// File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
+//
+// if ( hasManagedCopy )
+// {
+// expectedManagedContents = "<metadata>\n" + " <groupId>org.apache.maven.plugins</groupId>\n"
+// + " <artifactId>maven-assembly-plugin</artifactId>\n" + " <version>2.2-beta-2-SNAPSHOT</version>\n"
+// + "</metadata>";
+//
+// File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+// managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+// }
+//
+// setupConnector( REPOID_INTERNAL, remoteSnapshots );
+// saveConfiguration();
+//
+// // --- Execution
+// // process the response code later, not via an exception.
+// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+//
+// WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+// WebResponse response = sc.getResponse( request );
+//
+// // --- Verification
+//
+// switch ( expectation )
+// {
+// case EXPECT_MANAGED_CONTENTS:
+// assertResponseOK( response );
+// assertTrue( "Invalid Test Case: Can't expect managed contents with "
+// + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+// String actualContents = response.getText();
+// XMLAssert.assertXMLEqual( expectedManagedContents, actualContents );
+// // assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+// break;
+// case EXPECT_REMOTE_CONTENTS:
+// assertResponseOK( response );
+// assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+// break;
+// case EXPECT_NOT_FOUND:
+// assertResponseNotFound( response );
+// assertManagedFileNotExists( repoRootInternal, resourcePath );
+// break;
+// }
+// }
+
+ protected void tearDown()
+ throws Exception
+ {
+ shutdownServer( remotePrivateSnapshots );
+
+ super.tearDown();
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.policies.CachedFailuresPolicy;
+import org.apache.maven.archiva.policies.ChecksumPolicy;
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHandler;
+
+import java.io.File;
+
+/**
+ * AbstractRepositoryServletProxiedTestCase
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRepositoryServletProxiedTestCase
+ extends AbstractRepositoryServletTestCase
+{
+ class RemoteRepoInfo
+ {
+ public String id;
+
+ public String url;
+
+ public String context;
+
+ public Server server;
+
+ public File root;
+
+ public RemoteRepositoryConfiguration config;
+ }
+
+ protected static final long ONE_SECOND = ( 1000 /* milliseconds */ );
+
+ protected static final long ONE_MINUTE = ( ONE_SECOND * 60 );
+
+ protected static final long ONE_HOUR = ( ONE_MINUTE * 60 );
+
+ protected static final long ONE_DAY = ( ONE_HOUR * 24 );
+
+ protected static final long OVER_ONE_HOUR = ( ONE_HOUR + ONE_MINUTE );
+
+ protected static final long OVER_ONE_DAY = ( ONE_DAY + ONE_HOUR );
+
+ protected static final long OLDER = ( -1 );
+
+ protected static final long NEWER = 0;
+
+ protected static final int EXPECT_MANAGED_CONTENTS = 1;
+
+ protected static final int EXPECT_REMOTE_CONTENTS = 2;
+
+ protected static final int EXPECT_NOT_FOUND = 3;
+
+ protected static final boolean HAS_MANAGED_COPY = true;
+
+ protected static final boolean NO_MANAGED_COPY = false;
+
+ protected RemoteRepoInfo remoteCentral;
+
+ protected RemoteRepoInfo remoteSnapshots;
+
+ protected RemoteRepoInfo remotePrivateSnapshots;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ protected RemoteRepoInfo createServer( String id )
+ throws Exception
+ {
+ RemoteRepoInfo repo = new RemoteRepoInfo();
+ repo.id = id;
+ repo.context = "/" + id;
+ repo.root = getTestFile( "target/remote-repos/" + id + "/" );
+
+ // Remove exising root contents.
+ if ( repo.root.exists() )
+ {
+ FileUtils.deleteDirectory( repo.root );
+ }
+
+ // Establish root directory.
+ if ( !repo.root.exists() )
+ {
+ repo.root.mkdirs();
+ }
+
+ repo.server = new Server();
+ ContextHandlerCollection contexts = new ContextHandlerCollection();
+ repo.server.setHandler( contexts );
+
+ SocketConnector connector = new SocketConnector();
+ connector.setPort( 0 ); // 0 means, choose and empty port. (we'll find out which, later)
+
+ repo.server.setConnectors( new Connector[] { connector } );
+
+ ContextHandler context = new ContextHandler();
+ context.setContextPath( repo.context );
+ context.setResourceBase( repo.root.getAbsolutePath() );
+ context.setAttribute( "dirAllowed", true );
+ context.setAttribute( "maxCacheSize", 0 );
+ ServletHandler servlet = new ServletHandler();
+ servlet.addServletWithMapping( DefaultServlet.class.getName(), "/" );
+ context.setHandler( servlet );
+ contexts.addHandler( context );
+
+ repo.server.start();
+
+ int port = connector.getLocalPort();
+ repo.url = "http://localhost:" + port + repo.context;
+ System.out.println( "Remote HTTP Server started on " + repo.url );
+
+ repo.config = createRemoteRepository( repo.id, "Testable [" + repo.id + "] Remote Repo", repo.url );
+
+ return repo;
+ }
+
+ protected void assertServerSetupCorrectly( RemoteRepoInfo remoteRepo )
+ throws Exception
+ {
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( remoteRepo.url );
+ assertResponseOK( response );
+ }
+
+ private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy, String snapshotsPolicy )
+ {
+ ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+ connector.setSourceRepoId( repoId );
+ connector.setTargetRepoId( remoteRepo.id );
+ connector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, releasesPolicy );
+ connector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotsPolicy );
+ connector.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE );
+ connector.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO );
+
+ archivaConfiguration.getConfiguration().addProxyConnector( connector );
+ }
+
+ protected void shutdownServer( RemoteRepoInfo remoteRepo )
+ {
+ if ( remoteRepo != null )
+ {
+ if ( remoteRepo.server != null )
+ {
+ if ( remoteRepo.server.isRunning() )
+ {
+ try
+ {
+ remoteRepo.server.stop();
+ // int graceful = remoteRepo.server.getGracefulShutdown();
+ // System.out.println( "server set to graceful shutdown: " + graceful );
+ // remoteRepo = null;
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+ }
+ }
+ }
+
+ protected File populateRepo( RemoteRepoInfo remoteRepo, String path, String contents )
+ throws Exception
+ {
+ File destFile = new File( remoteRepo.root, path );
+ destFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( destFile, contents, null );
+ return destFile;
+ }
+
+ protected void setupCentralRemoteRepo()
+ throws Exception
+ {
+ remoteCentral = createServer( "central" );
+
+ assertServerSetupCorrectly( remoteCentral );
+ archivaConfiguration.getConfiguration().addRemoteRepository( remoteCentral.config );
+ setupCleanRepo( remoteCentral.root );
+ }
+
+ protected void setupConnector( String repoId, RemoteRepoInfo remoteRepo )
+ {
+ setupConnector( repoId, remoteRepo, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS );
+ }
+
+ protected void setupReleaseConnector( String managedRepoId, RemoteRepoInfo remoteRepo, String releasePolicy )
+ {
+ setupConnector( managedRepoId, remoteRepo, releasePolicy, SnapshotsPolicy.ALWAYS );
+ }
+
+ protected void setupSnapshotConnector( String managedRepoId, RemoteRepoInfo remoteRepo, String snapshotsPolicy )
+ {
+ setupConnector( managedRepoId, remoteRepo, ReleasesPolicy.ALWAYS, snapshotsPolicy );
+ }
+
+ protected void setupSnapshotsRemoteRepo()
+ throws Exception
+ {
+ remoteSnapshots = createServer( "snapshots" );
+
+ assertServerSetupCorrectly( remoteSnapshots );
+ archivaConfiguration.getConfiguration().addRemoteRepository( remoteSnapshots.config );
+ setupCleanRepo( remoteSnapshots.root );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ shutdownServer( remoteCentral );
+ shutdownServer( remoteSnapshots );
+ super.tearDown();
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+import net.sf.ehcache.CacheManager;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.webdav.RepositoryServlet;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+/**
+ * AbstractRepositoryServletTestCase
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRepositoryServletTestCase
+ extends PlexusInSpringTestCase
+{
+ protected static final String REPOID_INTERNAL = "internal";
+
+ protected ServletUnitClient sc;
+
+ protected File repoRootInternal;
+
+ private ServletRunner sr;
+
+ protected ArchivaConfiguration archivaConfiguration;
+
+ protected void saveConfiguration()
+ throws Exception
+ {
+ saveConfiguration( archivaConfiguration );
+ }
+
+ protected void assertFileContents( String expectedContents, File repoRoot, String path )
+ throws IOException
+ {
+ File actualFile = new File( repoRoot, path );
+ assertTrue( "File <" + actualFile.getAbsolutePath() + "> should exist.", actualFile.exists() );
+ assertTrue( "File <" + actualFile.getAbsolutePath() + "> should be a file (not a dir/link/device/etc).",
+ actualFile.isFile() );
+
+ String actualContents = FileUtils.readFileToString( actualFile, null );
+ assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents );
+ }
+
+ protected void assertRepositoryValid( RepositoryServlet servlet, String repoId )
+ {
+ ManagedRepositoryConfiguration repository = servlet.getRepository( repoId );
+ assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
+ File repoRoot = new File( repository.getLocation() );
+ assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repoRoot
+ .exists()
+ && repoRoot.isDirectory() );
+ }
+
+ protected void assertResponseOK( WebResponse response )
+ {
+ assertNotNull( "Should have recieved a response", response );
+ Assert.assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() );
+ }
+
+ protected void assertResponseNotFound( WebResponse response )
+ {
+ assertNotNull( "Should have recieved a response", response );
+ Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response
+ .getResponseCode() );
+ }
+
+ protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLocation( location.getAbsolutePath() );
+ return repo;
+ }
+
+ protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
+ {
+ RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setUrl( url );
+ return repo;
+ }
+
+ protected void dumpResponse( WebResponse response )
+ {
+ System.out.println( "---(response)---" );
+ System.out.println( "" + response.getResponseCode() + " " + response.getResponseMessage() );
+
+ String headerNames[] = response.getHeaderFieldNames();
+ for ( String headerName : headerNames )
+ {
+ System.out.println( "[header] " + headerName + ": " + response.getHeaderField( headerName ) );
+ }
+
+ System.out.println( "---(text)---" );
+ try
+ {
+ System.out.println( response.getText() );
+ }
+ catch ( IOException e )
+ {
+ System.err.print( "[Exception] : " );
+ e.printStackTrace( System.err );
+ }
+ }
+
+ protected void saveConfiguration( ArchivaConfiguration archivaConfiguration )
+ throws Exception
+ {
+ archivaConfiguration.save( archivaConfiguration.getConfiguration() );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
+ System.setProperty( "appserver.base", appserverBase );
+
+ File testConf = getTestFile( "src/test/resources/repository-archiva.xml" );
+ File testConfDest = new File( appserverBase, "conf/archiva.xml" );
+ FileUtils.copyFile( testConf, testConfDest );
+
+ archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
+ repoRootInternal = new File( appserverBase, "data/repositories/internal" );
+ Configuration config = archivaConfiguration.getConfiguration();
+
+ config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
+ saveConfiguration( archivaConfiguration );
+
+ CacheManager.getInstance().removeCache( "url-failures-cache" );
+
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ sr = new ServletRunner( getTestFile( "src/test/webapp/WEB-INF/web.xml" ) );
+ sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
+ sc = sr.newClient();
+ }
+
+ @Override
+ protected String getPlexusConfigLocation()
+ {
+ return "org/apache/maven/archiva/webdav/RepositoryServletTest.xml";
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ if ( sc != null )
+ {
+ sc.clearContents();
+ }
+
+ if ( sr != null )
+ {
+ sr.shutDown();
+ }
+
+ super.tearDown();
+ }
+
+ protected void setupCleanRepo( File repoRootDir )
+ throws IOException
+ {
+ FileUtils.deleteDirectory( repoRootDir );
+ if ( !repoRootDir.exists() )
+ {
+ repoRootDir.mkdirs();
+ }
+ }
+
+ protected void assertManagedFileNotExists( File repoRootInternal, String resourcePath )
+ {
+ File repoFile = new File( repoRootInternal, resourcePath );
+ assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.", repoFile
+ .exists() );
+ }
+
+ protected void setupCleanInternalRepo()
+ throws Exception
+ {
+ setupCleanRepo( repoRootInternal );
+ }
+
+ protected File populateRepo( File repoRootManaged, String path, String contents )
+ throws Exception
+ {
+ File destFile = new File( repoRootManaged, path );
+ destFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( destFile, contents, null );
+ return destFile;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.redback.authentication.AuthenticationDataSource;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import org.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
+import org.codehaus.plexus.redback.authorization.AuthorizationResult;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.keys.memory.MemoryKeyManager;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.DefaultUserSecurityPolicy;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.codehaus.plexus.redback.system.DefaultSecuritySession;
+import org.codehaus.plexus.redback.system.DefaultSecuritySystem;
+import org.codehaus.plexus.redback.system.SecuritySession;
+import org.codehaus.plexus.redback.system.SecuritySystem;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+import org.codehaus.plexus.redback.users.memory.MemoryUserManager;
+
+/**
+ * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
+ * for every request to respond as success / true.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component
+ * role="org.codehaus.plexus.redback.system.SecuritySystem"
+ */
+public class BypassSecuritySystem
+ extends DefaultSecuritySystem
+ implements SecuritySystem
+{
+ private KeyManager bypassKeyManager;
+ private UserSecurityPolicy bypassPolicy;
+ private UserManager bypassUserManager;
+
+ public BypassSecuritySystem()
+ {
+ bypassKeyManager = new MemoryKeyManager();
+ bypassPolicy = new DefaultUserSecurityPolicy();
+ bypassUserManager = new MemoryUserManager();
+ }
+
+ public SecuritySession authenticate( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException
+ {
+ AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
+ return new DefaultSecuritySession( result );
+ }
+
+ public AuthorizationResult authorize( SecuritySession session, Object permission )
+ throws AuthorizationException
+ {
+ return new AuthorizationResult( true, session.getUser(), null );
+ }
+
+ public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException
+ {
+ return new AuthorizationResult( true, session.getUser(), null );
+ }
+
+ public String getAuthenticatorId()
+ {
+ return "bypass-authenticator";
+ }
+
+ public String getAuthorizerId()
+ {
+ return "bypass-authorizer";
+ }
+
+ public KeyManager getKeyManager()
+ {
+ return bypassKeyManager;
+ }
+
+ public UserSecurityPolicy getPolicy()
+ {
+ return bypassPolicy;
+ }
+
+ public String getUserManagementId()
+ {
+ return "bypass-managementid";
+ }
+
+ public UserManager getUserManager()
+ {
+ return bypassUserManager;
+ }
+
+ public boolean isAuthenticated( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException
+ {
+ // Always true
+ return true;
+ }
+
+ public boolean isAuthorized( SecuritySession session, Object permission )
+ throws AuthorizationException
+ {
+ // Always true
+ return true;
+ }
+
+ public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException
+ {
+ // Always true
+ return true;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.webdav.util.MimeTypes;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+/**
+ * ArchivaMimeTypesTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class MimeTypesLoaderTest
+ extends PlexusInSpringTestCase
+{
+ public void testArchivaTypes()
+ throws Exception
+ {
+ lookup( MimeTypes.class );
+ MimeTypes mimeTypes = (MimeTypes) lookup( MimeTypes.class );
+ assertNotNull( mimeTypes );
+
+ // Test for some added types.
+ assertEquals( "sha1", "text/plain", mimeTypes.getMimeType( "foo.sha1" ) );
+ assertEquals( "md5", "text/plain", mimeTypes.getMimeType( "foo.md5" ) );
+ assertEquals( "pgp", "application/pgp-encrypted", mimeTypes.getMimeType( "foo.pgp" ) );
+ assertEquals( "jar", "application/java-archive", mimeTypes.getMimeType( "foo.jar" ) );
+ assertEquals( "Default", "application/octet-stream", mimeTypes.getMimeType(".SomeUnknownExtension"));
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebLink;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import java.io.File;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * RepositoryServletBrowseTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletBrowseTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testBrowse()
+ throws Exception
+ {
+ new File( repoRootInternal, "org/apache/archiva" ).mkdirs();
+ new File( repoRootInternal, "net/sourceforge" ).mkdirs();
+ new File( repoRootInternal, "commons-lang" ).mkdirs();
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" );
+ WebResponse response = sc.getResponse( request );
+ assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
+
+ // dumpResponse( response );
+
+ WebLink links[] = response.getLinks();
+ String expectedLinks[] = new String[] { "./commons-lang/", "./net/", "./org/" };
+
+ assertEquals( "Links.length", expectedLinks.length, links.length );
+ for ( int i = 0; i < links.length; i++ )
+ {
+ assertEquals( "Link[" + i + "]", expectedLinks[i], links[i].getURLString() );
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.PutMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Deploy / Put Test cases for RepositoryServlet.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletDeployTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testPutWithMissingParentCollection()
+ throws Exception
+ {
+ setupCleanRepo( repoRootInternal );
+
+ String putUrl = "http://machine.com/repository/internal/path/to/artifact.jar";
+ InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
+ assertNotNull( "artifact.jar inputstream", is );
+
+ WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
+
+ WebResponse response = sc.getResponse( request );
+ assertResponseCreated( response );
+ assertFileContents( "artifact.jar\n", repoRootInternal, "path/to/artifact.jar" );
+ }
+
+ protected void assertResponseCreated( WebResponse response )
+ {
+ assertNotNull( "Should have recieved a response", response );
+ assertEquals( "Should have been a 201/CREATED response code.", HttpServletResponse.SC_CREATED, response
+ .getResponseCode() );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+
+/**
+ * RepositoryServletTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletNoProxyMetadataTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testGetVersionMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
+
+ File checksumFile = new File( repoRootInternal, commonsLangMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetProjectMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
+
+ File checksumFile = new File( repoRootInternal, commonsLangMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetGroupMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-commons-lang-group";
+
+ File checksumFile = new File( repoRootInternal, commonsLangMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetSnapshotVersionMetadataDefaultLayout()
+ throws Exception
+ {
+ String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
+
+ File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+
+/**
+ * RepositoryServletTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletNoProxyTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testGetNoProxyChecksumDefaultLayout()
+ throws Exception
+ {
+ String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
+
+ File checksumFile = new File( repoRootInternal, commonsLangSha1 );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
+ }
+
+ public void testGetNoProxyChecksumLegacyLayout()
+ throws Exception
+ {
+ String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
+
+ File checksumFile = new File( repoRootInternal, commonsLangSha1 );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
+ + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
+ }
+
+ public void testGetNoProxyVersionedMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
+ String expectedMetadataContents = "dummy-versioned-metadata";
+
+ File metadataFile = new File( repoRootInternal, commonsLangMetadata );
+ metadataFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetNoProxyProjectMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
+ String expectedMetadataContents = "dummy-project-metadata";
+
+ File metadataFile = new File( repoRootInternal, commonsLangMetadata );
+ metadataFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetNoProxyGroupMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/maven-metadata.xml";
+ String expectedMetadataContents = "dummy-group-metadata";
+
+ File metadataFile = new File( repoRootInternal, commonsLangMetadata );
+ metadataFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetNoProxyArtifactDefaultLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
+ String expectedArtifactContents = "dummy-commons-lang-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ public void testGetNoProxyArtifactLegacyLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
+ String expectedArtifactContents = "dummy-commons-lang-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
+ + "commons-lang/jars/commons-lang-2.1.jar" );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ public void testGetNoProxySnapshotArtifactDefaultLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
+ String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ public void testGetNoProxySnapshotArtifactLegacyLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
+ String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
+ + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
+ String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout()
+ throws Exception
+ {
+ String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
+ String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
+
+ File artifactFile = new File( repoRootInternal, commonsLangJar );
+ artifactFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/"
+ + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
+ }
+
+ /**
+ * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
+ */
+ public void testGetNoProxyDualExtensionDefaultLayout()
+ throws Exception
+ {
+ String expectedContents = "the-contents-of-the-dual-extension";
+ String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
+
+ File checksumFile = new File( repoRootInternal, dualExtensionPath );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedContents, response.getText() );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Metadata, exists on local managed repository only.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedMetadataLocalOnlyTest
+ extends AbstractRepositoryServletProxiedMetadataTestCase
+{
+ public void testGetProxiedSnapshotVersionMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-1-SNAPSHOT" );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedVersionMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-2" );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedProjectMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
+ String version = "1.0-alpha-4";
+ String release = "1.0-alpha-4";
+ String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin", version,
+ release, new String[] { "1.0-alpha-4" } );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedGroupMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/maven-metadata.xml";
+ String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedMetadataRemoteOnlyTest
+ extends AbstractRepositoryServletProxiedMetadataTestCase
+{
+ public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+ String version = "4.0-alpha-1-SNAPSHOT";
+ String timestamp = "20040305.112233";
+ String buildNumber = "2";
+ String lastUpdated = "20040305112233";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ version, timestamp, buildNumber, lastUpdated);
+
+ File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
+ String version = "2.2-beta-2-SNAPSHOT";
+ String timestamp = "20071017.162810";
+ String buildNumber = "20";
+ String lastUpdated = "20071017162810";
+ String expectedMetadata = createVersionMetadata( "org.apache.maven.plugins", "maven-assembly-plugin", version,
+ timestamp, buildNumber, lastUpdated );
+
+ File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-2" );
+
+ File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedProjectMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
+ String latest = "1.0-alpha-4";
+ String release = "1.0-alpha-4";
+ String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ latest, release, new String[] { "1.0-alpha-4" } );
+
+ File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedGroupMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/maven-metadata.xml";
+ String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
+
+ File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedPluginSnapshotPolicyTest
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
+ HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_HOUR ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOncePass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy )
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String resourcePath = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42.jar";
+ String expectedRemoteContents = "archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42|jar-remote-contents";
+ String expectedManagedContents = null;
+ File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
+
+ if ( hasManagedCopy )
+ {
+ expectedManagedContents = "archivatest-maven-plugin-4.0-alpha-1-20070822.033400-42|jar-managed-contents";
+ File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+ managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+ }
+
+ setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
+ saveConfiguration();
+
+ // --- Execution
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+ WebResponse response = sc.getResponse( request );
+
+ // --- Verification
+
+ switch ( expectation )
+ {
+ case EXPECT_MANAGED_CONTENTS:
+ assertResponseOK( response );
+ assertTrue( "Invalid Test Case: Can't expect managed contents with "
+ + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+ assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+ break;
+ case EXPECT_REMOTE_CONTENTS:
+ assertResponseOK( response );
+ assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+ break;
+ case EXPECT_NOT_FOUND:
+ assertResponseNotFound( response );
+ assertManagedFileNotExists( repoRootInternal, resourcePath );
+ break;
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedReleasePolicyTest
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ public void testGetProxiedReleaseArtifactPolicyAlwaysManagedNewer()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.ALWAYS, HAS_MANAGED_COPY,
+ ( NEWER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyAlwaysManagedOlder()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ALWAYS, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyAlwaysNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ALWAYS, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyDailyFail()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.DAILY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyDailyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyDailyPass()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyRejectFail()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyRejectNoManagedContentFail()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_NOT_FOUND, ReleasesPolicy.NEVER, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyRejectPass()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyHourlyFail()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyHourlyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyHourlyPass()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_HOUR ) );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyOnceFail()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.ONCE, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyOnceNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedReleaseArtifactPolicyOncePass()
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ private void assertGetProxiedReleaseArtifactWithPolicy( int expectation, String releasePolicy,
+ boolean hasManagedCopy )
+ throws Exception
+ {
+ assertGetProxiedReleaseArtifactWithPolicy( expectation, releasePolicy, hasManagedCopy, 0 );
+ }
+
+ private void assertGetProxiedReleaseArtifactWithPolicy( int expectation, String releasePolicy,
+ boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
+ throws Exception
+ {
+ // --- Setup
+ setupCentralRemoteRepo();
+ setupCleanInternalRepo();
+
+ String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
+ String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
+ String expectedManagedContents = null;
+ File remoteFile = populateRepo( remoteCentral, resourcePath, expectedRemoteContents );
+
+ if ( hasManagedCopy )
+ {
+ expectedManagedContents = "archiva-test-1.0|jar-managed-contents";
+ File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+ managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+ }
+
+ setupReleaseConnector( REPOID_INTERNAL, remoteCentral, releasePolicy );
+ saveConfiguration();
+
+ // --- Execution
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+ WebResponse response = sc.getResponse( request );
+
+ // --- Verification
+
+ switch ( expectation )
+ {
+ case EXPECT_MANAGED_CONTENTS:
+ assertResponseOK( response );
+ assertTrue( "Invalid Test Case: Can't expect managed contents with "
+ + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+ assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+ break;
+ case EXPECT_REMOTE_CONTENTS:
+ assertResponseOK( response );
+ assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+ break;
+ case EXPECT_NOT_FOUND:
+ assertResponseNotFound( response );
+ assertManagedFileNotExists( repoRootInternal, resourcePath );
+ break;
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id: RepositoryServletProxiedReleasePolicyTest.java 590908 2007-11-01 06:21:26Z joakime $
+ */
+public class RepositoryServletProxiedRelocatedTest
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ public void testGetProxiedReleaseArtifactPolicyOncePass()
+ throws Exception
+ {
+ // --- Setup
+ setupCentralRemoteRepo();
+ setupCleanInternalRepo();
+
+ String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
+ String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
+ populateRepo( remoteCentral, resourcePath, expectedRemoteContents );
+
+ resourcePath = "archiva/test/1.0/test-1.0.pom";
+ String pom = "<project>" +
+ "<modelVersion>4.0.0</modelVersion>" +
+ "<groupId>archiva</groupId>" +
+ "<artifactId>test</artifactId>" +
+ "<version>1.0</version>" +
+ "<distributionManagement>" +
+ "<relocation>" +
+ "<groupId>org.apache.archiva</groupId>" +
+ "</relocation>" +
+ "</distributionManagement>" +
+ "</project>";
+ populateRepo( remoteCentral, resourcePath, pom );
+
+ resourcePath = "archiva/jars/test-1.0.jar";
+
+ setupReleaseConnector( REPOID_INTERNAL, remoteCentral, ReleasesPolicy.ONCE );
+ saveConfiguration();
+
+ // --- Execution
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+ WebResponse response = sc.getResponse( request );
+
+ // --- Verification
+ assertResponseOK( response );
+ assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Snapshot Artifacts, with varying policy settings.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedSnapshotPolicyTest
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
+ HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_HOUR ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOncePass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy )
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String resourcePath = "org/apache/archiva/test/2.0-SNAPSHOT/test-2.0-SNAPSHOT.jar";
+ String expectedRemoteContents = "archiva-test-2.0-SNAPSHOT|jar-remote-contents";
+ String expectedManagedContents = null;
+ File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
+
+ if ( hasManagedCopy )
+ {
+ expectedManagedContents = "archiva-test-2.0-SNAPSHOT|jar-managed-contents";
+ File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+ managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+ }
+
+ setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
+ saveConfiguration();
+
+ // --- Execution
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+ WebResponse response = sc.getResponse( request );
+
+ // --- Verification
+
+ switch ( expectation )
+ {
+ case EXPECT_MANAGED_CONTENTS:
+ assertResponseOK( response );
+ assertTrue( "Invalid Test Case: Can't expect managed contents with "
+ + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+ assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+ break;
+ case EXPECT_REMOTE_CONTENTS:
+ assertResponseOK( response );
+ assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+ break;
+ case EXPECT_NOT_FOUND:
+ assertResponseNotFound( response );
+ assertManagedFileNotExists( repoRootInternal, resourcePath );
+ break;
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS,
+ HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_DAY ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER,
+ HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( NEWER * ONE_MINUTE ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, HAS_MANAGED_COPY,
+ ( OLDER * OVER_ONE_HOUR ) );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ public void testGetProxiedSnapshotsArtifactPolicyOncePass()
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy )
+ throws Exception
+ {
+ assertGetProxiedSnapshotsArtifactWithPolicy( expectation, snapshotsPolicy, hasManagedCopy, 0 );
+ }
+
+ private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy,
+ boolean hasManagedCopy, long deltaManagedToRemoteTimestamp )
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String resourcePath = "org/apache/archiva/test/3.0-SNAPSHOT/test-3.0-20070822.033400-42.jar";
+ String expectedRemoteContents = "archiva-test-3.0-20070822.033400-42|jar-remote-contents";
+ String expectedManagedContents = null;
+ File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
+
+ if ( hasManagedCopy )
+ {
+ expectedManagedContents = "archiva-test-3.0-20070822.033400-42|jar-managed-contents";
+ File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+ managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+ }
+
+ setupSnapshotConnector( REPOID_INTERNAL, remoteSnapshots, snapshotsPolicy );
+ saveConfiguration();
+
+ // --- Execution
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+ WebResponse response = sc.getResponse( request );
+
+ // --- Verification
+
+ switch ( expectation )
+ {
+ case EXPECT_MANAGED_CONTENTS:
+ assertResponseOK( response );
+ assertTrue( "Invalid Test Case: Can't expect managed contents with "
+ + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+ assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+ break;
+ case EXPECT_REMOTE_CONTENTS:
+ assertResponseOK( response );
+ assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+ break;
+ case EXPECT_NOT_FOUND:
+ assertResponseNotFound( response );
+ assertManagedFileNotExists( repoRootInternal, resourcePath );
+ break;
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PutMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+
+/**
+ * RepositoryServletRepositoryGroupTest
+ *
+ * Test Case 1. Accessing a valid repository group root url (e.g. http://machine.com/repository/repository-group/) returns a Bad Request (HTTP 400)
+ * Test Case 2. Accessing an invalid repository group root url is forwarded to managed repository checking (this is not covered here)
+ * Test Case 3. Accessing an artifact in a valid repository group will iterate over the managed repositories in the repository group
+ * Test Case 3.a. If an invalid managed repository is encountered (managed repository doesn't exist),
+ * a Not Found (HTTP 404) is returned and the iteration is broken
+ * Test Case 3.b. If an artifact is not found in a valid managed repository (after proxying, etc.),
+ * a Not Found (HTTP 404) is set but not returned yet, the iteration continues to the next managed repository.
+ * The Not Found (HTTP 404) is returned after exhausting all valid managed repositories
+ * Test Case 3.c. If an artifact is found in a valid managed repository,
+ * the artifact is returned, the iteration is broken and any Not Found (HTTP 404) is disregarded
+ * Test Case 4. Accessing a valid repository group with any http write method returns a Bad Request (HTTP 400)
+ *
+ * @author
+ *
+ */
+public class RepositoryServletRepositoryGroupTest
+ extends AbstractRepositoryServletTestCase
+{
+ protected File repoRootFirst;
+
+ protected File repoRootLast;
+
+ protected File repoRootInvalid;
+
+ protected static final String MANAGED_REPO_FIRST = "first";
+
+ protected static final String MANAGED_REPO_LAST = "last";
+
+ protected static final String MANAGED_REPO_INVALID = "invalid";
+
+ protected static final String REPO_GROUP_WITH_VALID_REPOS = "group-with-valid-repos";
+
+ protected static final String REPO_GROUP_WITH_INVALID_REPOS = "group-with-invalid-repos";
+
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ String appserverBase = System.getProperty( "appserver.base" );
+
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ repoRootFirst = new File( appserverBase, "data/repositories/" + MANAGED_REPO_FIRST );
+ repoRootLast = new File( appserverBase, "data/repositories/" + MANAGED_REPO_LAST );
+
+ configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
+ configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
+
+ List<String> managedRepoIds = new ArrayList<String>();
+ managedRepoIds.add( MANAGED_REPO_FIRST );
+ managedRepoIds.add( MANAGED_REPO_LAST );
+
+ configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_VALID_REPOS, managedRepoIds ) );
+
+ // Create the repository group with an invalid managed repository
+ repoRootInvalid = new File( appserverBase, "data/repositories/" + MANAGED_REPO_INVALID );
+ ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid );
+
+ configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) );
+ configuration.addManagedRepository( managedRepositoryConfiguration );
+ configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) );
+
+ List<String> invalidManagedRepoIds = new ArrayList<String>();
+ invalidManagedRepoIds.add( MANAGED_REPO_FIRST );
+ invalidManagedRepoIds.add( MANAGED_REPO_INVALID );
+ invalidManagedRepoIds.add( MANAGED_REPO_LAST );
+
+ configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds ) );
+
+ configuration.removeManagedRepository( managedRepositoryConfiguration );
+ FileUtils.deleteDirectory( repoRootInvalid );
+
+ saveConfiguration( archivaConfiguration );
+ }
+
+ protected void tearDown()
+ throws Exception
+ {
+ setupCleanRepo( repoRootFirst );
+ setupCleanRepo( repoRootLast );
+
+ super.tearDown();
+ }
+
+ /*
+ * Test Case 3.c
+ */
+ public void testGetFromFirstManagedRepositoryReturnOk()
+ throws Exception
+ {
+ String resourceName = "dummy/dummy-first-resource/1.0/dummy-first-resource-1.0.txt";
+
+ File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
+ dummyInternalResourceFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
+ WebResponse response = sc.getResponse( request );
+
+ assertResponseOK( response );
+ assertEquals( "Expected file contents", "first", response.getText() );
+ }
+
+ /*
+ * Test Case 3.c
+ */
+ public void testGetFromLastManagedRepositoryReturnOk()
+ throws Exception
+ {
+ String resourceName = "dummy/dummy-last-resource/1.0/dummy-last-resource-1.0.txt";
+
+ File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
+ dummyReleasesResourceFile.getParentFile().mkdirs();
+ FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
+ WebResponse response = sc.getResponse( request );
+
+ assertResponseOK( response );
+ assertEquals( "Expected file contents", "last", response.getText() );
+ }
+
+ /*
+ * Test Case 3.b
+ */
+ public void testGetFromValidRepositoryGroupReturnNotFound()
+ throws Exception
+ {
+ String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
+ WebResponse response = sc.getResponse( request );
+
+ assertResponseNotFound( response );
+ }
+
+ /*
+ * Test Case 3.a
+ */
+ public void testGetInvalidManagedRepositoryInGroupReturnNotFound()
+ throws Exception
+ {
+ String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName );
+ WebResponse response = sc.getResponse( request );
+
+ assertResponseNotFound( response );
+ }
+
+ /*
+ * Test Case 4
+ */
+ public void testPutValidRepositoryGroupReturnBadRequest()
+ throws Exception
+ {
+ String resourceName = "dummy/dummy-put-resource/1.0/dummy-put-resource-1.0.txt";
+ String putUrl = "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName;
+ InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
+
+ WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" );
+ WebResponse response = sc.getResponse( request );
+
+ assertResponseMethodNotAllowed( response );
+ }
+
+ public void testBrowseRepositoryGroup()
+ throws Exception
+ {
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS );
+ WebResponse response = sc.getResponse( request );
+
+ assertNotNull( "Should have received a response", response );
+ assertEquals( "Should have been an 401 response code.", HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode() );
+ }
+
+ protected void assertResponseMethodNotAllowed( WebResponse response )
+ {
+ assertNotNull( "Should have recieved a response", response );
+ assertEquals( "Should have been an 405/Method Not Allowed response code.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getResponseCode() );
+ }
+
+ protected RepositoryGroupConfiguration createRepositoryGroup( String id, List<String> repositories )
+ {
+ RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration();
+ repoGroupConfiguration.setId( id );
+ repoGroupConfiguration.setRepositories( repositories );
+ return repoGroupConfiguration;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/**
+ * RepositoryServletSecurityTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletSecurityTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testSecuredGet()
+ {
+
+ }
+
+ public void testSecuredBrowse()
+ {
+
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.webdav.RepositoryServlet;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import java.io.File;
+
+/**
+ * RepositoryServletTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletTest
+ extends AbstractRepositoryServletTestCase
+{
+ private static final String REQUEST_PATH = "http://machine.com/repository/internal/";
+
+ private static final String NEW_REPOSITORY_ID = "new-id";
+
+ private static final String NEW_REPOSITORY_NAME = "New Repository";
+
+ public void testGetRepository()
+ throws Exception
+ {
+ RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
+ assertNotNull( servlet );
+
+ assertRepositoryValid( servlet, REPOID_INTERNAL );
+ }
+
+ public void testGetRepositoryAfterDelete()
+ throws Exception
+ {
+ RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
+ assertNotNull( servlet );
+
+ ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
+ Configuration c = archivaConfiguration.getConfiguration();
+ c.removeManagedRepository( c.findManagedRepositoryById( REPOID_INTERNAL ) );
+ saveConfiguration( archivaConfiguration );
+
+ ManagedRepositoryConfiguration repository = servlet.getRepository( REPOID_INTERNAL );
+ assertNull( repository );
+ }
+
+ public void testGetRepositoryAfterAdd()
+ throws Exception
+ {
+ RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
+ assertNotNull( servlet );
+
+ ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
+ Configuration c = archivaConfiguration.getConfiguration();
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( NEW_REPOSITORY_ID );
+ repo.setName( NEW_REPOSITORY_NAME );
+ File repoRoot = new File( getBasedir(), "target/test-repository-root" );
+ if ( !repoRoot.exists() )
+ {
+ repoRoot.mkdirs();
+ }
+ repo.setLocation( repoRoot.getAbsolutePath() );
+ c.addManagedRepository( repo );
+ saveConfiguration( archivaConfiguration );
+
+ ManagedRepositoryConfiguration repository = servlet.getRepository( NEW_REPOSITORY_ID );
+ assertNotNull( repository );
+ assertEquals( NEW_REPOSITORY_NAME, repository.getName() );
+
+ // check other is still intact
+ assertRepositoryValid( servlet, REPOID_INTERNAL );
+ }
+
+ public void testGetRepositoryInvalidPathPassthroughPresent()
+ throws Exception
+ {
+ String path = REQUEST_PATH + ".index/filecontent/segments.gen";
+
+ populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );
+
+ WebRequest request = new GetMethodWebRequest( path );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+ assertEquals( "index file", response.getText() );
+ }
+
+ public void testGetRepositoryInvalidPathPassthroughMissing()
+ throws Exception
+ {
+ String path = REQUEST_PATH + ".index/filecontent/foo.bar";
+
+ WebRequest request = new GetMethodWebRequest( path );
+ WebResponse response = sc.getResponse( request );
+ assertResponseNotFound( response );
+ assertEquals( "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path.", response.getResponseMessage() );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
+
+import java.util.List;
+
+public class StubRepositoryContentConsumers
+ extends RepositoryContentConsumers
+{
+ public List<KnownRepositoryContentConsumer> getSelectedKnownConsumers()
+ {
+ return getAvailableKnownConsumers();
+ }
+
+ public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers()
+ {
+ return getAvailableInvalidConsumers();
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.maven.archiva.webdav.ArchivaDavResourceFactory;
+
+/**
+ * UnauthenticatedDavResourceFactory
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id:
+ */
+public class UnauthenticatedDavResourceFactory
+ extends ArchivaDavResourceFactory
+{
+ @Override
+ protected boolean isAuthorized( DavServletRequest request, String repositoryId )
+ throws DavException
+ {
+ return true;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.webdav.ArchivaDavSessionProvider;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
+ */
+public class UnauthenticatedDavSessionProvider extends ArchivaDavSessionProvider
+{
+ public UnauthenticatedDavSessionProvider(WebApplicationContext applicationContext)
+ {
+ super(applicationContext);
+ }
+
+ @Override
+ public boolean attachSession( WebdavRequest request )
+ throws DavException
+ {
+ return true;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.apache.maven.archiva.webdav.RepositoryServlet;
+
+import javax.servlet.ServletConfig;
+
+/**
+ * UnauthenticatedRepositoryServlet
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class UnauthenticatedRepositoryServlet
+ extends RepositoryServlet
+{
+ @Override
+ public synchronized void initServers( ServletConfig servletConfig )
+ {
+ super.initServers(servletConfig);
+
+ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() );
+
+ UnauthenticatedDavSessionProvider sessionProvider = new UnauthenticatedDavSessionProvider(wac);
+ setDavSessionProvider(sessionProvider);
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%5p|%t|%5r|%-30c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Help identify bugs during testing -->
+ <logger name="org.apache.maven.archiva">
+ <level value="info"/>
+ </logger>
+
+ <logger name="net.sf.ehcache">
+ <level value="warn"/>
+ </logger>
+
+ <logger name="org.codehaus.plexus.security">
+ <level value="info"/>
+ </logger>
+
+ <logger name="org.springframework">
+ <level value="error"/>
+ </logger>
+
+ <logger name="org.codehaus.plexus.spring">
+ <level value="error"/>
+ </logger>
+
+ <logger name="JPOX">
+ <level value="warn"/>
+ </logger>
+
+ <logger name="JPOX.MetaData">
+ <level value="error"/>
+ </logger>
+
+ <logger name="JPOX.RDBMS.SQL">
+ <level value="error"/>
+ </logger>
+
+ <logger name="SQL">
+ <level value="error"/>
+ </logger>
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<plexus>
+ <components>
+ <!--
+ | Logger manager
+ -->
+ <component>
+ <role>org.codehaus.plexus.logging.LoggerManager</role>
+ <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
+ <lifecycle-handler>basic</lifecycle-handler>
+ </component>
+
+ <!--
+ | Configuration
+ -->
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
+ <field-name>prePolicies</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
+ <field-name>postPolicies</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <system/>
+ <xml fileName="${appserver.base}/conf/archiva.xml"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.apache.maven.archiva.webdav.DavServerManager</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.webdav.DefaultDavServerManager</implementation>
+ <description>DefaultDavServerManager</description>
+ <configuration>
+ <provider-hint>proxied</provider-hint>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>url-failures-cache</role-hint>
+ <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
+ <description>URL Failure Cache</description>
+ <configuration>
+ <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
+ <disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
+ <disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
+ <eternal>false</eternal>
+ <max-elements-in-memory>1000</max-elements-in-memory>
+ <memory-eviction-policy>LRU</memory-eviction-policy>
+ <name>url-failures-cache</name>
+ <overflow-to-disk>false</overflow-to-disk>
+ <!-- 45 minutes = 2700 seconds -->
+ <time-to-idle-seconds>2700</time-to-idle-seconds>
+ <!-- 30 minutes = 1800 seconds -->
+ <time-to-live-seconds>1800</time-to-live-seconds>
+ </configuration>
+ </component>
+
+
+ <!-- Don't drag in the world just to test this -->
+ <component>
+ <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers</implementation>
+ </component>
+
+ <!-- TODO: shouldn't need so many components just to use in-memory - is flaky since these are auto-generated -->
+ <component>
+ <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.system.DefaultSecuritySystem</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.authentication.AuthenticationManager</role>
+ <field-name>authnManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
+ <role-hint>rbac</role-hint>
+ <field-name>authorizer</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.keys.KeyManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>keyManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
+ <field-name>policy</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.authentication.Authenticator</role>
+ <role-hint>user-manager</role-hint>
+ <implementation>org.codehaus.plexus.redback.authentication.users.UserManagerAuthenticator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
+ <field-name>securityPolicy</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.authentication.Authenticator</role>
+ <role-hint>keystore</role-hint>
+ <implementation>org.codehaus.plexus.redback.authentication.keystore.KeyStoreAuthenticator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.keys.KeyManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>keystore</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator
+ </implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
+ <role-hint>rbac</role-hint>
+ <implementation>org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>manager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
+ <role-hint>default</role-hint>
+ <field-name>evaluator</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.RoleManager</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.DefaultRoleManager</implementation>
+ <instantiation-strategy>singleton</instantiation-strategy>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.merger.RoleModelMerger</role>
+ <role-hint>default</role-hint>
+ <field-name>modelMerger</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.validator.RoleModelValidator</role>
+ <role-hint>default</role-hint>
+ <field-name>modelValidator</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>modelProcessor</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>templateProcessor</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.PlexusContainer</role>
+ <field-name>container</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ </components>
+</plexus>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<plexus>
+ <components>
+ <!--
+ | Logger manager
+ -->
+ <component>
+ <role>org.codehaus.plexus.logging.LoggerManager</role>
+ <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
+ <lifecycle-handler>basic</lifecycle-handler>
+ </component>
+
+ <!--
+ | Configuration
+ -->
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
+ <field-name>prePolicies</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
+ <field-name>postPolicies</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <system/>
+ <xml fileName="${appserver.base}/conf/archiva.xml"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.apache.maven.archiva.webdav.DavServerManager</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.webdav.DefaultDavServerManager</implementation>
+ <description>DefaultDavServerManager</description>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.archiva.webdav.DavServerComponent</role>
+ <role-hint>proxied</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>url-failures-cache</role-hint>
+ <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
+ <description>URL Failure Cache</description>
+ <configuration>
+ <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
+ <disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
+ <disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
+ <eternal>false</eternal>
+ <max-elements-in-memory>1000</max-elements-in-memory>
+ <memory-eviction-policy>LRU</memory-eviction-policy>
+ <name>url-failures-cache</name>
+ <overflow-to-disk>false</overflow-to-disk>
+ <!-- 45 minutes = 2700 seconds -->
+ <time-to-idle-seconds>2700</time-to-idle-seconds>
+ <!-- 30 minutes = 1800 seconds -->
+ <time-to-live-seconds>1800</time-to-live-seconds>
+ </configuration>
+ </component>
+
+
+ <!-- Don't drag in the world just to test this -->
+ <component>
+ <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers</implementation>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.archiva.web.repository.BypassSecuritySystem</implementation>
+ </component>
+
+ <component>
+ <role>org.apache.maven.archiva.webdav.ArchivaDavResourceFactory</role>
+ <implementation>org.apache.maven.archiva.web.repository.UnauthenticatedDavResourceFactory</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <field-name>archivaConfiguration</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
+ <field-name>repositoryFactory</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.repository.content.RepositoryRequest</role>
+ <field-name>repositoryRequest</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.proxy.RepositoryProxyConnectors</role>
+ <field-name>connectors</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.repository.metadata.MetadataTools</role>
+ <field-name>metadataTools</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.security.ServletAuthenticator</role>
+ <field-name>servletAuth</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.webdav.util.MimeTypes</role>
+ <field-name>mimeTypes</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator</role>
+ <role-hint>basic</role-hint>
+ <field-name>httpAuth</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ </components>
+</plexus>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<configuration>
+
+ <version>2</version>
+
+ <repositoryScanning>
+ <fileTypes>
+ <fileType>
+ <id>artifacts</id>
+ <patterns>
+ <pattern>**/*.pom</pattern>
+ <pattern>**/*.jar</pattern>
+ <pattern>**/*.ear</pattern>
+ <pattern>**/*.war</pattern>
+ <pattern>**/*.car</pattern>
+ <pattern>**/*.sar</pattern>
+ <pattern>**/*.mar</pattern>
+ <pattern>**/*.rar</pattern>
+ <pattern>**/*.dtd</pattern>
+ <pattern>**/*.tld</pattern>
+ <pattern>**/*.tar.gz</pattern>
+ <pattern>**/*.tar.bz2</pattern>
+ <pattern>**/*.zip</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>indexable-content</id>
+ <patterns>
+ <pattern>**/*.txt</pattern>
+ <pattern>**/*.TXT</pattern>
+ <pattern>**/*.block</pattern>
+ <pattern>**/*.config</pattern>
+ <pattern>**/*.pom</pattern>
+ <pattern>**/*.xml</pattern>
+ <pattern>**/*.xsd</pattern>
+ <pattern>**/*.dtd</pattern>
+ <pattern>**/*.tld</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>auto-remove</id>
+ <patterns>
+ <pattern>**/*.bak</pattern>
+ <pattern>**/*~</pattern>
+ <pattern>**/*-</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>ignored</id>
+ <patterns>
+ <pattern>**/.htaccess</pattern>
+ <pattern>**/KEYS</pattern>
+ <pattern>**/*.rb</pattern>
+ <pattern>**/*.sh</pattern>
+ <pattern>**/.svn/**</pattern>
+ <pattern>**/.DAV/**</pattern>
+ </patterns>
+ </fileType>
+ </fileTypes>
+ <knownContentConsumers>
+ <knownContentConsumer>update-db-artifact</knownContentConsumer>
+ <knownContentConsumer>create-missing-checksums</knownContentConsumer>
+ <knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
+ <knownContentConsumer>validate-checksum</knownContentConsumer>
+ <knownContentConsumer>validate-signature</knownContentConsumer>
+ <knownContentConsumer>index-content</knownContentConsumer>
+ <knownContentConsumer>auto-remove</knownContentConsumer>
+ <knownContentConsumer>auto-rename</knownContentConsumer>
+ </knownContentConsumers>
+ <invalidContentConsumers>
+ <invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
+ </invalidContentConsumers>
+ </repositoryScanning>
+
+ <databaseScanning>
+ <cronExpression>0 0 * * * ?</cronExpression>
+ <unprocessedConsumers>
+ <unprocessedConsumer>index-artifact</unprocessedConsumer>
+ <unprocessedConsumer>update-db-project</unprocessedConsumer>
+ <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
+ <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
+ <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
+ <unprocessedConsumer>index-public-methods</unprocessedConsumer>
+ </unprocessedConsumers>
+ <cleanupConsumers>
+ <cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer>
+ <cleanupConsumer>not-present-remove-db-project</cleanupConsumer>
+ <cleanupConsumer>not-present-remove-indexed</cleanupConsumer>
+ </cleanupConsumers>
+ </databaseScanning>
+
+</configuration>
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-parent</artifactId>
- <version>3-SNAPSHOT</version>
+ <version>4-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<name>Archiva</name>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>