diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml index 5a20c99..860c5e7 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml @@ -70,6 +70,10 @@ org.wso2.carbon.identity.governance org.wso2.carbon.identity.auth.attribute.handler + + org.wso2.carbon.identity.organization.management.core + org.wso2.carbon.identity.organization.management.service + diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/test/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorTest.java b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/test/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorTest.java index 9dfad6c..dee3882 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/test/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorTest.java +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/test/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorTest.java @@ -37,6 +37,7 @@ import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext; import org.wso2.carbon.identity.application.authentication.framework.exception.AuthenticationFailedException; import org.wso2.carbon.identity.application.authentication.framework.exception.InvalidCredentialsException; +import org.wso2.carbon.identity.application.authentication.framework.internal.FrameworkServiceDataHolder; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils; import org.wso2.carbon.identity.application.authenticator.magiclink.cache.MagicLinkAuthContextCache; @@ -79,7 +80,8 @@ @PrepareForTest({ TokenGenerator.class, IdentityUtil.class, ServiceURLBuilder.class, IdentityTenantUtil.class, AbstractUserStoreManager.class, MagicLinkAuthContextCache.class, MagicLinkServiceDataHolder.class, - ConfigurationFacade.class, FrameworkUtils.class, MultitenantUtils.class, UserCoreUtil.class}) + ConfigurationFacade.class, FrameworkUtils.class, MultitenantUtils.class, UserCoreUtil.class, + FrameworkServiceDataHolder.class}) @PowerMockIgnore({ "javax.net.*", "javax.security.*", "javax.crypto.*", "javax.xml.*" }) public class MagicLinkAuthenticatorTest { @@ -122,6 +124,8 @@ public class MagicLinkAuthenticatorTest { @Mock private ConfigurationFacade mockConfigurationFacade; + private FrameworkServiceDataHolder frameworkServiceDataHolder; + @BeforeMethod public void setUp() { @@ -134,6 +138,8 @@ public void setUp() { mockStatic(MultitenantUtils.class); mockUserStoreManager = mock(AbstractUserStoreManager.class); Whitebox.setInternalState(magicLinkAuthenticator, "authenticationContext", context); + frameworkServiceDataHolder = mock(FrameworkServiceDataHolder.class); + mockStatic(FrameworkServiceDataHolder.class); } private void mockServiceURLBuilder() { @@ -490,8 +496,9 @@ public void testProcess() throws Exception { MagicLinkServiceDataHolder.getInstance().setRealmService(mockRealmService); when(IdentityUtil.getPrimaryDomainName()).thenReturn(USER_STORE_DOMAIN); when(IdentityTenantUtil.getTenantId(SUPER_TENANT_DOMAIN)).thenReturn(-1234); - AuthenticatedUser authenticatedUser = AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier( - USERNAME); + AuthenticatedUser authenticatedUser = new AuthenticatedUser(); + authenticatedUser.setAuthenticatedSubjectIdentifier(USERNAME); + authenticatedUser.setUserName(USERNAME); when(context.getLastAuthenticatedUser()).thenReturn(authenticatedUser); when(TokenGenerator.generateToken(anyInt())).thenReturn(DUMMY_MAGIC_TOKEN); mockStatic(MagicLinkAuthContextCache.class); @@ -512,6 +519,8 @@ public void testProcess() throws Exception { when(mockRealmService.getTenantUserRealm(anyInt())).thenReturn(mockUserRealm); when(mockUserRealm.getUserStoreManager()).thenReturn(mockUserStoreManager); when(mockUserStoreManager.getUserListWithID(USERNAME_CLAIM, USERNAME, null)).thenReturn(userList); + PowerMockito.when(FrameworkServiceDataHolder.getInstance()).thenReturn(frameworkServiceDataHolder); + PowerMockito.when(frameworkServiceDataHolder.getRealmService()).thenReturn(mockRealmService); Mockito.doNothing().when(httpServletResponse).sendRedirect(anyString()); diff --git a/pom.xml b/pom.xml index 4049cd9..a4c84db 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,12 @@ ${powermock.version} test + + org.wso2.carbon.identity.organization.management.core + org.wso2.carbon.identity.organization.management.service + ${org.wso2.carbon.identity.organization.management.core.version} + test + org.jacoco org.jacoco.agent @@ -201,7 +207,7 @@ ${project.version} 4.7.0 - 5.25.245 + 5.25.252 1.2.10 1.3.14 6.4.126 @@ -209,6 +215,8 @@ 4.4.3 1.5.3 1.8.23 + 1.0.55 + 6.9.10