Skip to content

Commit

Permalink
chore: update build and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed Feb 5, 2025
1 parent 9990557 commit f565ae4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ subprojects {
jvmAgents(libs.mockito.core) {
transitive = false
}
jvmAgents(libs.mockito.inline) {
transitive = false
}
}
}

Expand Down
1 change: 0 additions & 1 deletion gradle/tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ TestCategories.values().each({ testCategory ->
classDumpDir = layout.buildDirectory.dir('jacoco/classpathdumps').get().asFile
}
}

jvmArgs += "-javaagent:${configurations.jvmAgents.asPath}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.apereo.cas.AbstractCentralAuthenticationServiceTests;
import org.apereo.cas.config.CasSupportActionsAutoConfiguration;
import org.apereo.cas.test.CasTestExtension;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;

/**
Expand All @@ -11,5 +13,6 @@
* @since 6.0.0
*/
@ImportAutoConfiguration(CasSupportActionsAutoConfiguration.class)
@ExtendWith(CasTestExtension.class)
public abstract class AbstractWebflowActionsTests extends AbstractCentralAuthenticationServiceTests {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import org.apereo.cas.authentication.CoreAuthenticationTestUtils;
import org.apereo.cas.authentication.Credential;
import org.apereo.cas.services.RegisteredServiceTestUtils;
import org.apereo.cas.test.CasTestExtension;
import org.apereo.cas.util.MockRequestContext;
import org.apereo.cas.web.cookie.CasCookieBuilder;
import org.apereo.cas.web.support.WebUtils;
import lombok.val;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.validation.BindException;
Expand All @@ -22,14 +25,11 @@
* @since 3.0.0
*/
@Tag("WebflowAuthenticationActions")
@ExtendWith(CasTestExtension.class)
class AuthenticationViaFormActionTests extends AbstractWebflowActionsTests {

private static final String TEST = "test";

private static final String USERNAME_PARAM = "username";

private static final String PASSWORD_PARAM = "password";

@Autowired
@Qualifier(CasWebflowConstants.ACTION_ID_AUTHENTICATION_VIA_FORM_ACTION)
private Action action;
Expand All @@ -38,11 +38,21 @@ class AuthenticationViaFormActionTests extends AbstractWebflowActionsTests {
@Qualifier(CasCookieBuilder.BEAN_NAME_WARN_COOKIE_BUILDER)
private CasCookieBuilder warnCookieGenerator;

@BeforeEach
void beforeEach() throws Exception {
val requestContext = MockRequestContext.create(applicationContext);
requestContext
.setRemoteAddr("127.26.152.11")
.setLocalAddr("109.98.51.12")
.withUserAgent()
.setClientInfo();
}

@Test
void verifySuccessfulAuthenticationWithNoService() throws Throwable {
val context = MockRequestContext.create(applicationContext);
context.setParameter(USERNAME_PARAM, TEST);
context.setParameter(PASSWORD_PARAM, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_USERNAME, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_PASSWORD, TEST);
val credentials = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, credentials);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, action.execute(context).getId());
Expand All @@ -52,8 +62,8 @@ void verifySuccessfulAuthenticationWithNoService() throws Throwable {
void verifySuccessfulAuthenticationWithNoServiceAndWarn() throws Throwable {
val context = MockRequestContext.create(applicationContext);

context.setParameter(USERNAME_PARAM, TEST);
context.setParameter(PASSWORD_PARAM, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_USERNAME, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_PASSWORD, TEST);
context.setParameter(CasWebflowConstants.ATTRIBUTE_WARN_ON_REDIRECT, "true");

val credentials = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
Expand All @@ -66,8 +76,8 @@ void verifySuccessfulAuthenticationWithNoServiceAndWarn() throws Throwable {
void verifySuccessfulAuthenticationWithServiceAndWarn() throws Throwable {
val context = MockRequestContext.create(applicationContext);

context.setParameter(USERNAME_PARAM, TEST);
context.setParameter(PASSWORD_PARAM, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_USERNAME, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_PASSWORD, TEST);
context.setParameter(CasWebflowConstants.ATTRIBUTE_WARN_ON_REDIRECT, "true");
context.setParameter(CasProtocolConstants.PARAMETER_SERVICE, TEST);

Expand All @@ -82,8 +92,8 @@ void verifySuccessfulAuthenticationWithServiceAndWarn() throws Throwable {
void verifyFailedAuthenticationWithNoService() throws Throwable {
val context = MockRequestContext.create(applicationContext);

context.setParameter(USERNAME_PARAM, TEST);
context.setParameter(PASSWORD_PARAM, "test2");
context.setParameter(CasProtocolConstants.PARAMETER_USERNAME, TEST);
context.setParameter(CasProtocolConstants.PARAMETER_PASSWORD, "test2");

val credential = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword();
putCredentialInRequestScope(context, credential);
Expand Down Expand Up @@ -172,6 +182,6 @@ void verifyRenewWithServiceAndBadCredentials() throws Throwable {

private static void putCredentialInRequestScope(final RequestContext context,
final Credential credential) {
context.getRequestScope().put("credential", credential);
WebUtils.putCredential(context, credential);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</Appenders>
<Loggers>
<Logger name="org.apereo" level="error" />
<Root level="off">
<Root level="error">
<AppenderRef ref="console"/>
</Root>
</Loggers>
Expand Down

0 comments on commit f565ae4

Please sign in to comment.