1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
23 import org.testng.annotations.Test;
25 @Test( groups = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
26 public class AuditLogsReportTest
27 extends AbstractArchivaTest
29 private void goToAuditLogReports()
31 clickLinkWithText( "Audit Log Report" );
34 private void assertAuditLogsReportPage()
36 assertPage( "Apache Archiva \\ Audit Log Report" );
37 assertTextPresent( "Audit Log Report" );
39 assertElementPresent( "repository" );
40 assertElementPresent( "groupId" );
41 assertElementPresent( "artifactId" );
42 assertElementPresent( "startDate" );
43 assertElementPresent( "endDate" );
44 assertElementPresent( "rowCount" );
45 assertButtonWithValuePresent( "View Audit Log" );
48 @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
49 public void testAuditLogsReport()
51 goToAuditLogReports();
52 assertAuditLogsReportPage();
53 assertTextPresent( "Latest Events" );
56 @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
57 public void testViewAuditLogsNoDataFound()
59 goToAuditLogReports();
60 assertAuditLogsReportPage();
62 setFieldValue( "groupId", "non.existing" );
65 assertPage( "Apache Archiva \\ Audit Log Report" );
66 assertTextPresent( "Results" );
67 assertTextPresent( "No audit logs found." );
70 // TODO: add test for adding via WebDAV
71 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
72 public void testViewAuditLogsDataFound()
74 goToAuditLogReports();
75 assertAuditLogsReportPage();
77 selectValue( "repository", "internal" );
78 setFieldValue( "groupId", "test" );
81 assertAuditLogsReportPage();
82 assertTextPresent( "Results" );
83 assertTextNotPresent( "No audit logs found." );
84 assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
85 assertTextPresent( "Uploaded File" );
86 assertTextPresent( "internal" );
87 assertTextPresent( "admin" );
90 // TODO: add test for adding via WebDAV
91 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
92 public void testViewAuditLogsOnlyArtifactIdIsSpecified()
94 goToAuditLogReports();
95 assertAuditLogsReportPage();
97 selectValue( "repository", "internal" );
98 setFieldValue( "artifactId", "test" );
101 assertAuditLogsReportPage();
102 assertTextPresent( "Results" );
103 assertTextNotPresent( "No audit logs found." );
104 assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
105 assertTextPresent( "Uploaded File" );
106 assertTextPresent( "internal" );
107 assertTextPresent( "admin" );
110 // TODO: add test for adding via WebDAV
111 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
112 public void testViewAuditLogsForAllRepositories()
114 goToAuditLogReports();
115 assertAuditLogsReportPage();
117 selectValue( "repository", "all" );
120 assertAuditLogsReportPage();
121 assertTextPresent( "Results" );
122 assertTextNotPresent( "No audit logs found." );
123 assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
124 assertTextPresent( "Uploaded File" );
125 assertTextPresent( "internal" );
126 assertTextPresent( "admin" );
129 @Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload")
130 public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
132 String groupId = getProperty( "SNAPSHOT_GROUPID" );
133 String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
134 String version = getProperty( "SNAPSHOT_VERSION" );
135 String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
136 String packaging = getProperty( "SNAPSHOT_PACKAGING" );
138 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
139 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
140 "' was successfully deployed to repository '" + repo + "'" );
142 clickLinkWithText( "Logout" );
144 login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
146 goToAuditLogReports();
147 assertAuditLogsReportPage();
149 selectValue( "repository", "all" );
152 assertAuditLogsReportPage();
153 assertTextPresent( "Results" );
154 assertTextNotPresent( "No audit logs found." );
155 assertTextPresent( "testAddArtifactValidValues-1.0.jar" );
156 assertTextPresent( "Uploaded File" );
157 assertTextPresent( "internal" );
158 assertTextPresent( "admin" );
160 assertTextNotPresent( artifactId + "-" + version + "." + packaging );
161 clickLinkWithText( "Logout" );
162 login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );