summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webdav
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-11-13 06:33:14 +0000
committerOlivier Lamy <olamy@apache.org>2013-11-13 06:33:14 +0000
commit402f10c84133ca2cfbfc612255551b7c88791e32 (patch)
treebcdd1531f49e19b7b6982b27eeb5ab9b5e04ddf1 /archiva-modules/archiva-web/archiva-webdav
parentab6f5bde33f4ab6899557733fac009497053952e (diff)
downloadarchiva-402f10c84133ca2cfbfc612255551b7c88791e32.tar.gz
archiva-402f10c84133ca2cfbfc612255551b7c88791e32.zip
code cleanup comment
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1541400 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java159
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java127
2 files changed, 105 insertions, 181 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
index 4ef1ff4d3..e0ea0753a 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
@@ -137,11 +137,9 @@ public class ArchivaDavResourceFactoryTest
archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class );
config = new Configuration();
- //archivaConfiguration.getConfiguration();
- //archivaConfigurationControl.setReturnValue( config, 5, 20 );
expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 5, 20 );
archivaConfiguration.save( config );
- //archivaConfigurationControl.setVoidCallable( 1, 4 );
+
expectLastCall().times( 1, 4 );
archivaConfigurationControl.replay();
@@ -228,49 +226,36 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
- //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
+
expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
- // releasesRepo );
+
expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // false );
expect( repoRequest.isSupportFile(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( true );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
+
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
false );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // null );
+
expect( repoRequest.toArtifactReference(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ),
- // new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
- // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
+
expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ) ).andReturn(
new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
"target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
- // internalRepo );
+
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // false );
+
expect( repoRequest.isArchetypeCatalog(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
archivaConfigurationControl.replay();
@@ -318,49 +303,37 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
- //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
+
expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
- // internalRepo );
+
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
- // releasesRepo );
+
expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // false );
+
expect( repoRequest.isSupportFile(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
+
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
false );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // null );
+
expect( repoRequest.toArtifactReference(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ),
- // new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
- // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
+
expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ) ).andReturn(
new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
"target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // false );
+
expect( repoRequest.isArchetypeCatalog(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
archivaConfigurationControl.replay();
@@ -411,57 +384,41 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 4 );
- //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
+
expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
- // internalRepo );
+
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ),
- // localMirrorRepo );
+
expect( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ) ).andReturn( localMirrorRepo );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 4 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 4 );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false,
- // 2 );
+
expect( repoRequest.isSupportFile(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 );
+
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
false ).times( 2 );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // null, 2 );
+
expect( repoRequest.toArtifactReference(
"org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null ).times( 2 );
- //repoRequestControl.expectAndReturn(
- //repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
- // internalRepo ),
- //new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
- // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
+
expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ) ).andReturn(
new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
"target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
- //repoRequestControl.expectAndReturn(
- // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", localMirrorRepo ),
- // new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
- // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
+
expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
localMirrorRepo ) )
.andReturn( new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
"target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() );
- //repoRequestControl.expectAndReturn(
- // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
- // false, 2 );
+
expect( repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
archivaConfigurationControl.replay();
requestControl.replay();
@@ -502,31 +459,27 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
- // internalRepo );
+
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
- //requestControl.expectAndReturn( request.getRequestURI(),
- // "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" );
+
expect( request.getRequestURI() ).andReturn( "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" );
response.setHeader( "Pragma", "no-cache" );
- //responseControl.setVoidCallable();
+
expectLastCall();
response.setHeader( "Cache-Control", "no-cache" );
- //responseControl.setVoidCallable();
+
expectLastCall();
- //long date = 2039842134;
response.setDateHeader( eq("Last-Modified"), anyLong() );
- //responseControl.setVoidCallable();
expectLastCall();
archivaConfigurationControl.replay();
@@ -565,16 +518,15 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
- // internalRepo );
+
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
archivaConfigurationControl.replay();
@@ -615,16 +567,15 @@ public class ArchivaDavResourceFactoryTest
try
{
archivaConfigurationControl.reset();
- //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+
expect( archivaConfiguration.getConfiguration() ).andReturn( config );
- //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
- // legacyRepo );
+
expect( repoFactory.getManagedRepositoryContent( LEGACY_REPO ) ).andReturn( legacyRepo );
- //requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+
expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
- //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
- //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
archivaConfigurationControl.replay();
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
index 15345225b..fe16eea99 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
@@ -132,13 +132,12 @@ public class RepositoryServletSecurityTest
sr.registerServlet( "/repository/*", RepositoryServlet.class.getName() );
sc = sr.newClient();
- servletAuthControl = EasyMock.createControl();// MockControl.createControl( ServletAuthenticator.class );
- //servletAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+ servletAuthControl = EasyMock.createControl();
+
servletAuth = servletAuthControl.createMock( ServletAuthenticator.class );
httpAuthControl = EasyMock.createControl();
- //MockClassControl.createControl( HttpBasicAuthentication.class, HttpBasicAuthentication.class.getMethods() );
- //httpAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+
httpAuth = httpAuthControl.createMock( HttpAuthenticator.class );
davSessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );
@@ -218,18 +217,16 @@ public class RepositoryServletSecurityTest
servlet.setDavSessionProvider( davSessionProvider );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
- // new AuthenticationException( "Authentication error" ) );
+
servletAuth.isAuthenticated( EasyMock.anyObject( HttpServletRequest.class ),
EasyMock.anyObject( AuthenticationResult.class ) );
EasyMock.expectLastCall().andThrow( new AuthenticationException( "Authentication error" ) );
servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD );
- //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER );
- //servletAuthControl.setThrowable( new UnauthorizedException( "'guest' has no write access to repository" ) );
+
EasyMock.expectLastCall().andThrow( new UnauthorizedException( "'guest' has no write access to repository" ) );
httpAuthControl.replay();
@@ -240,7 +237,7 @@ public class RepositoryServletSecurityTest
httpAuthControl.verify();
servletAuthControl.verify();
- // assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode());
+ //assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode());
}
// test deploy with invalid user, but guest has write access to repo
@@ -267,38 +264,29 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
- // new AuthenticationException( "Authentication error" ) );
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ),
anyObject( AuthenticationResult.class ) ) ).andThrow(
new AuthenticationException( "Authentication error" ) );
- //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER );
- //servletAuthControl.setReturnValue( true );
EasyMock.expect(servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD )).andReturn( true );
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, result ),
- // new AuthenticationException( "Authentication error" ) );
+
EasyMock.expect(servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) )).andThrow( new AuthenticationException( "Authentication error" ) );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null );
EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( null );
// check if guest has write access
- //servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD );
- //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER );
- //servletAuthControl.setReturnValue( true );
EasyMock.expect( servletAuth.isAuthorized( "guest", "internal",
ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) ).andReturn(
true );
@@ -337,28 +325,26 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ),
anyObject( AuthenticationResult.class ) ) ).andReturn( true );
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ) ).andReturn( session );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
+
EasyMock.expect( httpAuth.getSessionUser( ic.getRequest().getSession() ) ).andReturn( new SimpleUser() );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ),
eq( result ) ) ).andReturn( true );
- //servletAuthControl.expectAndThrow(
- // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
- // new UnauthorizedException( "User not authorized" ) );
+
EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"),
eq(ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD) ) ).andThrow(
new UnauthorizedException( "User not authorized" ) );
@@ -400,10 +386,10 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class) )).andReturn( result );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ),
anyObject( AuthenticationResult.class ) ) ).andReturn( true );
@@ -412,19 +398,17 @@ public class RepositoryServletSecurityTest
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult(anyObject( HttpServletRequest.class ),
anyObject( HttpServletResponse.class) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ) ).andReturn( session );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), user );
+
EasyMock.expect( httpAuth.getSessionUser( ic.getRequest().getSession() ) ).andReturn( user );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn(
true );
- //servletAuthControl.expectAndReturn(
- // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
- // true );
+
EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"),
eq(ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD) ) ).andReturn(
true );
@@ -467,34 +451,29 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) )
.andReturn( result );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
- // new AuthenticationException( "Authentication error" ) );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andThrow(
new AuthenticationException( "Authentication error" ) );
- //servletAuthControl.expectAndReturn(
- // servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ),
- // true );
+
EasyMock.expect( servletAuth.isAuthorized( "guest", "internal",
ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ).andReturn(
true );
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null );
+
EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( null );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn(
true );
- //servletAuthControl.expectAndReturn(
- // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
- // true );
+
EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"),
eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andReturn(
true );
@@ -529,15 +508,12 @@ public class RepositoryServletSecurityTest
servlet.setDavSessionProvider( davSessionProvider );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
- // new AuthenticationException( "Authentication error" ) );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andThrow(
new AuthenticationException( "Authentication error" ) );
- //servletAuthControl.expectAndReturn(
- // servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ),
- // false );
+
EasyMock.expect( servletAuth.isAuthorized( "guest", "internal",
ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ).andReturn(
false );
@@ -577,24 +553,22 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true );
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
+
EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( new SimpleUser() );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn(
true );
- //servletAuthControl.expectAndReturn(
- // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
- // true );
+
EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"),
eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andReturn(
true );
@@ -636,24 +610,23 @@ public class RepositoryServletSecurityTest
servlet.setResourceFactory( archivaDavResourceFactory );
AuthenticationResult result = new AuthenticationResult();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true );
// ArchivaDavResourceFactory#isAuthorized()
SecuritySession session = new DefaultSecuritySession();
- //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
+
EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result );
- //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
+
EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class) ) ).andReturn( session );
- //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
+
EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class) ) ).andReturn( new SimpleUser() );
- //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
+
EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn(
true );
- //servletAuthControl.expectAndThrow( servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
- // new UnauthorizedException( "User not authorized to read repository." ) );
+
EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"),
eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andThrow(
new UnauthorizedException( "User not authorized to read repository." ) );