Skip to content

Commit

Permalink
Merge pull request #270 from cryptomator/feature/fix-migrate-archived…
Browse files Browse the repository at this point in the history
…-vaults

Fix archived vault migration during Hub upgrade
  • Loading branch information
SailReal authored Apr 12, 2024
2 parents ead4705 + c42ccba commit 36d5b22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,8 @@ public Response unlock(@PathParam("vaultId") UUID vaultId, @QueryParam("evenIfAr
@APIResponse(responseCode = "402", description = "number of users granted access exceeds available license seats")
@APIResponse(responseCode = "403", description = "not a vault owner")
@APIResponse(responseCode = "404", description = "at least one user has not been found")
@APIResponse(responseCode = "410", description = "vault is archived")
public Response grantAccess(@PathParam("vaultId") UUID vaultId, @NotEmpty Map<String, String> tokens) {
var vault = Vault.<Vault>findById(vaultId); // should always be found, since @VaultRole filter would have triggered
if (vault.archived) {
throw new GoneException("Vault is archived.");
}

// check number of available seats
long occupiedSeats = EffectiveVaultAccess.countSeatOccupyingUsers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ public void testUnlockArchived2() {
}

@Test
@DisplayName("GET /vaults/7E57C0DE-0000-4000-8000-00010000AAAA/access-token returns 403 for archived vaults with evenIfArchived set to true")
@DisplayName("GET /vaults/7E57C0DE-0000-4000-8000-00010000AAAA/access-token returns 200 for archived vaults with evenIfArchived set to true")
public void testUnlockArchived3() throws SQLException {
when().get("/vaults/{vaultId}/access-token?evenIfArchived=true", "7E57C0DE-0000-4000-8000-00010000AAAA")
.then().statusCode(403);
.then().statusCode(200);
}

@Nested
Expand Down Expand Up @@ -378,11 +378,11 @@ public void testGrantAccess5() {
}

@Test
@DisplayName("POST /vaults/7E57C0DE-0000-4000-8000-00010000AAAA/access-tokens returns 410")
@DisplayName("POST /vaults/7E57C0DE-0000-4000-8000-00010000AAAA/access-tokens returns 200 for user1 and vault archived")
public void testGrantAccessArchived() {
given().contentType(ContentType.JSON).body(Map.of("user1", "jwe.jwe.jwe.vaultAAA.user1"))
.when().post("/vaults/{vaultId}/access-tokens/", "7E57C0DE-0000-4000-8000-00010000AAAA")
.then().statusCode(410);
.then().statusCode(200);
}

}
Expand Down

0 comments on commit 36d5b22

Please sign in to comment.