Skip to content

Commit 28e40c3

Browse files
committed
Fix hibernate parsing of ban level
1 parent e76d2a1 commit 28e40c3

File tree

2 files changed

+16
-1
lines changed
  • src
    • main/kotlin/com/faforever/userservice/backend/domain
    • test/kotlin/com/faforever/userservice/backend/domain

2 files changed

+16
-1
lines changed

src/main/kotlin/com/faforever/userservice/backend/domain/Ban.kt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ data class Ban(
2121
val playerId: Long,
2222
@Column(name = "author_id")
2323
val authorId: Int,
24+
@Enumerated(EnumType.STRING)
2425
val level: BanLevel,
2526
val reason: String,
2627
@Column(name = "expires_at")

src/test/kotlin/com/faforever/userservice/backend/domain/LoginServiceTest.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,21 @@ class LoginServiceTest {
8686
whenever(passwordEncoder.matches(anyString(), anyString())).thenReturn(true)
8787
whenever(banRepository.findGlobalBansByPlayerId(anyInt())).thenReturn(
8888
listOf(
89-
Ban(1, 1, 100, BanLevel.CHAT, "test", OffsetDateTime.MAX, null, null, null, null)
89+
Ban(1, 1, 100, BanLevel.GLOBAL, "test", OffsetDateTime.MAX, null, null, null, null)
90+
)
91+
)
92+
93+
val result = loginService.login(username, password, ipAddress, false)
94+
assertThat(result, instanceOf(LoginResult.UserBanned::class.java))
95+
}
96+
97+
@Test
98+
fun loginWithPermaBannedUser() {
99+
whenever(userRepository.findByUsernameOrEmail(anyString())).thenReturn(user)
100+
whenever(passwordEncoder.matches(anyString(), anyString())).thenReturn(true)
101+
whenever(banRepository.findGlobalBansByPlayerId(anyInt())).thenReturn(
102+
listOf(
103+
Ban(1, 1, 100, BanLevel.GLOBAL, "test", null, null, null, null, null)
90104
)
91105
)
92106

0 commit comments

Comments
 (0)