-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from VAuthenticator/password-reuse-prevention…
…-2-iteration Password reuse prevention 2 iteration
- Loading branch information
Showing
18 changed files
with
243 additions
and
70 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ticator/server/account/mailverification/SendVerifyMailChallengeUponSignUpEventConsumer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.vauthenticator.server.account.mailverification | ||
|
||
import com.vauthenticator.server.events.EventConsumer | ||
import com.vauthenticator.server.events.SignUpEvent | ||
import com.vauthenticator.server.events.VAuthenticatorEvent | ||
|
||
class SendVerifyMailChallengeUponSignUpEventConsumer( | ||
private val mailChallenge: SendVerifyMailChallenge | ||
) : EventConsumer { | ||
override fun accept(event: VAuthenticatorEvent) { | ||
mailChallenge.sendVerifyMail(event.userName.content) | ||
} | ||
|
||
override fun handleable(event: VAuthenticatorEvent): Boolean = event is SignUpEvent | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...otlin/com/vauthenticator/server/account/welcome/SendWelcomeMailUponSignUpEventConsumer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.vauthenticator.server.account.welcome | ||
|
||
import com.vauthenticator.server.events.EventConsumer | ||
import com.vauthenticator.server.events.SignUpEvent | ||
import com.vauthenticator.server.events.VAuthenticatorEvent | ||
|
||
class SendWelcomeMailUponSignUpEventConsumer( | ||
private val sayWelcome: SayWelcome | ||
) : EventConsumer { | ||
override fun accept(event: VAuthenticatorEvent) { | ||
sayWelcome.welcome(event.userName.content) | ||
} | ||
|
||
override fun handleable(event: VAuthenticatorEvent): Boolean = event is SignUpEvent | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/main/kotlin/com/vauthenticator/server/events/EventsCollector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.vauthenticator.server.events | ||
|
||
import org.slf4j.LoggerFactory | ||
import org.springframework.context.event.EventListener | ||
|
||
class SpringEventsCollector(private val eventConsumers: List<EventConsumer>) : EventsCollector { | ||
|
||
private val logger = LoggerFactory.getLogger(SpringEventsCollector::class.java) | ||
@EventListener | ||
override fun accept(event: VAuthenticatorEvent) { | ||
eventConsumers.forEach { it.accept(event) } | ||
logger.debug("event ${event::class.simpleName} is collected") | ||
eventConsumers.forEach { | ||
val handleable = it.handleable(event) | ||
logger.debug("event ${event::class.simpleName} is handleable $handleable") | ||
if(handleable){ | ||
it.accept(event) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...tor/server/account/mailverification/SendVerifyMailChallengeUponSignUpEventConsumerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.vauthenticator.server.account.mailverification | ||
|
||
import com.vauthenticator.server.events.EventFixture.signUpEvent | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import io.mockk.junit5.MockKExtension | ||
import io.mockk.just | ||
import io.mockk.runs | ||
import io.mockk.verify | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
|
||
@ExtendWith(MockKExtension::class) | ||
class SendVerifyMailChallengeUponSignUpEventConsumerTest { | ||
|
||
@MockK | ||
lateinit var mailChallenge: SendVerifyMailChallenge | ||
|
||
@Test | ||
fun `when the verify mail challenge is sent`() { | ||
val uut = SendVerifyMailChallengeUponSignUpEventConsumer(mailChallenge) | ||
|
||
every { mailChallenge.sendVerifyMail("AN_EMAIL") } just runs | ||
|
||
uut.accept(signUpEvent) | ||
assertEquals(true, uut.handleable(signUpEvent)) | ||
|
||
verify { mailChallenge.sendVerifyMail("AN_EMAIL") } | ||
} | ||
} |
Oops, something went wrong.