Also check Seerr parent permissions (#1631)

## Description
When saving Seerr permissions on the WebUI, if a "parent" permission is
checked, only its bit is flipped and its children's bits are not. So
clients must check if a user has the permission _or_ its parent.

For example, if just "Request 4K" is checked, the flags for "Request 4K
Movies" and "Request 4K TV" will not set explicitly.

### Related issues
Fixes #1630

### Testing
Emulator & unit tests, also manually reviewed API requests/responses on
Seerr's web UI

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-06-27 14:28:57 -04:00 • committed by GitHub
parent a8ade9171e
commit 21e720c420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 92 additions and 14 deletions

View file

@ -0,0 +1,74 @@
package com.github.damontecres.wholphin.test
import com.github.damontecres.wholphin.data.model.SeerrPermission
import com.github.damontecres.wholphin.data.model.hasPermission
import com.github.damontecres.wholphin.services.SeerrUserConfig
import org.junit.Assert
import org.junit.Test
class TestSeerrPermission {
@Test
fun `Is Admin`() {
val user =
SeerrUserConfig(
id = 0,
permissions = 2,
)
Assert.assertTrue(user.hasPermission(SeerrPermission.ADMIN))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_MOVIE))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_TV))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K))
}
@Test
fun `Request any 4k has request movie 4k`() {
val user =
SeerrUserConfig(
id = 0,
permissions = 1024,
)
Assert.assertFalse(user.hasPermission(SeerrPermission.ADMIN))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_MOVIE))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_TV))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K))
}
@Test
fun `Request movie 4k and does not have request tv 4k`() {
val user =
SeerrUserConfig(
id = 0,
permissions = 2048,
)
Assert.assertFalse(user.hasPermission(SeerrPermission.ADMIN))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_MOVIE))
Assert.assertFalse(user.hasPermission(SeerrPermission.REQUEST_4K_TV))
Assert.assertFalse(user.hasPermission(SeerrPermission.REQUEST_4K))
}
@Test
fun `Has explicit request 4k and children`() {
val user =
SeerrUserConfig(
id = 0,
permissions = 7168,
)
Assert.assertFalse(user.hasPermission(SeerrPermission.ADMIN))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_MOVIE))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_TV))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K))
}
@Test
fun `Has explicit request 4k children`() {
val user =
SeerrUserConfig(
id = 0,
permissions = 6144,
)
Assert.assertFalse(user.hasPermission(SeerrPermission.ADMIN))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_MOVIE))
Assert.assertTrue(user.hasPermission(SeerrPermission.REQUEST_4K_TV))
Assert.assertFalse(user.hasPermission(SeerrPermission.REQUEST_4K))
}
}