package org.apache.maven.archiva.web.test;
/*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-import com.thoughtworks.selenium.Selenium;
import org.apache.maven.shared.web.test.AbstractSeleniumTestCase;
-import java.util.Calendar;
-
/**
* @author Edwin Punzalan
*/
{
private String baseUrl = "http://localhost:9595/archiva";
- public static final String CREATE_ADMIN_USER_PAGE_TITLE = "Maven Archiva :: Create Admin User";
-
protected String getApplicationName()
{
return "Archiva";
return "2005";
}
+ protected void postAdminUserCreation()
+ {
+ if ( getTitle().equals( getTitlePrefix() + "Configuration" ) )
+ {
+ //Add Managed Repository
+ setFieldValue( "id", "web-ui" );
+ setFieldValue( "urlName", "web-ui" );
+ setFieldValue( "name", "Web UI Test Managed Repository" );
+ setFieldValue( "directory", getBasedir() + "target/web-ui-dir" );
+ clickButtonWithValue( "AddRepository" );
+
+ //Set Index location
+ assertPage( "Configuration" );
+ setFieldValue( "indexPath", getBasedir() + "target/web-ui-index" );
+ clickButtonWithValue( "Save Configuration" );
+ assertPage( "Administration" );
+ }
+ }
+
public void assertHeader()
{
assertTrue( "banner is missing" , getSelenium().isElementPresent( "xpath=//div[@id='banner']" ) );
"/span[@id='bannerLeft']/a[@href='http://maven.apache.org/archiva/']" ) );
assertTrue( "bannerLeft img is missing" , getSelenium().isElementPresent( "xpath=//div[@id='banner']" +
"/span[@id='bannerLeft']/a[@href='http://maven.apache.org/archiva/']" +
- "/img[@src='http://maven.apache.org/images/maven.jpg']" ) );
+ "/img[@src='" + getWebContext() + "/images/archiva.png']" ) );
assertTrue( "bannerRight is missing", getSelenium().isElementPresent( "xpath=//div[@id='banner']/span[@id='bannerRight']" ) );
}
+ protected String getTitlePrefix()
+ {
+ return "Maven Archiva :: ";
+ }
+
public String getBaseUrl()
{
return baseUrl;
}
+
+ protected String getWebContext()
+ {
+ return "/archiva";
+ }
}
package org.apache.maven.archiva.web.test;
/*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-import com.thoughtworks.selenium.Selenium;
-
/**
* @author Edwin Punzalan
*/
{
goToLoginPage();
submitLoginPage( "badUsername", "badPassword", false );
- assertTextPresent( "Authentication failed" );
+ assertTextPresent( "You have entered an incorrect username and/or password" );
}
public void testUserLogin()
{
- createUser( "user", "user01" );
+ createUser( "test-user", "temp-pass" );
+
goToLoginPage();
- submitLoginPage( "user", "user01" );
+ submitLoginPage( "test-user", "temp-pass" );
+
+ if ( getTitle().equals( getTitlePrefix() + "Change Password" ) )
+ {
+ setFieldValue( "existingPassword", "temp-pass" );
+ setFieldValue( "newPassword", "p4ssw0rd" );
+ setFieldValue( "newPasswordConfirm", "p4ssw0rd" );
+ clickButtonWithValue( "Change Password" );
+ }
+
+ logout();
+
+ deleteUser( "test-user" );
}
private void createUser( String username, String password )
{
- Selenium sel = getSelenium();
-
goToLoginPage();
submitLoginPage( adminUsername, adminPassword );
- sel.open( "/archiva/security/userlist.action" );
- assertPage( "Maven Archiva :: [Admin] User List" );
- assertTextNotPresent( username );
- sel.open( "/archiva/security/usercreate!show.action" );
- assertPage( "Maven Archiva :: [Admin] User Create" );
- sel.type( "user.username", username );
- sel.type( "user.fullName", username + " FullName" );
- sel.type( "user.email", username + "@localhost.com" );
- sel.type( "user.password", password );
- sel.type( "user.confirmPassword", password );
- sel.click( "//input[@type='submit' and @value='Create User']" );
+ clickLinkWithText( "User Management" );
+ assertPage( "[Admin] User List" );
+ assertLinkNotPresent( username );
+ clickButtonWithValue( "Create New User" );
+
+ assertPage( "[Admin] User Create" );
+ setFieldValue( "user.username", username );
+ setFieldValue( "user.fullName", username + " FullName" );
+ setFieldValue( "user.email", username + "@localhost.com" );
+ setFieldValue( "user.password", password );
+ setFieldValue( "user.confirmPassword", password );
+ clickButtonWithValue( "Create User" );
waitPage();
- assertPage( "Maven Archiva :: [Admin] User List" );
- assertTextPresent( username );
+ assertPage( "[Admin] User List" );
+ assertLinkPresent( username );
+
+ logout();
+ }
+
+ private void deleteUser( String username )
+ {
+ goToLoginPage();
+ submitLoginPage( adminUsername, adminPassword );
+
+ clickLinkWithText( "User Management" );
+ assertPage( "[Admin] User List" );
+
+ try
+ {
+ Thread.sleep( 15000 );
+ }
+ catch ( InterruptedException e )
+ {
+ e.printStackTrace();
+ }
+
+ assertLinkPresent( username );
+ clickLinkWithXPath( "//a[@href='/security/userdelete.action?username=" + username + "']" );
+ assertPage( "[Admin] User Delete" );
+ assertTextPresent( "The following user will be deleted: " + username );
+ clickButtonWithValue( "Delete User" );
+ assertPage( "[Admin] User List" );
+
+ logout();
}
}