mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 19:28:44 +03:00
PM-10956: Add support for leave organization API (#3754)
This commit is contained in:
parent
8094b3fd22
commit
d4600c5c83
4 changed files with 28 additions and 0 deletions
|
@ -5,6 +5,7 @@ import com.x8bit.bitwarden.data.auth.datasource.network.model.OrganizationKeysRe
|
|||
import com.x8bit.bitwarden.data.auth.datasource.network.model.OrganizationResetPasswordEnrollRequestJson
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.PUT
|
||||
import retrofit2.http.Path
|
||||
|
||||
|
@ -37,4 +38,12 @@ interface AuthenticatedOrganizationApi {
|
|||
suspend fun getOrganizationKeys(
|
||||
@Path("id") organizationId: String,
|
||||
): Result<OrganizationKeysResponseJson>
|
||||
|
||||
/**
|
||||
* Leaves the this organization.
|
||||
*/
|
||||
@POST("/organizations/{id}/leave")
|
||||
suspend fun leaveOrganization(
|
||||
@Path("id") organizationId: String,
|
||||
): Result<Unit>
|
||||
}
|
||||
|
|
|
@ -38,4 +38,11 @@ interface OrganizationService {
|
|||
suspend fun getOrganizationKeys(
|
||||
organizationId: String,
|
||||
): Result<OrganizationKeysResponseJson>
|
||||
|
||||
/**
|
||||
* Leaves this organization.
|
||||
*/
|
||||
suspend fun leaveOrganization(
|
||||
organizationId: String,
|
||||
): Result<Unit>
|
||||
}
|
||||
|
|
|
@ -52,4 +52,9 @@ class OrganizationServiceImpl(
|
|||
.getOrganizationKeys(
|
||||
organizationId = organizationId,
|
||||
)
|
||||
|
||||
override suspend fun leaveOrganization(
|
||||
organizationId: String,
|
||||
): Result<Unit> =
|
||||
authenticatedOrganizationApi.leaveOrganization(organizationId = organizationId)
|
||||
}
|
||||
|
|
|
@ -104,6 +104,13 @@ class OrganizationServiceTest : BaseServiceTest() {
|
|||
val result = organizationService.getOrganizationKeys("orgId")
|
||||
assertTrue(result.isFailure)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `leaveOrganization when response is success should return success`() = runTest {
|
||||
server.enqueue(MockResponse())
|
||||
val result = organizationService.leaveOrganization(organizationId = "orgId")
|
||||
assertTrue(result.isSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
private const val ORGANIZATION_AUTO_ENROLL_STATUS_JSON = """
|
||||
|
|
Loading…
Add table
Reference in a new issue