Skip to content

Commit

Permalink
Improve unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Sep 26, 2024
1 parent d4a99a1 commit c9166db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponentHolder;
import org.wso2.carbon.identity.application.mgt.provider.ApplicationPermissionProvider;
import org.wso2.carbon.identity.application.mgt.provider.RegistryBasedApplicationPermissionProvider;
import org.wso2.carbon.identity.base.IdentityConstants;
import org.wso2.carbon.identity.common.testng.WithH2Database;
import org.wso2.carbon.identity.common.testng.realm.InMemoryRealmService;
import org.wso2.carbon.identity.common.testng.realm.MockUserStoreManager;
Expand Down Expand Up @@ -810,6 +811,10 @@ public void testGetAllLocalAuthenticators() throws IdentityApplicationManagement
LocalAuthenticatorConfig[] localAuthenticatorConfigs = applicationManagementService.getAllLocalAuthenticators
(SUPER_TENANT_DOMAIN_NAME);

for (LocalAuthenticatorConfig config: localAuthenticatorConfigs) {
Assert.assertNotNull(config.getDefinedByType(), "");
}

Assert.assertEquals(localAuthenticatorConfigs[0], localAuthenticatorConfig);
}

Expand Down Expand Up @@ -1245,11 +1250,13 @@ private void addApplicationConfigurations(ServiceProvider serviceProvider) {
identityProvider.setIdentityProviderName(IDP_NAME_1);
FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();
federatedAuthenticatorConfig.setName("Federated authenticator");
federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]
{federatedAuthenticatorConfig});
authenticationStep.setFederatedIdentityProviders(new IdentityProvider[]{identityProvider});
LocalAuthenticatorConfig localAuthenticatorConfig = new LocalAuthenticatorConfig();
localAuthenticatorConfig.setName("Local authenticator");
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
authenticationStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[]{localAuthenticatorConfig});
authenticationConfig.setAuthenticationSteps(new AuthenticationStep[]{authenticationStep});
serviceProvider.setLocalAndOutBoundAuthenticationConfig(authenticationConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.*;
import static org.wso2.carbon.idp.mgt.util.IdPManagementConstants.RESET_PROVISIONING_ENTITIES_ON_CONFIG_UPDATE;

/**
Expand Down Expand Up @@ -1032,6 +1029,7 @@ public void testGetIdPByAuthenticatorPropertyValue(int tenantId, String idpName,
value, authenticator, tenantId, TENANT_DOMAIN);
if (isExist) {
assertEquals(idpResult.getIdentityProviderName(), idpName);
assertNotNull(idpResult.getDefaultAuthenticatorConfig().getDefinedByType());
} else {
assertNull(idpResult);
}
Expand Down Expand Up @@ -1084,6 +1082,7 @@ public void testGetIdPByAuthenticatorPropertyWithoutAuthenticatorData(int tenant

if (isExist) {
assertEquals(idpResult.getIdentityProviderName(), idpName);
assertNotNull(idpResult.getDefaultAuthenticatorConfig().getDefinedByType());
} else {
assertNull(idpResult);
}
Expand Down Expand Up @@ -1748,6 +1747,7 @@ private void addTestIdps() throws IdentityProviderManagementException {
property2.setConfidential(false);
federatedAuthenticatorConfig.setProperties(new Property[]{property1, property2});
idp1.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{federatedAuthenticatorConfig});
idp1.setDefaultAuthenticatorConfig(federatedAuthenticatorConfig);

ProvisioningConnectorConfig provisioningConnectorConfig1 = new ProvisioningConnectorConfig();
provisioningConnectorConfig1.setName("ProvisiningConfig1");
Expand Down

0 comments on commit c9166db

Please sign in to comment.