]> source.dussan.org Git - archiva.git/blob
3aa365896098dffffc3c2b28c0064ae80b42ed58
[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     private static final String EDIT_ROLES = "Roles";
31
32     public void testBasicAddDeleteUser()
33     {
34         username = getProperty( "GUEST_USERNAME" );
35         fullname = getProperty( "GUEST_FULLNAME" );
36
37         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
38         deleteUser( username, fullname, getUserEmail() );
39         logout();
40         login( getAdminUsername(), getAdminPassword() );
41     }
42
43     @Test( dependsOnMethods = {"testBasicAddDeleteUser"} )
44     public void testUserWithGuestRole()
45     {
46         username = getProperty( "GUEST_USERNAME" );
47         fullname = getProperty( "GUEST_FULLNAME" );
48
49         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
50         clickLinkWithText( username );
51         clickLinkWithText( EDIT_ROLES );
52         checkUserRoleWithValue( fullname );
53         clickButtonWithValue( "Submit" );
54
55         logout();
56         login( username, getUserRolePassword() );
57         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
58         assertTextPresent( "Password successfully changed" );
59         assertLeftNavMenuWithRole( fullname );
60         logout();
61         login( getAdminUsername(), getAdminPassword() );
62     }
63
64     @Test( dependsOnMethods = {"testUserWithGuestRole"} )
65     public void testUserWithRegisteredUserRole()
66     {
67         username = getProperty( "REGISTERED_USERNAME" );
68         fullname = getProperty( "REGISTERED_FULLNAME" );
69
70         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
71         clickLinkWithText( username );
72         clickLinkWithText( EDIT_ROLES );
73         checkUserRoleWithValue( fullname );
74         clickButtonWithValue( "Submit" );
75
76         logout();
77         login( username, getUserRolePassword() );
78         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
79         assertTextPresent( "Password successfully changed" );
80         assertLeftNavMenuWithRole( fullname );
81         logout();
82         login( getAdminUsername(), getAdminPassword() );
83     }
84
85     @Test( dependsOnMethods = {"testUserWithRegisteredUserRole"} )
86     public void testUserWithSysAdminUserRole()
87     {
88         username = getProperty( "SYSAD_USERNAME" );
89         fullname = getProperty( "SYSAD_FULLNAME" );
90
91         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
92         clickLinkWithText( username );
93         clickLinkWithText( EDIT_ROLES );
94         checkUserRoleWithValue( fullname );
95         clickButtonWithValue( "Submit" );
96
97         logout();
98         login( username, getUserRolePassword() );
99         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
100         assertTextPresent( "Password successfully changed" );
101         assertLeftNavMenuWithRole( fullname );
102         logout();
103         login( getAdminUsername(), getAdminPassword() );
104     }
105
106     @Test( dependsOnMethods = {"testUserWithSysAdminUserRole"} )
107     public void testUserWithUserAdminUserRole()
108     {
109         username = getProperty( "USERADMIN_USERNAME" );
110         fullname = getProperty( "USERADMIN_FULLNAME" );
111
112         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
113         clickLinkWithText( username );
114         clickLinkWithText( EDIT_ROLES );
115         checkUserRoleWithValue( fullname );
116         clickButtonWithValue( "Submit" );
117
118         logout();
119         login( username, getUserRolePassword() );
120         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
121         assertTextPresent( "Password successfully changed" );
122         assertLeftNavMenuWithRole( fullname );
123         logout();
124         login( getAdminUsername(), getAdminPassword() );
125     }
126
127     @Test( dependsOnMethods = {"testUserWithUserAdminUserRole"} )
128     public void testUserWithGlobalRepoManagerRole()
129     {
130         username = getProperty( "GLOBALREPOMANAGER_USERNAME" );
131         fullname = getProperty( "GLOBALREPOMANAGER_FULLNAME" );
132
133         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
134         clickLinkWithText( username );
135         clickLinkWithText( EDIT_ROLES );
136         checkUserRoleWithValue( fullname );
137         clickButtonWithValue( "Submit" );
138
139         logout();
140         login( username, getUserRolePassword() );
141         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
142         assertTextPresent( "Password successfully changed" );
143         assertLeftNavMenuWithRole( fullname );
144         logout();
145         login( getAdminUsername(), getAdminPassword() );
146     }
147
148     @Test( dependsOnMethods = {"testUserWithGlobalRepoManagerRole"} )
149     public void testUserWithGlobalRepoObserverRole()
150     {
151         username = getProperty( "GLOBALREPOOBSERVER_USERNAME" );
152         fullname = getProperty( "GLOBALREPOOBSERVER_FULLNAME" );
153
154         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
155         clickLinkWithText( username );
156         clickLinkWithText( EDIT_ROLES );
157         checkUserRoleWithValue( fullname );
158         clickButtonWithValue( "Submit" );
159
160         logout();
161         login( username, getUserRolePassword() );
162         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
163         assertTextPresent( "Password successfully changed" );
164         assertLeftNavMenuWithRole( fullname );
165         logout();
166         login( getAdminUsername(), getAdminPassword() );
167     }
168
169     @Test( dependsOnMethods = {"testUserWithGlobalRepoObserverRole"} )
170     public void testUserWithRepoManagerInternalRole()
171     {
172         username = getProperty( "REPOMANAGER_INTERNAL_USERNAME" );
173         fullname = getProperty( "REPOMANAGER_INTERNAL_FULLNAME" );
174
175         createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
176         clickLinkWithText( username );
177         clickLinkWithText( EDIT_ROLES );
178         checkResourceRoleWithValue( fullname );
179         clickButtonWithValue( "Submit" );
180
181         logout();
182         login( username, getUserRolePassword() );
183         changePassword( getUserRolePassword(), getUserRoleNewPassword() );
184         assertTextPresent( "Password successfully changed" );
185         assertLeftNavMenuWithRole( fullname );
186         logout();
187         login( getAdminUsername(), getAdminPassword() );
188     }
189
190     /*
191      * @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } ) public void
192      * testUserWithRepoManagerSnapshotsRole() { username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME"); fullname =
193      * getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME"); createUser(username, fullname, getUserEmail(),
194      * getUserRolePassword(), true); clickLinkWithText( username ); clickLinkWithText( "Edit Roles" );
195      * checkResourceRoleWithValue( fullname ); clickButtonWithValue( "Submit" ); clickLinkWithText("Logout");
196      * login(username, getUserRolePassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword()); // this
197      * section will be removed if issue from redback after changing password will be fixed. getSelenium().goBack();
198      * clickLinkWithText("Logout"); //assertTextPresent("You are already logged in."); login(username,
199      * getUserRoleNewPassword()); assertLeftNavMenuWithRole( fullname ); clickLinkWithText("Logout"); login(
200      * getAdminUsername() , getAdminPassword() ); }
201      */
202
203     @Test( dependsOnMethods = {"testUserWithRepoManagerInternalRole"} )
204     public void testUserWithRepoObserverInternalRole()
205     {
206         username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
207         fullname = getProperty( "REPOOBSERVER_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 = { "testUserWithRepoObserverInternalRole" } ) public void
232      * testUserWithRepoObserverSnapshotsRole() { username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" ); fullname =
233      * getProperty( "REPOOBSERVER_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 }