mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[MNT-24859] Test cases added
This commit is contained in:
@@ -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();
|
|
@@ -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
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user