Skip to content

Commit

Permalink
fix: updating isMLSCapable (#1905)
Browse files Browse the repository at this point in the history
* fix: updating isMLSCapable

It should be possible to update isMlsCapable from false to true but not the other
way around.

* chore: add comment explaining update logic for is_mls_capable
  • Loading branch information
typfel committed Aug 31, 2023
1 parent 8429288 commit d789050
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ model = coalesce(excluded.model, model),
is_valid = is_valid,
last_active = coalesce(excluded.last_active, last_active),
mls_public_keys = excluded.mls_public_keys,
is_mls_capable = is_mls_capable;
is_mls_capable = excluded.is_mls_capable OR is_mls_capable; -- it's not possible to remove mls capability once added

selectAllClients:
SELECT * FROM Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ class ClientDAOTest : BaseDatabaseTest() {
assertEquals(listOf(client, client2), result)
}

@Test
fun givenIsMLSCapableIsFalse_whenUpdatingAClient_thenItShouldUpdatedToTrue() = runTest {
val user = user
userDAO.insertUser(user)
clientDAO.insertClient(insertedClient.copy(
isMLSCapable = false
))
clientDAO.insertClient(insertedClient.copy(
isMLSCapable = true
))
assertTrue { clientDAO.getClientsOfUserByQualifiedID(userId).first().isMLSCapable }
}

@Test
fun givenIsMLSCapableIsTrue_whenUpdatingAClient_thenItShouldRemainTrue() = runTest {
val user = user
userDAO.insertUser(user)
clientDAO.insertClient(insertedClient.copy(
isMLSCapable = true
))
clientDAO.insertClient(insertedClient.copy(
isMLSCapable = false
))
assertTrue { clientDAO.getClientsOfUserByQualifiedID(userId).first().isMLSCapable }
}

@Test
fun whenInsertingANewClient_thenIsMustBeMarkedAsValid() = runTest {
val user = user
Expand Down

0 comments on commit d789050

Please sign in to comment.