mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 19:28:44 +03:00
BIT-2283: Add the unassigned ciphers API (#1326)
This commit is contained in:
parent
25c7ed0835
commit
880d26e259
4 changed files with 22 additions and 0 deletions
|
@ -130,4 +130,10 @@ interface CiphersApi {
|
|||
@Path("cipherId") cipherId: String,
|
||||
@Path("attachmentId") attachmentId: String,
|
||||
): Result<SyncResponseJson.Cipher.Attachment>
|
||||
|
||||
/**
|
||||
* Indicates if the active user has unassigned ciphers.
|
||||
*/
|
||||
@GET("ciphers/has-unassigned-ciphers")
|
||||
suspend fun hasUnassignedCiphers(): Result<Boolean>
|
||||
}
|
||||
|
|
|
@ -101,4 +101,9 @@ interface CiphersService {
|
|||
cipherId: String,
|
||||
attachmentId: String,
|
||||
): Result<SyncResponseJson.Cipher.Attachment>
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating if the active user has unassigned ciphers.
|
||||
*/
|
||||
suspend fun hasUnassignedCiphers(): Result<Boolean>
|
||||
}
|
||||
|
|
|
@ -159,4 +159,7 @@ class CiphersServiceImpl(
|
|||
cipherId = cipherId,
|
||||
attachmentId = attachmentId,
|
||||
)
|
||||
|
||||
override suspend fun hasUnassignedCiphers(): Result<Boolean> =
|
||||
ciphersApi.hasUnassignedCiphers()
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.test.runTest
|
|||
import okhttp3.mockwebserver.MockResponse
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import retrofit2.create
|
||||
|
@ -259,6 +260,13 @@ class CiphersServiceTest : BaseServiceTest() {
|
|||
result.getOrThrow(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasUnassignedCiphers should return the correct response`() = runTest {
|
||||
server.enqueue(MockResponse().setBody("true"))
|
||||
val result = ciphersService.hasUnassignedCiphers()
|
||||
assertTrue(result.getOrThrow())
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupMockUri(
|
||||
|
|
Loading…
Add table
Reference in a new issue