Search in sources :

Example 1 with RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method testUpdateIdP.

@Test(dataProvider = "updateIdPData")
public void testUpdateIdP(Object oldIdp, Object newIdp, int tenantId) throws Exception {
    mockStatic(IdentityDatabaseUtil.class);
    mockStatic(IdentityUtil.class);
    try (Connection connection = getConnection(DB_NAME)) {
        when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection);
        when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection);
        when(IdentityUtil.getProperty(RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE)).thenReturn("false");
        when(IdentityDatabaseUtil.getDataSource()).thenReturn(dataSourceMap.get(DB_NAME));
        addTestIdps();
        idPManagementDAO.updateIdP((IdentityProvider) newIdp, ((IdentityProvider) oldIdp), tenantId);
        String newIdpName = ((IdentityProvider) newIdp).getIdentityProviderName();
        IdentityProvider idpResult = idPManagementDAO.getIdPByName(connection, newIdpName, tenantId, TENANT_DOMAIN);
        assertEquals(idpResult.getIdentityProviderName(), newIdpName);
    }
}
Also used : Connection(java.sql.Connection) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method testUpdateIdPException.

@Test(dataProvider = "updateIdPData")
public void testUpdateIdPException(Object oldIdp, Object newIdp, int tenantId) throws Exception {
    mockStatic(IdentityDatabaseUtil.class);
    mockStatic(IdentityUtil.class);
    try (Connection connection = getConnection(DB_NAME)) {
        when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection);
        when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection);
        when(IdentityUtil.getProperty(RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE)).thenReturn("false");
        assertThrows(IdentityProviderManagementException.class, () -> idPManagementDAO.updateIdP((IdentityProvider) newIdp, ((IdentityProvider) oldIdp), tenantId));
    }
}
Also used : Connection(java.sql.Connection) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Connection (java.sql.Connection)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Test (org.testng.annotations.Test)2 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)2