]> source.dussan.org Git - archiva.git/blob
bc44b8413912b53437f99da1841534c97d600399
[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 = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
26 public class UserRolesTest
27     extends AbstractArchivaTest
28 {
29
30     public void testBasicAddDeleteUser()
31     {
32         username = getProperty( "GUEST_USERNAME" );
33         fullname = getProperty( "GUEST_FULLNAME" );
34
35         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
36         deleteUser( username, fullname, getUserEmail() );
37         logout();
38         login( getAdminUsername(), getAdminPassword() );
39     }
40
41     @Test( dependsOnMethods = { "testBasicAddDeleteUser" } )
42     public void testUserWithGuestRole()
43     {
44         username = getProperty( "GUEST_USERNAME" );
45         fullname = getProperty( "GUEST_FULLNAME" );
46
47         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
48         clickLinkWithText( username );
49         clickLinkWithText( "Edit Roles" );
50         checkUserRoleWithValue( fullname );
51         clickButtonWithValue( "Submit" );
52
53         logout();
54         login( username, getUserRolePassword() );
55         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
56
57         // this section will be removed if issue from redback after changing password will be fixed.
58         getSelenium().goBack();
59         logout();
60         // assertTextPresent("You are already logged in.");
61
62         login( username, getUserRoleNewPassword() );
63         assertLeftNavMenuWithRole( fullname );
64         logout();
65         login( getAdminUsername(), getAdminPassword() );
66     }
67
68     @Test( dependsOnMethods = { "testUserWithGuestRole" } )
69     public void testUserWithRegisteredUserRole()
70     {
71         username = getProperty( "REGISTERED_USERNAME" );
72         fullname = getProperty( "REGISTERED_FULLNAME" );
73
74         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
75         clickLinkWithText( username );
76         clickLinkWithText( "Edit Roles" );
77         checkUserRoleWithValue( fullname );
78         clickButtonWithValue( "Submit" );
79
80         logout();
81         login( username, getUserRolePassword() );
82         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
83
84         // this section will be removed if issue from redback after changing password will be fixed.
85         getSelenium().goBack();
86         logout();
87         // assertTextPresent("You are already logged in.");
88
89         login( username, getUserRoleNewPassword() );
90         assertLeftNavMenuWithRole( fullname );
91         logout();
92         login( getAdminUsername(), getAdminPassword() );
93     }
94
95     @Test( dependsOnMethods = { "testUserWithRegisteredUserRole" } )
96     public void testUserWithSysAdminUserRole()
97     {
98         username = getProperty( "SYSAD_USERNAME" );
99         fullname = getProperty( "SYSAD_FULLNAME" );
100
101         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
102         clickLinkWithText( username );
103         clickLinkWithText( "Edit Roles" );
104         checkUserRoleWithValue( fullname );
105         clickButtonWithValue( "Submit" );
106
107         logout();
108         login( username, getUserRolePassword() );
109         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
110
111         // this section will be removed if issue from redback after changing password will be fixed.
112         getSelenium().goBack();
113         logout();
114         // assertTextPresent("You are already logged in.");
115
116         login( username, getUserRoleNewPassword() );
117         assertLeftNavMenuWithRole( fullname );
118         logout();
119         login( getAdminUsername(), getAdminPassword() );
120     }
121
122     @Test( dependsOnMethods = { "testUserWithSysAdminUserRole" } )
123     public void testUserWithUserAdminUserRole()
124     {
125         username = getProperty( "USERADMIN_USERNAME" );
126         fullname = getProperty( "USERADMIN_FULLNAME" );
127
128         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
129         clickLinkWithText( username );
130         clickLinkWithText( "Edit Roles" );
131         checkUserRoleWithValue( fullname );
132         clickButtonWithValue( "Submit" );
133
134         logout();
135         login( username, getUserRolePassword() );
136         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
137
138         // this section will be removed if issue from redback after changing password will be fixed.
139         getSelenium().goBack();
140         logout();
141         // assertTextPresent("You are already logged in.");
142
143         login( username, getUserRoleNewPassword() );
144         assertLeftNavMenuWithRole( fullname );
145         logout();
146         login( getAdminUsername(), getAdminPassword() );
147     }
148
149     @Test( dependsOnMethods = { "testUserWithUserAdminUserRole" } )
150     public void testUserWithGlobalRepoManagerRole()
151     {
152         username = getProperty( "GLOBALREPOMANAGER_USERNAME" );
153         fullname = getProperty( "GLOBALREPOMANAGER_FULLNAME" );
154
155         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
156         clickLinkWithText( username );
157         clickLinkWithText( "Edit Roles" );
158         checkUserRoleWithValue( fullname );
159         clickButtonWithValue( "Submit" );
160
161         logout();
162         login( username, getUserRolePassword() );
163         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
164
165         // this section will be removed if issue from redback after changing password will be fixed.
166         getSelenium().goBack();
167         logout();
168         // assertTextPresent("You are already logged in.");
169
170         login( username, getUserRoleNewPassword() );
171         assertLeftNavMenuWithRole( fullname );
172         logout();
173         login( getAdminUsername(), getAdminPassword() );
174     }
175
176     @Test( dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
177     public void testUserWithGlobalRepoObserverRole()
178     {
179         username = getProperty( "GLOBALREPOOBSERVER_USERNAME" );
180         fullname = getProperty( "GLOBALREPOOBSERVER_FULLNAME" );
181
182         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
183         clickLinkWithText( username );
184         clickLinkWithText( "Edit Roles" );
185         checkUserRoleWithValue( fullname );
186         clickButtonWithValue( "Submit" );
187
188         logout();
189         login( username, getUserRolePassword() );
190         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
191
192         // this section will be removed if issue from redback after changing password will be fixed.
193         getSelenium().goBack();
194         logout();
195         // assertTextPresent("You are already logged in.");
196
197         login( username, getUserRoleNewPassword() );
198         assertLeftNavMenuWithRole( fullname );
199         logout();
200         login( getAdminUsername(), getAdminPassword() );
201     }
202
203     @Test( dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
204     public void testUserWithRepoManagerInternalRole()
205     {
206         username = getProperty( "REPOMANAGER_INTERNAL_USERNAME" );
207         fullname = getProperty( "REPOMANAGER_INTERNAL_FULLNAME" );
208
209         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
210         clickLinkWithText( username );
211         clickLinkWithText( "Edit Roles" );
212         checkResourceRoleWithValue( fullname );
213         clickButtonWithValue( "Submit" );
214
215         logout();
216         login( username, getUserRolePassword() );
217         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
218
219         // this section will be removed if issue from redback after changing password will be fixed.
220         getSelenium().goBack();
221         logout();
222         // assertTextPresent("You are already logged in.");
223
224         login( username, getUserRoleNewPassword() );
225         assertLeftNavMenuWithRole( fullname );
226         logout();
227         login( getAdminUsername(), getAdminPassword() );
228     }
229
230     /*
231      * @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } ) public void
232      * testUserWithRepoManagerSnapshotsRole() { username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME"); fullname =
233      * getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME"); createUser(username, fullname, getUserEmail(),
234      * getUserRolePassword(), true); clickLinkWithText( username ); clickLinkWithText( "Edit Roles" );
235      * checkResourceRoleWithValue( fullname ); clickButtonWithValue( "Submit" ); clickLinkWithText("Logout");
236      * login(username, getUserRolePassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword()); // this
237      * section will be removed if issue from redback after changing password will be fixed. getSelenium().goBack();
238      * clickLinkWithText("Logout"); //assertTextPresent("You are already logged in."); login(username,
239      * getUserRoleNewPassword()); assertLeftNavMenuWithRole( fullname ); clickLinkWithText("Logout"); login(
240      * getAdminUsername() , getAdminPassword() ); }
241      */
242
243     @Test( dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
244     public void testUserWithRepoObserverInternalRole()
245     {
246         username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
247         fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
248
249         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
250         clickLinkWithText( username );
251         clickLinkWithText( "Edit Roles" );
252         checkResourceRoleWithValue( fullname );
253         clickButtonWithValue( "Submit" );
254
255         logout();
256         login( username, getUserRolePassword() );
257         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
258
259         // this section will be removed if issue from redback after changing password will be fixed.
260         getSelenium().goBack();
261         logout();
262         // assertTextPresent("You are already logged in.");
263
264         login( username, getUserRoleNewPassword() );
265         assertLeftNavMenuWithRole( fullname );
266         logout();
267         login( getAdminUsername(), getAdminPassword() );
268     }
269
270     /*
271      * @Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } ) public void
272      * testUserWithRepoObserverSnapshotsRole() { username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" ); fullname =
273      * getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" ); createUser(username, fullname, getUserEmail(),
274      * getUserRolePassword(), true); clickLinkWithText( username ); clickLinkWithText( "Edit Roles" );
275      * checkResourceRoleWithValue( fullname ); clickButtonWithValue( "Submit" ); clickLinkWithText("Logout");
276      * login(username, getUserRolePassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword()); // this
277      * section will be removed if issue from redback after changing password will be fixed. getSelenium().goBack();
278      * clickLinkWithText("Logout"); //assertTextPresent("You are already logged in."); login(username,
279      * getUserRoleNewPassword()); assertLeftNavMenuWithRole( fullname ); clickLinkWithText("Logout"); login(
280      * getAdminUsername() , getAdminPassword() ); }
281      */
282 }