archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r905996 - in /archiva/trunk/archiva-modules/archiva-web: archiva-webapp-test/src/test/resources/ archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/
Date Wed, 03 Feb 2010 11:11:13 GMT
Author: oching
Date: Wed Feb  3 11:11:06 2010
New Revision: 905996

URL: http://svn.apache.org/viewvc?rev=905996&view=rev
Log:
[MRM-1316] audit log report does not restrict events to repositories that you are a manager
of
o filter the results and show only actions performed on repos which the user has access to
o added selenium test

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties?rev=905996&r1=905995&r2=905996&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
Wed Feb  3 11:11:06 2010
@@ -77,6 +77,13 @@
 ARTIFACTFILEPATH1=test
 REPOSITORYID1=internal
 
+SNAPSHOT_GROUPID=org.apache.archiva
+SNAPSHOT_ARTIFACTID=archiva-test
+SNAPSHOT_VERSION=1.0-SNAPSHOT
+SNAPSHOT_PACKAGING=jar
+SNAPSHOT_ARTIFACTFILEPATH=test
+SNAPSHOT_REPOSITORYID=snapshots
+
 # REPOSITORIES
 # Manage Repositories
 MANAGED_IDENTIFIER=testing1

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java?rev=905996&r1=905995&r2=905996&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
Wed Feb  3 11:11:06 2010
@@ -128,4 +128,40 @@
         assertTextPresent( "internal" );
         assertTextPresent( "admin" );
     }
+    
+    @Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole"
}, enabled = false )
+    public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
+    {
+        String groupId = getProperty( "SNAPSHOT_GROUPID" );
+        String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
+        String version = getProperty( "SNAPSHOT_VERSION" );
+        String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
+        String packaging = getProperty( "SNAPSHOT_PACKAGING" );
+        
+        addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH"
), repo );        
+        assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
+            "' was successfully deployed to repository '" + repo + "'" );
+        
+        clickLinkWithText( "Logout" );
+                
+        login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRolePassword() );
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        
+        selectValue( "repository", "all" );
+        submit();
+        
+        assertAuditLogsReportPage();
+        assertTextPresent( "Results" );
+        assertTextNotPresent( "No audit logs found." );
+        assertTextPresent( "test-1.0.jar" );
+        assertTextPresent( "Uploaded File" );
+        assertTextPresent( "internal" );
+        assertTextPresent( "admin" );
+        
+        assertTextNotPresent( artifactId + "-" + version + "." + packaging );
+        
+        clickLinkWithText( "Logout" );
+        login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java?rev=905996&r1=905995&r2=905996&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
Wed Feb  3 11:11:06 2010
@@ -149,7 +149,7 @@
         }
 
         SimpleConstraint constraint = new MostRecentArchivaAuditLogsConstraint();
-        auditLogs = (List<ArchivaAuditLogs>) dao.query( constraint );
+        auditLogs = filterLogs( (List<ArchivaAuditLogs>) dao.query( constraint ) );
     }
 
     public String execute()
@@ -216,7 +216,8 @@
 
         try
         {
-            auditLogs = auditLogsDao.queryAuditLogs( constraint );            
+            auditLogs = filterLogs( auditLogsDao.queryAuditLogs( constraint ) );
+            
             if( auditLogs.isEmpty() )
             {
                 addActionError( "No audit logs found." );
@@ -244,6 +245,25 @@
         return SUCCESS;
     }
     
+    private List<ArchivaAuditLogs> filterLogs( List<ArchivaAuditLogs> auditLogs
)
+    {
+        List<String> observableRepos = getManageableRepositories();
+        List<ArchivaAuditLogs> filteredAuditLogs = new ArrayList<ArchivaAuditLogs>();
+        
+        if( auditLogs != null )
+        {
+            for( ArchivaAuditLogs auditLog : auditLogs )
+            {
+                if( observableRepos.contains( auditLog.getRepositoryId() ) )
+                {
+                    filteredAuditLogs.add( auditLog );
+                }
+            }
+        }
+        
+        return filteredAuditLogs;
+    }
+        
     private void paginate()
     {
         if ( auditLogs.size() <= rowCount )
@@ -270,6 +290,27 @@
         next = StringUtils.replace( next, " ", "%20" );
     }
 
+    private List<String> getManageableRepositories()
+    {
+        try
+        {
+            return userRepositories.getManagableRepositoryIds( getPrincipal() );
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+    
     private List<String> getObservableRepositories()
     {
         try



Mime
View raw message