Search in sources :

Example 1 with H2DataBaseManager

use of org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager in project jaggery by wso2.

the class ShellUtilityService method initializeUtilityServices.

/**
 * Initialize utility services for command line client
 * @throws SQLException
 */
protected static void initializeUtilityServices() throws SQLException {
    // H2 database
    final H2DatabaseManager databaseManager = H2DatabaseManager.getInstance();
    databaseManager.initialize();
}
Also used : H2DatabaseManager(org.wso2.carbon.h2.osgi.console.H2DatabaseManager)

Example 2 with H2DataBaseManager

use of org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager in project product-is by wso2.

the class OIDCPasswordGrantTest method addSecondaryUserStore.

private void addSecondaryUserStore() throws Exception {
    String jdbcClass = "org.wso2.carbon.user.core.jdbc.UniqueIDJDBCUserStoreManager";
    H2DataBaseManager dataBaseManager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);
    dataBaseManager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
    dataBaseManager.disconnect();
    PropertyDTO[] propertyDTOs = new PropertyDTO[10];
    for (int i = 0; i < 10; i++) {
        propertyDTOs[i] = new PropertyDTO();
    }
    propertyDTOs[0].setName("driverName");
    propertyDTOs[0].setValue("org.h2.Driver");
    propertyDTOs[1].setName("url");
    propertyDTOs[1].setValue("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME);
    propertyDTOs[2].setName("userName");
    propertyDTOs[2].setValue(DB_USER_NAME);
    propertyDTOs[3].setName("password");
    propertyDTOs[3].setValue(DB_USER_PASSWORD);
    propertyDTOs[4].setName("UserIDEnabled");
    propertyDTOs[4].setValue("true");
    UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(jdbcClass, USER_STORE_DOMAIN, propertyDTOs);
    userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
    Thread.sleep(5000);
    userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, USER_STORE_DOMAIN);
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)

Example 3 with H2DataBaseManager

use of org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager in project product-is by wso2.

the class UserStoreConfigUtils method getJDBCUserStoreProperties.

/**
 * Sets properties for the JDBC Userstore.
 *
 * @throws IOException            throws if an error occurs when setting JDBC userstore properties.
 * @throws SQLException           throws if an error occurs when perfomring a db action.
 * @throws ClassNotFoundException throws if it fails to find the relevant java class.
 * @deprecated This method uses a common user store database name. When multiple test cases reuse the same database,
 * there can be transient connection exceptions due to database not properly closed. Thus please use the utility
 * method {@link UserStoreConfigUtils#getJDBCUserStoreProperties(String)} with a test case specific user database
 * name instead.
 */
public PropertyDTO[] getJDBCUserStoreProperties() throws IOException, SQLException, ClassNotFoundException {
    propertyDTOs = new PropertyDTO[11];
    for (int i = 0; i < 11; i++) {
        propertyDTOs[i] = new PropertyDTO();
    }
    // creating database
    H2DataBaseManager dbmanager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + userStoreDBName, dbUserName, dbUserPassword);
    dbmanager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
    dbmanager.disconnect();
    propertyDTOs[0].setName("driverName");
    propertyDTOs[0].setValue("org.h2.Driver");
    propertyDTOs[1].setName("url");
    propertyDTOs[1].setValue("jdbc:h2:./repository/database/" + userStoreDBName);
    propertyDTOs[2].setName("userName");
    propertyDTOs[2].setValue(dbUserName);
    propertyDTOs[3].setName("password");
    propertyDTOs[3].setValue(dbUserPassword);
    propertyDTOs[4].setName("PasswordJavaRegEx");
    propertyDTOs[4].setValue("^[\\S]{5,30}$");
    propertyDTOs[5].setName("UsernameJavaRegEx");
    propertyDTOs[5].setValue("^[\\S]{5,30}$");
    propertyDTOs[6].setName("Disabled");
    propertyDTOs[6].setValue("false");
    propertyDTOs[7].setName("PasswordDigest");
    propertyDTOs[7].setValue("SHA-256");
    propertyDTOs[8].setName("StoreSaltedPassword");
    propertyDTOs[8].setValue("true");
    propertyDTOs[9].setName("SCIMEnabled");
    propertyDTOs[9].setValue("true");
    propertyDTOs[9].setName("CountRetrieverClass");
    propertyDTOs[9].setValue("org.wso2.carbon.identity.user.store.count.jdbc.JDBCUserStoreCountRetriever");
    propertyDTOs[10].setName("UserIDEnabled");
    propertyDTOs[10].setValue("true");
    return propertyDTOs;
}
Also used : H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)

Example 4 with H2DataBaseManager

use of org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager in project product-is by wso2.

the class UserStoreConfigUtils method getJDBCUserStoreProperties.

