]> source.dussan.org Git - archiva.git/blob
1f984fbc7a6843b27121d872c9d4371d7f0267e2
[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         /*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
231         public void testUserWithRepoManagerSnapshotsRole()
232         {
233                 username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
234                 fullname = 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 = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
261                 fullname = 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         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         logout();
276         //assertTextPresent("You are already logged in.");
277                 
278                 login(username, getUserRoleNewPassword());
279                 assertLeftNavMenuWithRole( fullname );
280         logout();
281         login( getAdminUsername() , getAdminPassword() );
282         }
283
284     /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
285      public void testUserWithRepoObserverSnapshotsRole()
286      {
287          username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
288          fullname = 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 }