-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevents users from changing their password
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
komga/src/test/kotlin/org/gotson/komga/interfaces/rest/UserControllerTest.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,38 @@ | ||
package org.gotson.komga.interfaces.rest | ||
|
||
import org.gotson.komga.infrastructure.security.KomgaUserDetailsLifecycle | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.http.MediaType | ||
import org.springframework.test.context.ActiveProfiles | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.patch | ||
|
||
@ExtendWith(SpringExtension::class) | ||
@SpringBootTest | ||
@AutoConfigureTestDatabase | ||
@AutoConfigureMockMvc(printOnlyOnFailure = false) | ||
@ActiveProfiles("demo") | ||
class UserControllerTest( | ||
@Autowired private val userDetailsLifecycle: KomgaUserDetailsLifecycle, | ||
@Autowired private val mockMvc: MockMvc | ||
|
||
) { | ||
@Test | ||
@WithMockCustomUser | ||
fun `given demo profile is active when a user tries to update its password via api then returns forbidden`() { | ||
val jsonString = """{"password":"new"}""" | ||
|
||
mockMvc.patch("/api/v1/users/me/password") { | ||
contentType = MediaType.APPLICATION_JSON | ||
content = jsonString | ||
}.andExpect { | ||
status { isForbidden } | ||
} | ||
} | ||
} |