Skip to content

Commit

Permalink
Merge pull request #20 from danieliu456/kc24
Browse files Browse the repository at this point in the history
upgrade to Kc24
  • Loading branch information
dajay authored Apr 10, 2024
2 parents 1cd3598 + e645441 commit 26744e2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ FROM jboss/keycloak:15.1.1
ENV DB_VENDOR H2

ADD target/keycloak-verify-email-by-code-*-SNAPSHOT.jar /opt/jboss/keycloak/standalone/deployments/


4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: '3.8'
services:
keycloak:
image: quay.io/keycloak/keycloak:23.0
image: quay.io/keycloak/keycloak:24.0
command: [ 'start-dev',
'--import-realm',
'--debug',
'--spi-required-action-VERIFY_EMAIL_CODE-code-length=5' ]
volumes:
- ./realm-config/local:/opt/keycloak/data/import
- ./target/keycloak-verify-email-by-code-23.0.0-SNAPSHOT.jar:/opt/keycloak/providers/keycloak-verify-email-by-code.jar
- ./target/keycloak-verify-email-by-code-24.0.0-SNAPSHOT.jar:/opt/keycloak/providers/keycloak-verify-email-by-code.jar
environment:
- KC_DB=dev-file
- KEYCLOAK_ADMIN=admin
Expand Down
14 changes: 10 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>fr.redfroggy.keycloak</groupId>
<artifactId>keycloak-verify-email-by-code</artifactId>
<version>23.0.0-SNAPSHOT</version>
<version>24.0.0-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Action to verify email by code for Keycloak</description>
Expand Down Expand Up @@ -53,11 +53,11 @@
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>3.5.0</maven.javadoc.plugin.version>

<keycloak.version>23.0.4</keycloak.version>
<keycloak.version>24.0.0</keycloak.version>
<jboss-logging.version>3.5.3.Final</jboss-logging.version>

<junit-jupiter.version>5.10.0</junit-jupiter.version>
<mockito.version>5.3.1</mockito.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
<mockito.version>5.11.0</mockito.version>
<assertj.version>3.24.2</assertj.version>
</properties>

Expand Down Expand Up @@ -172,6 +172,12 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static void createFormChallenge(RequiredActionContext context, FormMessa
loginFormsProvider = loginFormsProvider.addError(new FormMessage(EMAIL_CODE, INVALID_CODE));
}
Response challenge = loginFormsProvider
.setAttribute("user", new ProfileBean(context.getUser()))
.setAttribute("user", new ProfileBean(context.getUser(), context.getSession()))
.createForm(LOGIN_VERIFY_EMAIL_CODE_TEMPLATE);
context.challenge(challenge);
}
Expand Down Expand Up @@ -182,7 +182,6 @@ private void sendVerifyEmailAndCreateForm(RequiredActionContext context) throws

@Override
public String getDisplayText() {

logger.info("Retrieved display text for VerifyEmailByCode");
return "Verify Email by code";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.sessions.AuthenticationSessionModel;
import org.keycloak.userprofile.UserProfileProvider;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
Expand All @@ -38,6 +39,8 @@ class VerifyEmailByCodeTest {
@Mock
private UserModel user;
@Mock
private UserProfileProvider provider;
@Mock
private KeycloakSession session;
@Mock
private EventBuilder event;
Expand Down Expand Up @@ -167,7 +170,7 @@ public void shouldGenerateCodeWithSixDigits() {
private void mockChallenge() {
when(requiredActionContext.getUser()).thenReturn(user);
when(user.getEmail()).thenReturn("[email protected]");

when(session.getProvider(UserProfileProvider.class)).thenReturn(provider);
when(requiredActionContext.getSession()).thenReturn(session);

when(requiredActionContext.getEvent()).thenReturn(event);
Expand Down Expand Up @@ -235,6 +238,8 @@ public void shouldChallengeOnProcessActionWhenCodeIsNull() throws EmailException
public void shouldChallengeWithErrorOnProcessActionWhenCodeIsNotValid() {
initAction();
when(requiredActionContext.getUser()).thenReturn(user);
when(session.getProvider(UserProfileProvider.class)).thenReturn(provider);
when(requiredActionContext.getSession()).thenReturn(session);
when(user.getEmail()).thenReturn("[email protected]");

when(requiredActionContext.getEvent()).thenReturn(event);
Expand All @@ -243,6 +248,7 @@ public void shouldChallengeWithErrorOnProcessActionWhenCodeIsNotValid() {
when(event.detail(Details.EMAIL, user.getEmail())).thenReturn(event);

when(requiredActionContext.getAuthenticationSession()).thenReturn(authSession);

when(authSession.getAuthNote(VerifyEmailByCode.VERIFY_EMAIL_CODE)).thenReturn("code is valid");

HttpRequest request = mock(HttpRequest.class);
Expand Down

0 comments on commit 26744e2

Please sign in to comment.