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 // TODO: disable if not running on *chrome
72 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
73 public void testViewAuditLogsDataFound()
75 goToAuditLogReports();
76 assertAuditLogsReportPage();
78 selectValue( "repository", "internal" );
79 setFieldValue( "groupId", "test" );
82 assertAuditLogsReportPage();
83 assertTextPresent( "Results" );
84 assertTextNotPresent( "No audit logs found." );
85 assertTextPresent( "test-1.0.jar" );
86 assertTextPresent( "Uploaded File" );
87 assertTextPresent( "internal" );
88 assertTextPresent( "admin" );
91 // TODO: add test for adding via WebDAV
92 // TODO: disable if not running on *chrome
93 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
94 public void testViewAuditLogsOnlyArtifactIdIsSpecified()
96 goToAuditLogReports();
97 assertAuditLogsReportPage();
99 selectValue( "repository", "internal" );
100 setFieldValue( "artifactId", "test" );
103 assertAuditLogsReportPage();
104 assertTextPresent( "Results" );
105 assertTextNotPresent( "No audit logs found." );
106 assertTextPresent( "test-1.0.jar" );
107 assertTextPresent( "Uploaded File" );
108 assertTextPresent( "internal" );
109 assertTextPresent( "admin" );
112 // TODO: add test for adding via WebDAV
113 // TODO: disable if not running on *chrome
114 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
115 public void testViewAuditLogsForAllRepositories()
117 goToAuditLogReports();
118 assertAuditLogsReportPage();
120 selectValue( "repository", "all" );
123 assertAuditLogsReportPage();
124 assertTextPresent( "Results" );
125 assertTextNotPresent( "No audit logs found." );
126 assertTextPresent( "test-1.0.jar" );
127 assertTextPresent( "Uploaded File" );
128 assertTextPresent( "internal" );
129 assertTextPresent( "admin" );
132 @Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, enabled = false )
133 public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
135 String groupId = getProperty( "SNAPSHOT_GROUPID" );
136 String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
137 String version = getProperty( "SNAPSHOT_VERSION" );
138 String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
139 String packaging = getProperty( "SNAPSHOT_PACKAGING" );
141 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
142 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
143 "' was successfully deployed to repository '" + repo + "'" );
145 clickLinkWithText( "Logout" );
147 login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRolePassword() );
148 goToAuditLogReports();
149 assertAuditLogsReportPage();
151 selectValue( "repository", "all" );
154 assertAuditLogsReportPage();
155 assertTextPresent( "Results" );
156 assertTextNotPresent( "No audit logs found." );
157 assertTextPresent( "test-1.0.jar" );
158 assertTextPresent( "Uploaded File" );
159 assertTextPresent( "internal" );
160 assertTextPresent( "admin" );
162 assertTextNotPresent( artifactId + "-" + version + "." + packaging );
164 clickLinkWithText( "Logout" );
165 login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
168 @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload")
169 public void testViewAuditLogsReportForGroupId()
171 String groupId = getProperty("AUDITLOG_GROUPID");
172 String artifactId = getProperty("ARTIFACTID");
173 String version = getProperty("VERSION");
174 String packaging = getProperty("PACKAGING");
175 String repositoryId = getProperty("REPOSITORYID");
176 String expectedArtifact = getProperty("AUDITLOG_EXPECTED_ARTIFACT");
178 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId );
180 goToAuditLogReports();
182 selectValue( "repository", repositoryId );
183 setFieldValue( "groupId", groupId );
186 assertAuditLogsReportPage();
187 assertTextPresent( expectedArtifact );
188 assertTextPresent( repositoryId );