Add tests for the public access determination logic
This commit is contained in:
parent
d8cb9ae368
commit
a2b22bbba8
@ -113,6 +113,66 @@ class RepositoryTest {
|
|||||||
verify(exactly = 1) { appSettingsService.updateApiVersion(4) }
|
verify(exactly = 1) { appSettingsService.updateApiVersion(4) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun get_public_access() {
|
||||||
|
every { appSettingsService.updatePublicAccess(any()) } returns Unit
|
||||||
|
coEvery { api.apiInformation() } returns StatusAndData(
|
||||||
|
success = true,
|
||||||
|
data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, true))
|
||||||
|
)
|
||||||
|
every { appSettingsService.getUserName() } returns ""
|
||||||
|
|
||||||
|
initializeRepository()
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.apiInformation() }
|
||||||
|
coVerify(exactly = 1) { appSettingsService.updatePublicAccess(true) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun get_public_access_username_not_empty() {
|
||||||
|
every { appSettingsService.updatePublicAccess(any()) } returns Unit
|
||||||
|
coEvery { api.apiInformation() } returns StatusAndData(
|
||||||
|
success = true,
|
||||||
|
data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, true))
|
||||||
|
)
|
||||||
|
every { appSettingsService.getUserName() } returns "username"
|
||||||
|
|
||||||
|
initializeRepository()
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.apiInformation() }
|
||||||
|
coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun get_public_access_no_auth() {
|
||||||
|
every { appSettingsService.updatePublicAccess(any()) } returns Unit
|
||||||
|
coEvery { api.apiInformation() } returns StatusAndData(
|
||||||
|
success = true,
|
||||||
|
data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, false))
|
||||||
|
)
|
||||||
|
every { appSettingsService.getUserName() } returns ""
|
||||||
|
|
||||||
|
initializeRepository()
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.apiInformation() }
|
||||||
|
coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun get_public_access_disabled() {
|
||||||
|
every { appSettingsService.updatePublicAccess(any()) } returns Unit
|
||||||
|
coEvery { api.apiInformation() } returns StatusAndData(
|
||||||
|
success = true,
|
||||||
|
data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(false, true))
|
||||||
|
)
|
||||||
|
every { appSettingsService.getUserName() } returns ""
|
||||||
|
|
||||||
|
initializeRepository()
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.apiInformation() }
|
||||||
|
coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun get_api_1_date_with_api_4_version_stored() {
|
fun get_api_1_date_with_api_4_version_stored() {
|
||||||
every { appSettingsService.getApiVersion() } returns 4
|
every { appSettingsService.getApiVersion() } returns 4
|
||||||
|
Loading…
Reference in New Issue
Block a user