]> source.dussan.org Git - archiva.git/blob
c7ca4735081b211522ea905f1ff5dfa77301be48
[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 = p.getProperty( "GUEST_USERNAME" );
33                 fullname = p.getProperty( "GUEST_FULLNAME" );
34                 
35                 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true);
36                 deleteUser( username, fullname, getUserEmail() );
37                 clickLinkWithText( "Logout" );
38                 login( getAdminUsername() , getAdminPassword() );
39         }
40         
41         @Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
42         public void testUserWithGuestRole()
43         {
44                 username = p.getProperty("GUEST_USERNAME");
45                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
60                 //assertTextPresent("You are already logged in.");
61                 
62                 login(username, getUserRoleNewPassword());
63                 assertLeftNavMenuWithRole( fullname );
64                 clickLinkWithText("Logout");
65                 login( getAdminUsername() , getAdminPassword() );
66         }
67         
68         @Test (dependsOnMethods = { "testUserWithGuestRole" } )
69         public void testUserWithRegisteredUserRole()
70         {
71                 username = p.getProperty("REGISTERED_USERNAME");
72                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
87                 //assertTextPresent("You are already logged in.");
88                 
89                 login(username, getUserRoleNewPassword());
90                 assertLeftNavMenuWithRole( fullname );
91                 clickLinkWithText("Logout");
92                 login( getAdminUsername() , getAdminPassword() );
93         }
94         
95         @Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
96         public void testUserWithSysAdminUserRole()
97         {
98                 username = p.getProperty("SYSAD_USERNAME");
99                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
114                 //assertTextPresent("You are already logged in.");
115                 
116                 login(username, getUserRoleNewPassword());
117                 assertLeftNavMenuWithRole( fullname );
118                 clickLinkWithText("Logout");
119                 login( getAdminUsername() , getAdminPassword() );
120         }
121         
122         @Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
123         public void testUserWithUserAdminUserRole()
124         {
125                 username = p.getProperty("USERADMIN_USERNAME");
126                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
141                 //assertTextPresent("You are already logged in.");
142                 
143                 login(username, getUserRoleNewPassword());
144                 assertLeftNavMenuWithRole( fullname );
145                 clickLinkWithText("Logout");
146                 login( getAdminUsername() , getAdminPassword() );
147         }
148         
149         @Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
150         public void testUserWithGlobalRepoManagerRole()
151         {
152                 username = p.getProperty("GLOBALREPOMANAGER_USERNAME");
153                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
168                 //assertTextPresent("You are already logged in.");
169                 
170                 login(username, getUserRoleNewPassword());
171                 assertLeftNavMenuWithRole( fullname );
172                 clickLinkWithText("Logout");
173                 login( getAdminUsername() , getAdminPassword() );
174         }
175
176         @Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
177         public void testUserWithGlobalRepoObserverRole()
178         {
179                 username = p.getProperty("GLOBALREPOOBSERVER_USERNAME");
180                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
195                 //assertTextPresent("You are already logged in.");
196                 
197                 login(username, getUserRoleNewPassword());
198                 assertLeftNavMenuWithRole( fullname );
199                 clickLinkWithText("Logout");
200                 login( getAdminUsername() , getAdminPassword() );
201         }
202         
203         @Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
204         public void testUserWithRepoManagerInternalRole()
205         {
206                 username = p.getProperty("REPOMANAGER_INTERNAL_USERNAME");
207                 fullname = p.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                 clickLinkWithText("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                 clickLinkWithText("Logout");
222                 //assertTextPresent("You are already logged in.");
223                 
224                 login(username, getUserRoleNewPassword());
225                 assertLeftNavMenuWithRole( fullname );
226                 clickLinkWithText("Logout");
227                 login( getAdminUsername() , getAdminPassword() );
228         }
229         
230         /*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
231         public void testUserWithRepoManagerSnapshotsRole()
232         {
233                 username = p.getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
234                 fullname = p.getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME");
235                 
236                 createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
237                 clickLinkWithText( username );
238                 clickLinkWithText( "Edit Roles" );
239                 checkResourceRoleWithValue( fullname );
240                 clickButtonWithValue( "Submit" );
241                 
242                 clickLinkWithText("Logout");
243                 login(username, getUserRolePassword());
244                 changePassword( getUserRolePassword(), getUserRoleNewPassword());
245                 
246                 // this section will be removed if issue from redback after changing password will be fixed.
247                 getSelenium().goBack();
248                 clickLinkWithText("Logout");
249                 //assertTextPresent("You are already logged in.");
250                 
251                 login(username, getUserRoleNewPassword());
252                 assertLeftNavMenuWithRole( fullname );
253                 clickLinkWithText("Logout");
254                 login( getAdminUsername() , getAdminPassword() );
255         }*/
256         
257         @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
258         public void testUserWithRepoObserverInternalRole()
259         {
260                 username = p.getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
261                 fullname = p.getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
262                 
263                 createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
264                 clickLinkWithText( username );
265                 clickLinkWithText( "Edit Roles" );
266                 checkResourceRoleWithValue( fullname );
267                 clickButtonWithValue( "Submit" );
268                 
269                 clickLinkWithText("Logout");
270                 login(username, getUserRolePassword());
271                 changePassword( getUserRolePassword(), getUserRoleNewPassword());
272                 
273                 // this section will be removed if issue from redback after changing password will be fixed.
274                 getSelenium().goBack();
275                 clickLinkWithText("Logout");
276                 //assertTextPresent("You are already logged in.");
277                 
278                 login(username, getUserRoleNewPassword());
279                 assertLeftNavMenuWithRole( fullname );
280                 clickLinkWithText("Logout");
281                 login( getAdminUsername() , getAdminPassword() );
282         }
283         
284         /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
285         public void testUserWithRepoObserverSnapshotsRole()
286         {
287                 username = p.getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
288                 fullname = p.getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
289                 
290                 createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
291                 clickLinkWithText( username );
292                 clickLinkWithText( "Edit Roles" );
293                 checkResourceRoleWithValue( fullname );
294                 clickButtonWithValue( "Submit" );
295                 
296                 clickLinkWithText("Logout");
297                 login(username, getUserRolePassword());
298                 changePassword( getUserRolePassword(), getUserRoleNewPassword());
299                 
300                 // this section will be removed if issue from redback after changing password will be fixed.
301                 getSelenium().goBack();
302                 clickLinkWithText("Logout");
303                 //assertTextPresent("You are already logged in.");
304                 
305                 login(username, getUserRoleNewPassword());
306                 assertLeftNavMenuWithRole( fullname );
307                 clickLinkWithText("Logout");
308                 login( getAdminUsername() , getAdminPassword() );
309         }*/
310 }