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 getSelenium().open( "/archiva/report/queryAuditLogReport.action" );
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", getProperty( "VALIDARTIFACT_GROUPID" ) );
81 assertAuditLogsReportPage();
82 assertTextPresent( "Results" );
83 assertTextNotPresent( "No audit logs found." );
85 getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "." + getProperty(
86 "ARTIFACT_PACKAGING" ) );
87 assertTextPresent( "Uploaded File" );
88 assertTextPresent( "internal" );
89 assertTextPresent( "admin" );
92 // TODO: add test for adding via WebDAV
93 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
94 public void testViewAuditLogsOnlyArtifactIdIsSpecified()
96 goToAuditLogReports();
97 assertAuditLogsReportPage();
99 selectValue( "repository", "internal" );
100 setFieldValue( "artifactId", getProperty( "AUDITLOGARTIFACT_ARTIFACTID" ) );
103 assertAuditLogsReportPage();
104 assertTextPresent( "If you specify an artifact ID, you must specify a group ID" );
105 assertTextNotPresent( "Results" );
106 assertTextNotPresent( "No audit logs found." );
107 assertTextNotPresent(
108 getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "." + getProperty(
109 "ARTIFACT_PACKAGING" ) );
110 assertTextNotPresent( "Uploaded File" );
113 // TODO: add test for adding via WebDAV
114 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
115 public void testViewAuditLogsForAllRepositories()
117 goToAuditLogReports();
118 assertAuditLogsReportPage();
120 selectValue( "repository", "all" );
123 assertAuditLogsReportPage();
124 assertTextPresent( "Results" );
125 assertTextNotPresent( "No audit logs found." );
127 getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "." + getProperty(
128 "ARTIFACT_PACKAGING" ) );
129 assertTextPresent( "Uploaded File" );
130 assertTextPresent( "internal" );
131 assertTextPresent( "admin" );
134 @Test( dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" },
135 groups = "requiresUpload" )
136 public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
138 String groupId = getProperty( "SNAPSHOT_GROUPID" );
139 String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
140 String version = getProperty( "SNAPSHOT_VERSION" );
141 String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
142 String packaging = getProperty( "SNAPSHOT_PACKAGING" );
144 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo, true );
146 "Artifact '" + groupId + ":" + artifactId + ":" + version + "' was successfully deployed to repository '"
149 clickLinkWithText( "Logout" );
151 login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
153 goToAuditLogReports();
154 assertAuditLogsReportPage();
156 selectValue( "repository", "all" );
159 assertAuditLogsReportPage();
160 assertTextPresent( "Results" );
161 assertTextNotPresent( "No audit logs found." );
163 getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "." + packaging );
164 assertTextPresent( "Uploaded File" );
165 assertTextPresent( "internal" );
166 assertTextPresent( "admin" );
168 assertTextNotPresent( artifactId + "-" + version + "." + packaging );
169 clickLinkWithText( "Logout" );
170 login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
174 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
175 public void testViewAuditLogsReportForGroupId()
177 String groupId = getProperty( "AUDITLOGARTIFACT_GROUPID" );
178 String artifactId = getProperty( "AUDITLOGARTIFACT_ARTIFACTID" );
179 String version = getProperty( "VERSION" );
180 String packaging = getProperty( "PACKAGING" );
181 String repositoryId = getProperty( "REPOSITORYID" );
182 String expectedArtifact = getProperty( "AUDITLOG_EXPECTED_ARTIFACT" );
184 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId,
187 goToAuditLogReports();
189 selectValue( "repository", repositoryId );
190 setFieldValue( "groupId", groupId );
193 assertAuditLogsReportPage();
194 assertTextPresent( expectedArtifact );
195 assertTextPresent( repositoryId );