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", getProperty( "VALIDARTIFACT_GROUPID" ) );
81 assertAuditLogsReportPage();
82 assertTextPresent( "Results" );
83 assertTextNotPresent( "No audit logs found." );
84 assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
85 + getProperty( "ARTIFACT_PACKAGING" ) );
86 assertTextPresent( "Uploaded File" );
87 assertTextPresent( "internal" );
88 assertTextPresent( "admin" );
91 // TODO: add test for adding via WebDAV
92 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
93 public void testViewAuditLogsOnlyArtifactIdIsSpecified()
95 goToAuditLogReports();
96 assertAuditLogsReportPage();
98 selectValue( "repository", "internal" );
99 setFieldValue( "artifactId", getProperty( "AUDITLOGARTIFACT_ARTIFACTID" ) );
102 assertAuditLogsReportPage();
103 assertTextPresent( "If you specify an artifact ID, you must specify a group ID" );
104 assertTextNotPresent( "Results" );
105 assertTextNotPresent( "No audit logs found." );
106 assertTextNotPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
107 + getProperty( "ARTIFACT_PACKAGING" ) );
108 assertTextNotPresent( "Uploaded File" );
111 // TODO: add test for adding via WebDAV
112 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
113 public void testViewAuditLogsForAllRepositories()
115 goToAuditLogReports();
116 assertAuditLogsReportPage();
118 selectValue( "repository", "all" );
121 assertAuditLogsReportPage();
122 assertTextPresent( "Results" );
123 assertTextNotPresent( "No audit logs found." );
124 assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
125 + getProperty( "ARTIFACT_PACKAGING" ) );
126 assertTextPresent( "Uploaded File" );
127 assertTextPresent( "internal" );
128 assertTextPresent( "admin" );
131 @Test( dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload" )
132 public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
134 String groupId = getProperty( "SNAPSHOT_GROUPID" );
135 String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
136 String version = getProperty( "SNAPSHOT_VERSION" );
137 String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
138 String packaging = getProperty( "SNAPSHOT_PACKAGING" );
140 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
141 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version
142 + "' was successfully deployed to repository '" + repo + "'" );
144 clickLinkWithText( "Logout" );
146 login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
148 goToAuditLogReports();
149 assertAuditLogsReportPage();
151 selectValue( "repository", "all" );
154 assertAuditLogsReportPage();
155 assertTextPresent( "Results" );
156 assertTextNotPresent( "No audit logs found." );
157 assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
159 assertTextPresent( "Uploaded File" );
160 assertTextPresent( "internal" );
161 assertTextPresent( "admin" );
163 assertTextNotPresent( artifactId + "-" + version + "." + packaging );
164 clickLinkWithText( "Logout" );
165 login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
169 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
170 public void testViewAuditLogsReportForGroupId()
172 String groupId = getProperty( "AUDITLOGARTIFACT_GROUPID" );
173 String artifactId = getProperty( "AUDITLOGARTIFACT_ARTIFACTID" );
174 String version = getProperty( "VERSION" );
175 String packaging = getProperty( "PACKAGING" );
176 String repositoryId = getProperty( "REPOSITORYID" );
177 String expectedArtifact = getProperty( "AUDITLOG_EXPECTED_ARTIFACT" );
179 addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId );
181 goToAuditLogReports();
183 selectValue( "repository", repositoryId );
184 setFieldValue( "groupId", groupId );
187 assertAuditLogsReportPage();
188 assertTextPresent( expectedArtifact );
189 assertTextPresent( repositoryId );