/**
 * Creates an H2 database and gets its properties.
 *
 * @param userStoreDBName The test case specific user database name.
 * @throws IOException            throws if an error occurs when setting JDBC userstore properties.
 * @throws SQLException           throws if an error occurs when perfomring a db action.
 * @throws ClassNotFoundException throws if it fails to find the relevant java class.
 */
public PropertyDTO[] getJDBCUserStoreProperties(final String userStoreDBName) throws IOException, SQLException, ClassNotFoundException {
    propertyDTOs = new PropertyDTO[11];
    for (int i = 0; i < 11; i++) {
        propertyDTOs[i] = new PropertyDTO();
    }
    // creating database
    H2DataBaseManager dbmanager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + userStoreDBName, dbUserName, dbUserPassword);
    dbmanager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
    dbmanager.disconnect();
    propertyDTOs[0].setName("driverName");
    propertyDTOs[0].setValue("org.h2.Driver");
    propertyDTOs[1].setName("url");
    propertyDTOs[1].setValue("jdbc:h2:./repository/database/" + userStoreDBName);
    propertyDTOs[2].setName("userName");
    propertyDTOs[2].setValue(dbUserName);
    propertyDTOs[3].setName("password");
    propertyDTOs[3].setValue(dbUserPassword);
    propertyDTOs[4].setName("PasswordJavaRegEx");
    propertyDTOs[4].setValue("^[\\S]{5,30}$");
    propertyDTOs[5].setName("UsernameJavaRegEx");
    propertyDTOs[5].setValue("^[\\S]{5,30}$");
    propertyDTOs[6].setName("Disabled");
    propertyDTOs[6].setValue("false");
    propertyDTOs[7].setName("PasswordDigest");
    propertyDTOs[7].setValue("SHA-256");
    propertyDTOs[8].setName("StoreSaltedPassword");
    propertyDTOs[8].setValue("true");
    propertyDTOs[9].setName("SCIMEnabled");
    propertyDTOs[9].setValue("true");
    propertyDTOs[9].setName("CountRetrieverClass");
    propertyDTOs[9].setValue("org.wso2.carbon.identity.user.store.count.jdbc.JDBCUserStoreCountRetriever");
    propertyDTOs[10].setName("UserIDEnabled");
    propertyDTOs[10].setValue("true");
    return propertyDTOs;
}
Also used : H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)

Example 5 with H2DataBaseManager

use of org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager in project product-is by wso2.

the class SCIM2GroupTest method populateSecondaryUserStoreProperties.

private PropertyDTO[] populateSecondaryUserStoreProperties() throws SQLException, ClassNotFoundException, IOException {
    H2DataBaseManager dataBaseManager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/JDBC_USER_STORE_DB", "wso2automation", "wso2automation");
    dataBaseManager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
    dataBaseManager.disconnect();
    PropertyDTO[] userStoreProperties = new PropertyDTO[11];
    IntStream.range(0, userStoreProperties.length).forEach(index -> userStoreProperties[index] = new PropertyDTO());
    userStoreProperties[0].setName("driverName");
    userStoreProperties[0].setValue("org.h2.Driver");
    userStoreProperties[1].setName("url");
    userStoreProperties[1].setValue("jdbc:h2:./repository/database/JDBC_USER_STORE_DB");
    userStoreProperties[2].setName("userName");
    userStoreProperties[2].setValue("wso2automation");
    userStoreProperties[3].setName("password");
    userStoreProperties[3].setValue("wso2automation");
    userStoreProperties[4].setName("PasswordJavaRegEx");
    userStoreProperties[4].setValue("^[\\S]{5,30}$");
    userStoreProperties[5].setName("UsernameJavaRegEx");
    userStoreProperties[5].setValue("^[\\S]{5,30}$");
    userStoreProperties[6].setName("Disabled");
    userStoreProperties[6].setValue("false");
    userStoreProperties[7].setName("PasswordDigest");
    userStoreProperties[7].setValue("SHA-256");
    userStoreProperties[8].setName("StoreSaltedPassword");
    userStoreProperties[8].setValue("true");
    userStoreProperties[9].setName("SCIMEnabled");
    userStoreProperties[9].setValue("true");
    userStoreProperties[9].setName("CountRetrieverClass");
    userStoreProperties[9].setValue("org.wso2.carbon.identity.user.store.count.jdbc.JDBCUserStoreCountRetriever");
    userStoreProperties[10].setName("UserIDEnabled");
    userStoreProperties[10].setValue("true");
    return userStoreProperties;
}
Also used : H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)

Aggregations

File (java.io.File)6 H2DataBaseManager (org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager)6 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)6 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO)3 H2DatabaseManager (org.wso2.carbon.h2.osgi.console.H2DatabaseManager)2