]> source.dussan.org Git - archiva.git/blob
a99c44325a4e41bca8d9f034c0e747d490f06800
[archiva.git] /
1 package org.apache.archiva.web.test;
2
3 /*
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
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
23 import org.testng.annotations.Test;
24
25 @Test( groups = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
26 public class AuditLogsReportTest
27     extends AbstractArchivaTest
28 {
29     private void goToAuditLogReports()
30     {
31         clickLinkWithText( "Audit Log Report" );
32     }
33
34     private void assertAuditLogsReportPage()
35     {
36         assertPage( "Apache Archiva \\ Audit Log Report" );
37         assertTextPresent( "Audit Log Report" );
38
39         assertElementPresent( "repository" );
40         assertElementPresent( "groupId" );
41         assertElementPresent( "artifactId" );
42         assertElementPresent( "startDate" );
43         assertElementPresent( "endDate" );
44         assertElementPresent( "rowCount" );
45         assertButtonWithValuePresent( "View Audit Log" );
46     }
47
48     @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" } )
49     public void testAuditLogsReport()
50     {
51         goToAuditLogReports();
52         assertAuditLogsReportPage();
53         assertTextPresent( "Latest Events" );
54     }
55
56     @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" } )
57     public void testViewAuditLogsNoDataFound()
58     {
59         goToAuditLogReports();
60         assertAuditLogsReportPage();
61
62         setFieldValue( "groupId", "non.existing" );
63         submit();
64
65         assertPage( "Apache Archiva \\ Audit Log Report" );
66         assertTextPresent( "Results" );
67         assertTextPresent( "No audit logs found." );
68     }
69
70     // TODO: add test for adding via WebDAV
71     @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
72     public void testViewAuditLogsDataFound()
73     {
74         goToAuditLogReports();
75         assertAuditLogsReportPage();
76
77         selectValue( "repository", "internal" );
78         setFieldValue( "groupId", getProperty( "VALIDARTIFACT_GROUPID" ) );
79         submit();
80
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" );
89     }
90
91     // TODO: add test for adding via WebDAV
92     @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
93     public void testViewAuditLogsOnlyArtifactIdIsSpecified()
94     {
95         goToAuditLogReports();
96         assertAuditLogsReportPage();
97
98         selectValue( "repository", "internal" );
99         setFieldValue( "artifactId", getProperty( "AUDITLOGARTIFACT_ARTIFACTID" ) );
100         submit();
101
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" );
109     }
110
111     // TODO: add test for adding via WebDAV
112     @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
113     public void testViewAuditLogsForAllRepositories()
114     {
115         goToAuditLogReports();
116         assertAuditLogsReportPage();
117
118         selectValue( "repository", "all" );
119         submit();
120
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" );
129     }
130
131     @Test( dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload" )
132     public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
133     {
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" );
139
140         addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
141         assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version
142             + "' was successfully deployed to repository '" + repo + "'" );
143
144         clickLinkWithText( "Logout" );
145
146         login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
147
148         goToAuditLogReports();
149         assertAuditLogsReportPage();
150
151         selectValue( "repository", "all" );
152         submit();
153
154         assertAuditLogsReportPage();
155         assertTextPresent( "Results" );
156         assertTextNotPresent( "No audit logs found." );
157         assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
158             + packaging );
159         assertTextPresent( "Uploaded File" );
160         assertTextPresent( "internal" );
161         assertTextPresent( "admin" );
162
163         assertTextNotPresent( artifactId + "-" + version + "." + packaging );
164         clickLinkWithText( "Logout" );
165         login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
166     }
167
168     // MRM-1304
169     @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
170     public void testViewAuditLogsReportForGroupId()
171     {
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" );
178
179         addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repositoryId );
180
181         goToAuditLogReports();
182
183         selectValue( "repository", repositoryId );
184         setFieldValue( "groupId", groupId );
185         submit();
186
187         assertAuditLogsReportPage();
188         assertTextPresent( expectedArtifact );
189         assertTextPresent( repositoryId );
190     }
191 }