Skip to content

Commit

Permalink
Fix formatting in unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaura committed Nov 14, 2024
1 parent 7548be0 commit 35f816a
Showing 1 changed file with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,10 @@ public void testProcessOrgParamForOrgsWithSameName() throws Exception {
when(mockOrgApplicationManager.getApplicationSharedOrganizations(anyString(), anyString())).
thenReturn(Arrays.asList(mockBasicOrganization, mockBasicOrganization));

mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);
when(mockAuthenticationContext.getContextIdentifier()).thenReturn(contextIdentifier);
when(mockAuthenticationContext.getExternalIdP()).thenReturn(mockExternalIdPConfig);
when(mockAuthenticationContext.getServiceProviderName()).thenReturn(saasApp);
when(mockAuthenticationContext.getServiceProviderResourceId()).thenReturn(saasAppResourceId);
when(mockAuthenticationContext.getTenantDomain()).thenReturn(saasAppOwnedTenant);
when(mockExternalIdPConfig.getName()).thenReturn(AUTHENTICATOR_FRIENDLY_NAME);

when(authenticatorDataHolder.getOrganizationConfigManager().getDiscoveryConfiguration())
Expand All @@ -358,8 +357,7 @@ public void testProcessWithValidOrgIdParamSet() throws Exception {
authenticatorParamProperties.put(ORG_PARAMETER, "");
when(organizationAuthenticator.getRuntimeParams(mockAuthenticationContext))
.thenReturn(authenticatorParamProperties);
when(mockAuthenticationContext.getServiceProviderName()).thenReturn(saasApp);
when(mockAuthenticationContext.getTenantDomain()).thenReturn(saasAppOwnedTenant);
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);

setMockContextParamForValidOrganization();
mockOrgApplicationManager();
Expand Down Expand Up @@ -404,8 +402,7 @@ public void testProcessWithSharedAppPublicClientStatus(boolean isPublicClient,
setupInboundAuthenticationRequestConfigs();
setMockContextParamForValidOrganization();

when(mockAuthenticationContext.getServiceProviderName()).thenReturn(saasApp);
when(mockAuthenticationContext.getTenantDomain()).thenReturn(saasAppOwnedTenant);
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);
when(mockAuthenticationContext.getAuthenticatorProperties()).thenReturn(authenticatorProperties);

when(authenticatorDataHolder.getOrganizationManager().resolveOrganizationId(anyString()))
Expand Down Expand Up @@ -447,8 +444,7 @@ public void testInitiateAuthenticationRequestNoSharedApp() throws Exception {

when(mockOrganizationManager.resolveOrganizationId(anyString()))
.thenReturn(saasAppOwnedOrgId);
when(mockAuthenticationContext.getTenantDomain()).thenReturn(saasAppOwnedTenant);
when(mockAuthenticationContext.getServiceProviderName()).thenReturn(saasApp);
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);
when(mockOrgApplicationManager.resolveSharedApplication(anyString(),
anyString(), anyString())).thenThrow(
new OrganizationManagementServerException(ERROR_CODE_APPLICATION_NOT_SHARED.getCode(),
Expand All @@ -474,7 +470,7 @@ public void testInitiateAuthenticationRequestInvalidSharedAppInbound() throws Ex
new OrganizationManagementServerException(ERROR_CODE_INVALID_APPLICATION.getCode(),
ERROR_CODE_INVALID_APPLICATION.getMessage()));

mockAuthenticationContext();
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);

organizationAuthenticator.initiateAuthenticationRequest(mockServletRequest, mockServletResponse,
mockAuthenticationContext);
Expand All @@ -491,7 +487,7 @@ public void testInitiateAuthenticationRequestInvalidSharedApp() throws Exception

mockOrganizationManager();
mockOrgApplicationManager();
mockAuthenticationContext();
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);

when(mockServiceProvider.getInboundAuthenticationConfig()).thenReturn(mockInboundAuthenticationConfig);

Expand Down Expand Up @@ -588,7 +584,7 @@ public void testSAMLIdPInitiatedB2BLoginFlow(boolean isSamlRedirectionHtmlPageAv
mockOrganizationManager();

// Mock authentication context.
mockAuthenticationContext();
mockBasicAuthenticationContext(saasAppOwnedTenant, saasApp);

// Mock application manager.
mockOrgApplicationManager();
Expand Down Expand Up @@ -658,10 +654,10 @@ public void testSAMLIdPInitiatedB2BLoginFlow(boolean isSamlRedirectionHtmlPageAv
}
}

private void mockAuthenticationContext() {
private void mockBasicAuthenticationContext(String tenantDomain, String serviceProviderName) {

when(mockAuthenticationContext.getTenantDomain()).thenReturn(saasAppOwnedTenant);
when(mockAuthenticationContext.getServiceProviderName()).thenReturn(saasApp);
when(mockAuthenticationContext.getTenantDomain()).thenReturn(tenantDomain);
when(mockAuthenticationContext.getServiceProviderName()).thenReturn(serviceProviderName);
}

private void mockOrgApplicationManager() throws OrganizationManagementException {
Expand All @@ -676,8 +672,8 @@ private void mockOrganizationManager() throws OrganizationManagementException {
.getOrganizationIdByName(anyString())).thenReturn(orgId);
when(authenticatorDataHolder.getOrganizationManager()
.getOrganization(anyString(), anyBoolean(), anyBoolean())).thenReturn(mockOrganization);
when(authenticatorDataHolder.getOrganizationManager().resolveTenantDomain(anyString())).thenReturn(
orgId);
when(authenticatorDataHolder.getOrganizationManager().resolveTenantDomain(anyString()))
.thenReturn(orgId);
when(authenticatorDataHolder.getOrganizationManager().resolveOrganizationId(anyString()))
.thenReturn(saasAppOwnedOrgId);
when(authenticatorDataHolder.getOrganizationManager().getOrganizationNameById(anyString()))
Expand Down

0 comments on commit 35f816a

Please sign in to comment.