Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix archived vault migration during Hub upgrade #270

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,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);
}
Comment on lines 164 to 169
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did the old test succeed? 😭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quiet exactly for the same reason described in the bug report: In the testGrantAccessArchived, the access-token wasn't added because this vault is archived and then the GET /vaults/{vaultId}/access-token?evenIfArchived=true resource throws a ForbiddenException (403).


@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
Loading