[MNT-24859] Test cases added

This commit is contained in:
pmm
2025-04-15 15:17:02 +05:30
parent 7f949dc189
commit 2ab9a14f3f
2 changed files with 46 additions and 10 deletions

View File

@@ -1,10 +0,0 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/admin/admin-common.lib.js">
function main()
{
status.code = 301;
status.location = url.serviceContext + Admin.getDefaultToolURI();
status.redirect = true;
}
main();

View File

@@ -173,6 +173,28 @@ public class IdentityServiceAdminConsoleAuthenticatorUnitTest
assertTrue(authenticationRequest.getValue().contains("state")); assertTrue(authenticationRequest.getValue().contains("state"));
} }
@Test
public void shouldCallAuthChallengeWebScriptHome() throws IOException
{
String redirectPath = "/alfresco/s/index";
when(identityServiceConfig.getAdminConsoleScopes()).thenReturn(Set.of("openid", "email", "profile", "offline_access"));
when(identityServiceConfig.getWebScriptHomeRedirectPath()).thenReturn(redirectPath);
ArgumentCaptor<String> authenticationRequest = ArgumentCaptor.forClass(String.class);
String expectedUri = "http://localhost:8999/auth?client_id=alfresco&redirect_uri=%s%s&response_type=code&scope="
.formatted("http://localhost:8080", redirectPath);
authenticator.requestAuthentication(request, response);
verify(response).sendRedirect(authenticationRequest.capture());
assertTrue(authenticationRequest.getValue().contains(expectedUri));
assertTrue(authenticationRequest.getValue().contains("openid"));
assertTrue(authenticationRequest.getValue().contains("profile"));
assertTrue(authenticationRequest.getValue().contains("email"));
assertTrue(authenticationRequest.getValue().contains("offline_access"));
assertTrue(authenticationRequest.getValue().contains("state"));
}
@Test @Test
public void shouldCallAuthChallengeWithAudience() throws IOException public void shouldCallAuthChallengeWithAudience() throws IOException
{ {
@@ -197,6 +219,30 @@ public class IdentityServiceAdminConsoleAuthenticatorUnitTest
assertTrue(authenticationRequest.getValue().contains("state")); assertTrue(authenticationRequest.getValue().contains("state"));
} }
@Test
public void shouldCallAuthChallengeWebScriptHomeWithAudience() throws IOException
{
String audience = "http://localhost:8082";
String redirectPath = "/alfresco/s/index";
when(identityServiceConfig.getAudience()).thenReturn(audience);
when(identityServiceConfig.getWebScriptHomeRedirectPath()).thenReturn(redirectPath);
when(identityServiceConfig.getAdminConsoleScopes()).thenReturn(Set.of("openid", "email", "profile", "offline_access"));
ArgumentCaptor<String> authenticationRequest = ArgumentCaptor.forClass(String.class);
String expectedUri = "http://localhost:8999/auth?client_id=alfresco&redirect_uri=%s%s&response_type=code&scope="
.formatted("http://localhost:8080", redirectPath);
authenticator.requestAuthentication(request, response);
verify(response).sendRedirect(authenticationRequest.capture());
assertTrue(authenticationRequest.getValue().contains(expectedUri));
assertTrue(authenticationRequest.getValue().contains("openid"));
assertTrue(authenticationRequest.getValue().contains("profile"));
assertTrue(authenticationRequest.getValue().contains("email"));
assertTrue(authenticationRequest.getValue().contains("offline_access"));
assertTrue(authenticationRequest.getValue().contains("audience=%s".formatted(audience)));
assertTrue(authenticationRequest.getValue().contains("state"));
}
@Test @Test
public void shouldResetCookiesAndCallAuthChallenge() throws IOException public void shouldResetCookiesAndCallAuthChallenge() throws IOException
{ {