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

Introduce Role-Based Authentication for Repository Management #1060

Merged
merged 12 commits into from
Dec 24, 2024
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
minwoox committed Nov 18, 2024
commit 35459a1a0cf2126c652f9a51e90e654b61ed044a
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ void grantPermissionToMemberForMetaRepository() throws Exception {
assertThat(res.status()).isSameAs(HttpStatus.FORBIDDEN);
assertThat(res.contentUtf8()).contains("You must have READ permission for repository");

// Grant a READ permission to the member.
// Grant a READ permission to the member with the legacy format.
request = HttpRequest.builder()
.post("/api/v1/metadata/" + projectName + "/repos/meta/perm/role")
.content(MediaType.JSON,
@@ -115,5 +115,20 @@ void grantPermissionToMemberForMetaRepository() throws Exception {
// Now the member can access the meta repository.
res = memberClient.get("/api/v1/projects/" + projectName + "/repos/meta/list").aggregate().join();
assertThat(res.status()).isSameAs(HttpStatus.NO_CONTENT);

// With the new format.
request = HttpRequest.builder()
.post("/api/v1/metadata/" + projectName + "/repos/meta/perm/role")
.content(MediaType.JSON,
'{' +
" \"member\": null," +
" \"guest\": null" +
'}')
.build();
adminClient.execute(request).aggregate().join();

// Now the member cannot access the meta repository.
res = memberClient.get("/api/v1/projects/" + projectName + "/repos/meta/list").aggregate().join();
assertThat(res.status()).isSameAs(HttpStatus.FORBIDDEN);
}
}
Loading