1 package org.apache.archiva.web.test;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
23 import org.testng.annotations.Test;
25 @Test( groups = {"userroles"}, dependsOnMethods = {"testWithCorrectUsernamePassword"} )
26 public class UserRolesTest
27 extends AbstractArchivaTest
30 private static final String EDIT_ROLES = "Roles";
32 public void testBasicAddDeleteUser()
34 username = getProperty( "GUEST_USERNAME" );
35 fullname = getProperty( "GUEST_FULLNAME" );
37 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
38 deleteUser( username, fullname, getUserEmail() );
40 login( getAdminUsername(), getAdminPassword() );
43 @Test( dependsOnMethods = {"testBasicAddDeleteUser"} )
44 public void testUserWithGuestRole()
46 username = getProperty( "GUEST_USERNAME" );
47 fullname = getProperty( "GUEST_FULLNAME" );
49 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
50 clickLinkWithText( username );
51 clickLinkWithText( EDIT_ROLES );
52 checkUserRoleWithValue( fullname );
53 clickButtonWithValue( "Submit" );
56 login( username, getUserRolePassword() );
57 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
58 assertTextPresent( "Password successfully changed" );
59 assertLeftNavMenuWithRole( fullname );
61 login( getAdminUsername(), getAdminPassword() );
64 @Test( dependsOnMethods = {"testUserWithGuestRole"} )
65 public void testUserWithRegisteredUserRole()
67 username = getProperty( "REGISTERED_USERNAME" );
68 fullname = getProperty( "REGISTERED_FULLNAME" );
70 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
71 clickLinkWithText( username );
72 clickLinkWithText( EDIT_ROLES );
73 checkUserRoleWithValue( fullname );
74 clickButtonWithValue( "Submit" );
77 login( username, getUserRolePassword() );
78 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
79 assertTextPresent( "Password successfully changed" );
80 assertLeftNavMenuWithRole( fullname );
82 login( getAdminUsername(), getAdminPassword() );
85 @Test( dependsOnMethods = {"testUserWithRegisteredUserRole"} )
86 public void testUserWithSysAdminUserRole()
88 username = getProperty( "SYSAD_USERNAME" );
89 fullname = getProperty( "SYSAD_FULLNAME" );
91 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
92 clickLinkWithText( username );
93 clickLinkWithText( EDIT_ROLES );
94 checkUserRoleWithValue( fullname );
95 clickButtonWithValue( "Submit" );
98 login( username, getUserRolePassword() );
99 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
100 assertTextPresent( "Password successfully changed" );
101 assertLeftNavMenuWithRole( fullname );
103 login( getAdminUsername(), getAdminPassword() );
106 @Test( dependsOnMethods = {"testUserWithSysAdminUserRole"} )
107 public void testUserWithUserAdminUserRole()
109 username = getProperty( "USERADMIN_USERNAME" );
110 fullname = getProperty( "USERADMIN_FULLNAME" );
112 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
113 clickLinkWithText( username );
114 clickLinkWithText( EDIT_ROLES );
115 checkUserRoleWithValue( fullname );
116 clickButtonWithValue( "Submit" );
119 login( username, getUserRolePassword() );
120 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
121 assertTextPresent( "Password successfully changed" );
122 assertLeftNavMenuWithRole( fullname );
124 login( getAdminUsername(), getAdminPassword() );
127 @Test( dependsOnMethods = {"testUserWithUserAdminUserRole"} )
128 public void testUserWithGlobalRepoManagerRole()
130 username = getProperty( "GLOBALREPOMANAGER_USERNAME" );
131 fullname = getProperty( "GLOBALREPOMANAGER_FULLNAME" );
133 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
134 clickLinkWithText( username );
135 clickLinkWithText( EDIT_ROLES );
136 checkUserRoleWithValue( fullname );
137 clickButtonWithValue( "Submit" );
140 login( username, getUserRolePassword() );
141 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
142 assertTextPresent( "Password successfully changed" );
143 assertLeftNavMenuWithRole( fullname );
145 login( getAdminUsername(), getAdminPassword() );
148 @Test( dependsOnMethods = {"testUserWithGlobalRepoManagerRole"} )
149 public void testUserWithGlobalRepoObserverRole()
151 username = getProperty( "GLOBALREPOOBSERVER_USERNAME" );
152 fullname = getProperty( "GLOBALREPOOBSERVER_FULLNAME" );
154 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
155 clickLinkWithText( username );
156 clickLinkWithText( EDIT_ROLES );
157 checkUserRoleWithValue( fullname );
158 clickButtonWithValue( "Submit" );
161 login( username, getUserRolePassword() );
162 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
163 assertTextPresent( "Password successfully changed" );
164 assertLeftNavMenuWithRole( fullname );
166 login( getAdminUsername(), getAdminPassword() );
169 @Test( dependsOnMethods = {"testUserWithGlobalRepoObserverRole"} )
170 public void testUserWithRepoManagerInternalRole()
172 username = getProperty( "REPOMANAGER_INTERNAL_USERNAME" );
173 fullname = getProperty( "REPOMANAGER_INTERNAL_FULLNAME" );
175 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
176 clickLinkWithText( username );
177 clickLinkWithText( EDIT_ROLES );
178 checkResourceRoleWithValue( fullname );
179 clickButtonWithValue( "Submit" );
182 login( username, getUserRolePassword() );
183 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
184 assertTextPresent( "Password successfully changed" );
185 assertLeftNavMenuWithRole( fullname );
187 login( getAdminUsername(), getAdminPassword() );
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() ); }
203 @Test( dependsOnMethods = {"testUserWithRepoManagerInternalRole"} )
204 public void testUserWithRepoObserverInternalRole()
206 username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
207 fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
209 createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
210 clickLinkWithText( username );
211 clickLinkWithText( EDIT_ROLES );
212 checkResourceRoleWithValue( fullname );
213 clickButtonWithValue( "Submit" );
216 login( username, getUserRolePassword() );
217 changePassword( getUserRolePassword(), getUserRoleNewPassword() );
219 // this section will be removed if issue from redback after changing password will be fixed.
220 getSelenium().goBack();
222 // assertTextPresent("You are already logged in.");
224 login( username, getUserRoleNewPassword() );
225 assertLeftNavMenuWithRole( fullname );
227 login( getAdminUsername(), getAdminPassword() );
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() ); }