From: James William Dumay Date: Wed, 28 May 2008 02:12:38 +0000 (+0000) Subject: Moved repository servlet and tests X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a33faee5e0d57e82fa29e647dabd43aa5ccb810f;p=archiva.git Moved repository servlet and tests git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@660786 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/pom.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/pom.xml index 7680279c0..773b669bb 100644 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -233,23 +233,6 @@ activation provided - - - org.mortbay.jetty - jetty - 6.1.5 - test - - - httpunit - httpunit - 1.6.2 - test - - - xmlunit - xmlunit - org.codehaus.plexus plexus-quartz @@ -264,42 +247,6 @@ org.codehaus.plexus plexus-taskqueue - - org.codehaus.plexus.redback - redback-keys-memory - ${redback.version} - test - - - org.codehaus.plexus - plexus-container-default - - - - - org.codehaus.plexus.redback - redback-rbac-memory - ${redback.version} - test - - - org.codehaus.plexus - plexus-container-default - - - - - org.codehaus.plexus.redback - redback-users-memory - ${redback.version} - test - - - org.codehaus.plexus - plexus-container-default - - - commons-fileupload commons-fileupload diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ArchivaMimeTypeLoader.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ArchivaMimeTypeLoader.java deleted file mode 100644 index b289188ed..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/ArchivaMimeTypeLoader.java +++ /dev/null @@ -1,72 +0,0 @@ -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 Joakim Erdfelt - * @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 ); - } - } - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/PolicingServletRequest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/PolicingServletRequest.java deleted file mode 100644 index 085b3dcdd..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/PolicingServletRequest.java +++ /dev/null @@ -1,75 +0,0 @@ -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 Joakim Erdfelt - * @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; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java deleted file mode 100644 index 7ced43901..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java +++ /dev/null @@ -1,264 +0,0 @@ -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 Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryServlet - extends AbstractWebdavServlet - implements ConfigurationListener -{ - private Logger log = LoggerFactory.getLogger( RepositoryServlet.class ); - - private ArchivaConfiguration configuration; - - private Map 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\""; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml index ab9ae2f45..b732fe8b5 100644 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml @@ -81,7 +81,7 @@ RepositoryServlet - org.apache.maven.archiva.web.repository.RepositoryServlet + org.apache.maven.archiva.webdav.RepositoryServlet 1 diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java deleted file mode 100644 index b35de9fdc..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java +++ /dev/null @@ -1,253 +0,0 @@ -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 Joakim Erdfelt - * @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( "\n\n" ); - buf.append( "\n" ); - buf.append( " " ).append( groupId ).append( "\n" ); - buf.append( " " ).append( artifactId ).append( "\n" ); - buf.append( " " ).append( version ).append( "\n" ); - - boolean hasSnapshot = StringUtils.isNotBlank( timestamp ) || StringUtils.isNotBlank( buildNumber ); - boolean hasLastUpdated = StringUtils.isNotBlank( lastUpdated ); - - if ( hasSnapshot || hasLastUpdated ) - { - buf.append( " \n" ); - if ( hasSnapshot ) - { - buf.append( " \n" ); - buf.append( " " ).append( buildNumber ).append( "\n" ); - buf.append( " " ).append( timestamp ).append( "\n" ); - buf.append( " \n" ); - } - if ( hasLastUpdated ) - { - buf.append( " " ).append( lastUpdated ).append( "\n" ); - } - buf.append( " \n" ); - } - buf.append( "" ); - - return buf.toString(); - } - - protected String createProjectMetadata( String groupId, String artifactId, String latest, String release, - String[] versions ) - { - StringBuffer buf = new StringBuffer(); - - buf.append( "\n\n" ); - buf.append( "\n" ); - buf.append( " " ).append( groupId ).append( "\n" ); - buf.append( " " ).append( artifactId ).append( "\n" ); - - boolean hasLatest = StringUtils.isNotBlank( latest ); - boolean hasRelease = StringUtils.isNotBlank( release ); - boolean hasVersions = !ArrayUtils.isEmpty( versions ); - - if ( hasLatest || hasRelease || hasVersions ) - { - buf.append( " \n" ); - if ( hasLatest ) - { - buf.append( " " ).append( latest ).append( "\n" ); - } - if ( hasRelease ) - { - buf.append( " " ).append( release ).append( "\n" ); - } - if ( hasVersions ) - { - buf.append( " \n" ); - for ( String availVersion : versions ) - { - buf.append( " " ).append( availVersion ).append( "\n" ); - } - buf.append( " \n" ); - } - buf.append( " \n" ); - } - buf.append( "" ); - - return buf.toString(); - } - - protected String createGroupMetadata( String groupId, String[] plugins ) - { - StringBuffer buf = new StringBuffer(); - - buf.append( "\n\n" ); - buf.append( "\n" ); - buf.append( " " ).append( groupId ).append( "\n" ); - - boolean hasPlugins = !ArrayUtils.isEmpty( plugins ); - - if ( hasPlugins ) - { - buf.append( " \n" ); - for ( String plugin : plugins ) - { - buf.append( " \n" ); - buf.append( " " ).append( plugin ).append( "\n" ); - buf.append( " " ).append( plugin + "-maven-plugin" ).append( "\n" ); - buf.append( " " ).append( "The " + plugin + " Plugin" ).append( "\n" ); - buf.append( " \n" ); - } - buf.append( " \n" ); - } - buf.append( "" ); - - 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 = "\n" + "\n" -// + " org.apache.maven.plugins\n" + " maven-assembly-plugin\n" -// + " 2.2-beta-2-SNAPSHOT\n" + " \n" + " \n" -// + " 20071017.162810\n" + " 20\n" -// + " \n" + " 20071017162814\n" + " \n" -// + ""; -// String expectedManagedContents = null; -// File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents ); -// -// if ( hasManagedCopy ) -// { -// expectedManagedContents = "\n" + " org.apache.maven.plugins\n" -// + " maven-assembly-plugin\n" + " 2.2-beta-2-SNAPSHOT\n" -// + ""; -// -// 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(); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java deleted file mode 100644 index 28a68977d..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java +++ /dev/null @@ -1,252 +0,0 @@ -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 Joakim Erdfelt - * @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(); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletTestCase.java deleted file mode 100644 index 6f2df4c32..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletTestCase.java +++ /dev/null @@ -1,227 +0,0 @@ -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 Joakim Erdfelt - * @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; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/BypassSecuritySystem.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/BypassSecuritySystem.java deleted file mode 100644 index e99d7b42d..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/BypassSecuritySystem.java +++ /dev/null @@ -1,134 +0,0 @@ -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 Joakim Erdfelt - * @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; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/MimeTypesLoaderTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/MimeTypesLoaderTest.java deleted file mode 100644 index e58c1dba2..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/MimeTypesLoaderTest.java +++ /dev/null @@ -1,48 +0,0 @@ -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 Joakim Erdfelt - * @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")); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletBrowseTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletBrowseTest.java deleted file mode 100644 index 63e123470..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletBrowseTest.java +++ /dev/null @@ -1,62 +0,0 @@ -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 Joakim Erdfelt - * @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() ); - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletDeployTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletDeployTest.java deleted file mode 100644 index ec53e804d..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletDeployTest.java +++ /dev/null @@ -1,62 +0,0 @@ -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 Joakim Erdfelt - * @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() ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java deleted file mode 100644 index 15df75479..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java +++ /dev/null @@ -1,110 +0,0 @@ -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 Joakim Erdfelt - * @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() ); - } - -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyTest.java deleted file mode 100644 index 3222c01b3..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyTest.java +++ /dev/null @@ -1,258 +0,0 @@ -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 Joakim Erdfelt - * @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() ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java deleted file mode 100644 index 883f38252..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java +++ /dev/null @@ -1,118 +0,0 @@ -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 Joakim Erdfelt - * @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 ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java deleted file mode 100644 index 2f4272922..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java +++ /dev/null @@ -1,166 +0,0 @@ -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 Joakim Erdfelt - * @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 ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedPluginSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedPluginSnapshotPolicyTest.java deleted file mode 100644 index 7d252bb1d..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedPluginSnapshotPolicyTest.java +++ /dev/null @@ -1,195 +0,0 @@ -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 Joakim Erdfelt - * @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; - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedReleasePolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedReleasePolicyTest.java deleted file mode 100644 index ebf944e1a..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedReleasePolicyTest.java +++ /dev/null @@ -1,193 +0,0 @@ -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 Joakim Erdfelt - * @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; - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedRelocatedTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedRelocatedTest.java deleted file mode 100644 index b0ca79344..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedRelocatedTest.java +++ /dev/null @@ -1,79 +0,0 @@ -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 Joakim Erdfelt - * @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 = "" + - "4.0.0" + - "archiva" + - "test" + - "1.0" + - "" + - "" + - "org.apache.archiva" + - "" + - "" + - ""; - 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() ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedSnapshotPolicyTest.java deleted file mode 100644 index 7db24e4f9..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedSnapshotPolicyTest.java +++ /dev/null @@ -1,195 +0,0 @@ -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 Joakim Erdfelt - * @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; - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java deleted file mode 100644 index dbff0a725..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java +++ /dev/null @@ -1,195 +0,0 @@ -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 Joakim Erdfelt - * @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; - } - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletRepositoryGroupTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletRepositoryGroupTest.java deleted file mode 100644 index 72684fd01..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletRepositoryGroupTest.java +++ /dev/null @@ -1,234 +0,0 @@ -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 managedRepoIds = new ArrayList(); - 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 invalidManagedRepoIds = new ArrayList(); - 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 repositories ) - { - RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration(); - repoGroupConfiguration.setId( id ); - repoGroupConfiguration.setRepositories( repositories ); - return repoGroupConfiguration; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.java deleted file mode 100644 index f87cdb26b..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.apache.maven.archiva.web.repository; - -/** - * RepositoryServletSecurityTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryServletSecurityTest - extends AbstractRepositoryServletTestCase -{ - public void testSecuredGet() - { - - } - - public void testSecuredBrowse() - { - - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java deleted file mode 100644 index 201d1db99..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java +++ /dev/null @@ -1,124 +0,0 @@ -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 Joakim Erdfelt - * @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() ); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/StubRepositoryContentConsumers.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/StubRepositoryContentConsumers.java deleted file mode 100644 index 13324f1d3..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/StubRepositoryContentConsumers.java +++ /dev/null @@ -1,21 +0,0 @@ -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 getSelectedKnownConsumers() - { - return getAvailableKnownConsumers(); - } - - public synchronized List getSelectedInvalidConsumers() - { - return getAvailableInvalidConsumers(); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavResourceFactory.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavResourceFactory.java deleted file mode 100644 index 548211bf7..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavResourceFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -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 Maria Odea Ching - * @version $Id: - */ -public class UnauthenticatedDavResourceFactory - extends ArchivaDavResourceFactory -{ - @Override - protected boolean isAuthorized( DavServletRequest request, String repositoryId ) - throws DavException - { - return true; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavSessionProvider.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavSessionProvider.java deleted file mode 100644 index 47423f465..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedDavSessionProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -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 James William Dumay - */ -public class UnauthenticatedDavSessionProvider extends ArchivaDavSessionProvider -{ - public UnauthenticatedDavSessionProvider(WebApplicationContext applicationContext) - { - super(applicationContext); - } - - @Override - public boolean attachSession( WebdavRequest request ) - throws DavException - { - return true; - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedRepositoryServlet.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedRepositoryServlet.java deleted file mode 100644 index 492ec2f56..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/UnauthenticatedRepositoryServlet.java +++ /dev/null @@ -1,46 +0,0 @@ -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 Joakim Erdfelt - * @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); - } -} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.xml deleted file mode 100644 index d7087095a..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletSecurityTest.xml +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager - basic - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - org.apache.maven.archiva.policies.PreDownloadPolicy - prePolicies - - - org.apache.maven.archiva.policies.PostDownloadPolicy - postPolicies - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - org.apache.maven.archiva.webdav.DavServerManager - default - org.apache.maven.archiva.webdav.DefaultDavServerManager - DefaultDavServerManager - - proxied - - - - - org.codehaus.plexus.cache.Cache - url-failures-cache - org.codehaus.plexus.cache.ehcache.EhcacheCache - URL Failure Cache - - 600 - false - ${java.io.tmpdir}/archiva/urlcache - false - 1000 - LRU - url-failures-cache - false - - 2700 - - 1800 - - - - - - - org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers - default - org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers - - - - - org.codehaus.plexus.redback.system.SecuritySystem - default - org.codehaus.plexus.redback.system.DefaultSecuritySystem - - - org.codehaus.plexus.redback.authentication.AuthenticationManager - authnManager - - - org.codehaus.plexus.redback.authorization.Authorizer - rbac - authorizer - - - org.codehaus.plexus.redback.users.UserManager - memory - userManager - - - org.codehaus.plexus.redback.keys.KeyManager - memory - keyManager - - - org.codehaus.plexus.redback.policy.UserSecurityPolicy - policy - - - - - - org.codehaus.plexus.redback.authentication.Authenticator - user-manager - org.codehaus.plexus.redback.authentication.users.UserManagerAuthenticator - - - org.codehaus.plexus.redback.users.UserManager - memory - userManager - - - org.codehaus.plexus.redback.policy.UserSecurityPolicy - securityPolicy - - - - - - org.codehaus.plexus.redback.authentication.Authenticator - keystore - org.codehaus.plexus.redback.authentication.keystore.KeyStoreAuthenticator - - - org.codehaus.plexus.redback.keys.KeyManager - memory - keystore - - - org.codehaus.plexus.redback.users.UserManager - memory - userManager - - - - - - org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator - default - org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator - - - - org.codehaus.plexus.redback.users.UserManager - memory - userManager - - - - - - org.codehaus.plexus.redback.authorization.Authorizer - rbac - org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer - - - org.codehaus.plexus.redback.rbac.RBACManager - memory - manager - - - org.codehaus.plexus.redback.users.UserManager - memory - userManager - - - org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator - default - evaluator - - - - - - org.codehaus.plexus.redback.role.RoleManager - default - org.codehaus.plexus.redback.role.DefaultRoleManager - singleton - - - org.codehaus.plexus.redback.role.merger.RoleModelMerger - default - modelMerger - - - org.codehaus.plexus.redback.role.validator.RoleModelValidator - default - modelValidator - - - org.codehaus.plexus.redback.role.processor.RoleModelProcessor - default - modelProcessor - - - org.codehaus.plexus.redback.role.template.RoleTemplateProcessor - default - templateProcessor - - - org.codehaus.plexus.redback.rbac.RBACManager - memory - rbacManager - - - org.codehaus.plexus.PlexusContainer - container - - - - - - org.codehaus.plexus.redback.role.processor.RoleModelProcessor - default - org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor - - - org.codehaus.plexus.redback.rbac.RBACManager - memory - rbacManager - - - - - - org.codehaus.plexus.redback.role.template.RoleTemplateProcessor - default - org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor - - - org.codehaus.plexus.redback.rbac.RBACManager - memory - rbacManager - - - - - diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletTest.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletTest.xml deleted file mode 100644 index 43e6ed727..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/repository/RepositoryServletTest.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager - basic - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - org.apache.maven.archiva.policies.PreDownloadPolicy - prePolicies - - - org.apache.maven.archiva.policies.PostDownloadPolicy - postPolicies - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - org.apache.maven.archiva.webdav.DavServerManager - default - org.apache.maven.archiva.webdav.DefaultDavServerManager - DefaultDavServerManager - - - org.apache.maven.archiva.webdav.DavServerComponent - proxied - - - - - - org.codehaus.plexus.cache.Cache - url-failures-cache - org.codehaus.plexus.cache.ehcache.EhcacheCache - URL Failure Cache - - 600 - false - ${java.io.tmpdir}/archiva/urlcache - false - 1000 - LRU - url-failures-cache - false - - 2700 - - 1800 - - - - - - - org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers - default - org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers - - - - org.codehaus.plexus.redback.system.SecuritySystem - default - org.apache.maven.archiva.web.repository.BypassSecuritySystem - - - - org.apache.maven.archiva.webdav.ArchivaDavResourceFactory - org.apache.maven.archiva.web.repository.UnauthenticatedDavResourceFactory - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - archivaConfiguration - - - org.apache.maven.archiva.repository.RepositoryContentFactory - repositoryFactory - - - org.apache.maven.archiva.repository.content.RepositoryRequest - repositoryRequest - - - org.apache.maven.archiva.proxy.RepositoryProxyConnectors - connectors - - - org.apache.maven.archiva.repository.metadata.MetadataTools - metadataTools - - - org.apache.maven.archiva.security.ServletAuthenticator - servletAuth - - - org.apache.maven.archiva.webdav.util.MimeTypes - mimeTypes - - - org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator - basic - httpAuth - - - - - diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/repository-archiva.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/repository-archiva.xml deleted file mode 100644 index 997d62b00..000000000 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webapp/src/test/resources/repository-archiva.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - 2 - - - - - artifacts - - **/*.pom - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.dtd - **/*.tld - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - - - - indexable-content - - **/*.txt - **/*.TXT - **/*.block - **/*.config - **/*.pom - **/*.xml - **/*.xsd - **/*.dtd - **/*.tld - - - - auto-remove - - **/*.bak - **/*~ - **/*- - - - - ignored - - **/.htaccess - **/KEYS - **/*.rb - **/*.sh - **/.svn/** - **/.DAV/** - - - - - update-db-artifact - create-missing-checksums - update-db-repository-metadata - validate-checksum - validate-signature - index-content - auto-remove - auto-rename - - - update-db-bad-content - - - - - 0 0 * * * ? - - index-artifact - update-db-project - validate-repository-metadata - index-archive-toc - update-db-bytecode-stats - index-public-methods - - - not-present-remove-db-artifact - not-present-remove-db-project - not-present-remove-indexed - - - - diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/pom.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/pom.xml index ed8b416fe..6763a8867 100644 --- a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -111,6 +111,52 @@ + + xmlunit + xmlunit + + + org.mortbay.jetty + jetty + 6.1.5 + test + + + org.codehaus.plexus.redback + redback-keys-memory + ${redback.version} + test + + + org.codehaus.plexus + plexus-container-default + + + + + org.codehaus.plexus.redback + redback-rbac-memory + ${redback.version} + test + + + org.codehaus.plexus + plexus-container-default + + + + + org.codehaus.plexus.redback + redback-users-memory + ${redback.version} + test + + + org.codehaus.plexus + plexus-container-default + + + diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java new file mode 100644 index 000000000..ca6cc9bc7 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java @@ -0,0 +1,263 @@ +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 Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryServlet + extends AbstractWebdavServlet + implements ConfigurationListener +{ + private Logger log = LoggerFactory.getLogger( RepositoryServlet.class ); + + private ArchivaConfiguration configuration; + + private Map 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\""; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java new file mode 100644 index 000000000..c11da99c1 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java @@ -0,0 +1,253 @@ +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 Joakim Erdfelt + * @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( "\n\n" ); + buf.append( "\n" ); + buf.append( " " ).append( groupId ).append( "\n" ); + buf.append( " " ).append( artifactId ).append( "\n" ); + buf.append( " " ).append( version ).append( "\n" ); + + boolean hasSnapshot = StringUtils.isNotBlank( timestamp ) || StringUtils.isNotBlank( buildNumber ); + boolean hasLastUpdated = StringUtils.isNotBlank( lastUpdated ); + + if ( hasSnapshot || hasLastUpdated ) + { + buf.append( " \n" ); + if ( hasSnapshot ) + { + buf.append( " \n" ); + buf.append( " " ).append( buildNumber ).append( "\n" ); + buf.append( " " ).append( timestamp ).append( "\n" ); + buf.append( " \n" ); + } + if ( hasLastUpdated ) + { + buf.append( " " ).append( lastUpdated ).append( "\n" ); + } + buf.append( " \n" ); + } + buf.append( "" ); + + return buf.toString(); + } + + protected String createProjectMetadata( String groupId, String artifactId, String latest, String release, + String[] versions ) + { + StringBuffer buf = new StringBuffer(); + + buf.append( "\n\n" ); + buf.append( "\n" ); + buf.append( " " ).append( groupId ).append( "\n" ); + buf.append( " " ).append( artifactId ).append( "\n" ); + + boolean hasLatest = StringUtils.isNotBlank( latest ); + boolean hasRelease = StringUtils.isNotBlank( release ); + boolean hasVersions = !ArrayUtils.isEmpty( versions ); + + if ( hasLatest || hasRelease || hasVersions ) + { + buf.append( " \n" ); + if ( hasLatest ) + { + buf.append( " " ).append( latest ).append( "\n" ); + } + if ( hasRelease ) + { + buf.append( " " ).append( release ).append( "\n" ); + } + if ( hasVersions ) + { + buf.append( " \n" ); + for ( String availVersion : versions ) + { + buf.append( " " ).append( availVersion ).append( "\n" ); + } + buf.append( " \n" ); + } + buf.append( " \n" ); + } + buf.append( "" ); + + return buf.toString(); + } + + protected String createGroupMetadata( String groupId, String[] plugins ) + { + StringBuffer buf = new StringBuffer(); + + buf.append( "\n\n" ); + buf.append( "\n" ); + buf.append( " " ).append( groupId ).append( "\n" ); + + boolean hasPlugins = !ArrayUtils.isEmpty( plugins ); + + if ( hasPlugins ) + { + buf.append( " \n" ); + for ( String plugin : plugins ) + { + buf.append( " \n" ); + buf.append( " " ).append( plugin ).append( "\n" ); + buf.append( " " ).append( plugin + "-maven-plugin" ).append( "\n" ); + buf.append( " " ).append( "The " + plugin + " Plugin" ).append( "\n" ); + buf.append( " \n" ); + } + buf.append( " \n" ); + } + buf.append( "" ); + + 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 = "\n" + "\n" +// + " org.apache.maven.plugins\n" + " maven-assembly-plugin\n" +// + " 2.2-beta-2-SNAPSHOT\n" + " \n" + " \n" +// + " 20071017.162810\n" + " 20\n" +// + " \n" + " 20071017162814\n" + " \n" +// + ""; +// String expectedManagedContents = null; +// File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents ); +// +// if ( hasManagedCopy ) +// { +// expectedManagedContents = "\n" + " org.apache.maven.plugins\n" +// + " maven-assembly-plugin\n" + " 2.2-beta-2-SNAPSHOT\n" +// + ""; +// +// 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(); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java new file mode 100644 index 000000000..1c1233748 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java @@ -0,0 +1,252 @@ +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 Joakim Erdfelt + * @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(); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java new file mode 100644 index 000000000..6900bc13d --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java @@ -0,0 +1,230 @@ +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 Joakim Erdfelt + * @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; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/BypassSecuritySystem.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/BypassSecuritySystem.java new file mode 100644 index 000000000..9ad1ae6f9 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/BypassSecuritySystem.java @@ -0,0 +1,134 @@ +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 Joakim Erdfelt + * @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; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MimeTypesLoaderTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MimeTypesLoaderTest.java new file mode 100644 index 000000000..49c10b9c3 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MimeTypesLoaderTest.java @@ -0,0 +1,48 @@ +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 Joakim Erdfelt + * @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")); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java new file mode 100644 index 000000000..885b8c1e6 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java @@ -0,0 +1,62 @@ +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 Joakim Erdfelt + * @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() ); + } + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java new file mode 100644 index 000000000..32ef17d20 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java @@ -0,0 +1,62 @@ +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 Joakim Erdfelt + * @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() ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyMetadataTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyMetadataTest.java new file mode 100644 index 000000000..5efdb52eb --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyMetadataTest.java @@ -0,0 +1,110 @@ +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 Joakim Erdfelt + * @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() ); + } + +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java new file mode 100644 index 000000000..2a6d2e40f --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java @@ -0,0 +1,258 @@ +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 Joakim Erdfelt + * @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() ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataLocalOnlyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataLocalOnlyTest.java new file mode 100644 index 000000000..6c9d7dac8 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataLocalOnlyTest.java @@ -0,0 +1,118 @@ +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 Joakim Erdfelt + * @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 ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataRemoteOnlyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataRemoteOnlyTest.java new file mode 100644 index 000000000..9a2af21c8 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedMetadataRemoteOnlyTest.java @@ -0,0 +1,166 @@ +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 Joakim Erdfelt + * @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 ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java new file mode 100644 index 000000000..a776b5dce --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedPluginSnapshotPolicyTest.java @@ -0,0 +1,195 @@ +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 Joakim Erdfelt + * @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; + } + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java new file mode 100644 index 000000000..144d49bb9 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedReleasePolicyTest.java @@ -0,0 +1,193 @@ +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 Joakim Erdfelt + * @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; + } + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedRelocatedTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedRelocatedTest.java new file mode 100644 index 000000000..2303836b6 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedRelocatedTest.java @@ -0,0 +1,79 @@ +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 Joakim Erdfelt + * @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 = "" + + "4.0.0" + + "archiva" + + "test" + + "1.0" + + "" + + "" + + "org.apache.archiva" + + "" + + "" + + ""; + 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() ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java new file mode 100644 index 000000000..da944d9f2 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedSnapshotPolicyTest.java @@ -0,0 +1,195 @@ +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 Joakim Erdfelt + * @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; + } + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java new file mode 100644 index 000000000..2a34b9ab0 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java @@ -0,0 +1,195 @@ +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 Joakim Erdfelt + * @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; + } + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java new file mode 100644 index 000000000..57453ea81 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java @@ -0,0 +1,234 @@ +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 managedRepoIds = new ArrayList(); + 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 invalidManagedRepoIds = new ArrayList(); + 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 repositories ) + { + RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration(); + repoGroupConfiguration.setId( id ); + repoGroupConfiguration.setRepositories( repositories ); + return repoGroupConfiguration; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java new file mode 100644 index 000000000..badd20cb6 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java @@ -0,0 +1,21 @@ +package org.apache.maven.archiva.webdav; + +/** + * RepositoryServletSecurityTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryServletSecurityTest + extends AbstractRepositoryServletTestCase +{ + public void testSecuredGet() + { + + } + + public void testSecuredBrowse() + { + + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletTest.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletTest.java new file mode 100644 index 000000000..41b0b09fc --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletTest.java @@ -0,0 +1,123 @@ +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 Joakim Erdfelt + * @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() ); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/StubRepositoryContentConsumers.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/StubRepositoryContentConsumers.java new file mode 100644 index 000000000..ff9dbd237 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/StubRepositoryContentConsumers.java @@ -0,0 +1,21 @@ +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 getSelectedKnownConsumers() + { + return getAvailableKnownConsumers(); + } + + public synchronized List getSelectedInvalidConsumers() + { + return getAvailableInvalidConsumers(); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavResourceFactory.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavResourceFactory.java new file mode 100644 index 000000000..81d739d3a --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavResourceFactory.java @@ -0,0 +1,41 @@ +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 Maria Odea Ching + * @version $Id: + */ +public class UnauthenticatedDavResourceFactory + extends ArchivaDavResourceFactory +{ + @Override + protected boolean isAuthorized( DavServletRequest request, String repositoryId ) + throws DavException + { + return true; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavSessionProvider.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavSessionProvider.java new file mode 100644 index 000000000..567f348f0 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedDavSessionProvider.java @@ -0,0 +1,43 @@ +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 James William Dumay + */ +public class UnauthenticatedDavSessionProvider extends ArchivaDavSessionProvider +{ + public UnauthenticatedDavSessionProvider(WebApplicationContext applicationContext) + { + super(applicationContext); + } + + @Override + public boolean attachSession( WebdavRequest request ) + throws DavException + { + return true; + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedRepositoryServlet.java b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedRepositoryServlet.java new file mode 100644 index 000000000..57f37931c --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/UnauthenticatedRepositoryServlet.java @@ -0,0 +1,47 @@ +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 Joakim Erdfelt + * @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); + } +} diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j.xml new file mode 100644 index 000000000..a2e7ea23d --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml new file mode 100644 index 000000000..d7087095a --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml @@ -0,0 +1,273 @@ + + + + + + + + org.codehaus.plexus.logging.LoggerManager + org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager + basic + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + configured + + + org.apache.maven.archiva.policies.PreDownloadPolicy + prePolicies + + + org.apache.maven.archiva.policies.PostDownloadPolicy + postPolicies + + + + + org.codehaus.plexus.registry.Registry + configured + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + + org.apache.maven.archiva.webdav.DavServerManager + default + org.apache.maven.archiva.webdav.DefaultDavServerManager + DefaultDavServerManager + + proxied + + + + + org.codehaus.plexus.cache.Cache + url-failures-cache + org.codehaus.plexus.cache.ehcache.EhcacheCache + URL Failure Cache + + 600 + false + ${java.io.tmpdir}/archiva/urlcache + false + 1000 + LRU + url-failures-cache + false + + 2700 + + 1800 + + + + + + + org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers + default + org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers + + + + + org.codehaus.plexus.redback.system.SecuritySystem + default + org.codehaus.plexus.redback.system.DefaultSecuritySystem + + + org.codehaus.plexus.redback.authentication.AuthenticationManager + authnManager + + + org.codehaus.plexus.redback.authorization.Authorizer + rbac + authorizer + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + org.codehaus.plexus.redback.keys.KeyManager + memory + keyManager + + + org.codehaus.plexus.redback.policy.UserSecurityPolicy + policy + + + + + + org.codehaus.plexus.redback.authentication.Authenticator + user-manager + org.codehaus.plexus.redback.authentication.users.UserManagerAuthenticator + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + org.codehaus.plexus.redback.policy.UserSecurityPolicy + securityPolicy + + + + + + org.codehaus.plexus.redback.authentication.Authenticator + keystore + org.codehaus.plexus.redback.authentication.keystore.KeyStoreAuthenticator + + + org.codehaus.plexus.redback.keys.KeyManager + memory + keystore + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + + + + org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator + default + org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator + + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + + + + org.codehaus.plexus.redback.authorization.Authorizer + rbac + org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + manager + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator + default + evaluator + + + + + + org.codehaus.plexus.redback.role.RoleManager + default + org.codehaus.plexus.redback.role.DefaultRoleManager + singleton + + + org.codehaus.plexus.redback.role.merger.RoleModelMerger + default + modelMerger + + + org.codehaus.plexus.redback.role.validator.RoleModelValidator + default + modelValidator + + + org.codehaus.plexus.redback.role.processor.RoleModelProcessor + default + modelProcessor + + + org.codehaus.plexus.redback.role.template.RoleTemplateProcessor + default + templateProcessor + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + org.codehaus.plexus.PlexusContainer + container + + + + + + org.codehaus.plexus.redback.role.processor.RoleModelProcessor + default + org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + + + + org.codehaus.plexus.redback.role.template.RoleTemplateProcessor + default + org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + + + diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml new file mode 100644 index 000000000..43e6ed727 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml @@ -0,0 +1,154 @@ + + + + + + + + org.codehaus.plexus.logging.LoggerManager + org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager + basic + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + configured + + + org.apache.maven.archiva.policies.PreDownloadPolicy + prePolicies + + + org.apache.maven.archiva.policies.PostDownloadPolicy + postPolicies + + + + + org.codehaus.plexus.registry.Registry + configured + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + + org.apache.maven.archiva.webdav.DavServerManager + default + org.apache.maven.archiva.webdav.DefaultDavServerManager + DefaultDavServerManager + + + org.apache.maven.archiva.webdav.DavServerComponent + proxied + + + + + + org.codehaus.plexus.cache.Cache + url-failures-cache + org.codehaus.plexus.cache.ehcache.EhcacheCache + URL Failure Cache + + 600 + false + ${java.io.tmpdir}/archiva/urlcache + false + 1000 + LRU + url-failures-cache + false + + 2700 + + 1800 + + + + + + + org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers + default + org.apache.maven.archiva.web.repository.StubRepositoryContentConsumers + + + + org.codehaus.plexus.redback.system.SecuritySystem + default + org.apache.maven.archiva.web.repository.BypassSecuritySystem + + + + org.apache.maven.archiva.webdav.ArchivaDavResourceFactory + org.apache.maven.archiva.web.repository.UnauthenticatedDavResourceFactory + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + archivaConfiguration + + + org.apache.maven.archiva.repository.RepositoryContentFactory + repositoryFactory + + + org.apache.maven.archiva.repository.content.RepositoryRequest + repositoryRequest + + + org.apache.maven.archiva.proxy.RepositoryProxyConnectors + connectors + + + org.apache.maven.archiva.repository.metadata.MetadataTools + metadataTools + + + org.apache.maven.archiva.security.ServletAuthenticator + servletAuth + + + org.apache.maven.archiva.webdav.util.MimeTypes + mimeTypes + + + org.codehaus.plexus.redback.xwork.filter.authentication.HttpAuthenticator + basic + httpAuth + + + + + diff --git a/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/repository-archiva.xml b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/repository-archiva.xml new file mode 100644 index 000000000..997d62b00 --- /dev/null +++ b/moved-repo-servlet/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/repository-archiva.xml @@ -0,0 +1,111 @@ + + + + + + 2 + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + + indexable-content + + **/*.txt + **/*.TXT + **/*.block + **/*.config + **/*.pom + **/*.xml + **/*.xsd + **/*.dtd + **/*.tld + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + + + update-db-artifact + create-missing-checksums + update-db-repository-metadata + validate-checksum + validate-signature + index-content + auto-remove + auto-rename + + + update-db-bad-content + + + + + 0 0 * * * ? + + index-artifact + update-db-project + validate-repository-metadata + index-archive-toc + update-db-bytecode-stats + index-public-methods + + + not-present-remove-db-artifact + not-present-remove-db-project + not-present-remove-indexed + + + + diff --git a/moved-repo-servlet/pom.xml b/moved-repo-servlet/pom.xml index e0811fec0..47a20ba21 100644 --- a/moved-repo-servlet/pom.xml +++ b/moved-repo-servlet/pom.xml @@ -28,7 +28,7 @@ org.apache.archiva archiva-parent - 3-SNAPSHOT + 4-SNAPSHOT ../parent/pom.xml Archiva @@ -184,6 +184,12 @@ 3.8.1 test + + httpunit + httpunit + 1.6.2 + test + easymock easymock