Skip to content

Commit

Permalink
Fix2
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Jan 17, 2025
1 parent d0182e5 commit e81bdc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.linecorp.centraldogma.internal.api.v1.PushResultDto;
import com.linecorp.centraldogma.server.CentralDogmaBuilder;
import com.linecorp.centraldogma.server.internal.api.sysadmin.MirrorAccessControlRequest;
import com.linecorp.centraldogma.server.internal.credential.NoneCredential;
import com.linecorp.centraldogma.server.internal.credential.PublicKeyCredential;
import com.linecorp.centraldogma.server.internal.mirror.MirrorAccessControl;
import com.linecorp.centraldogma.server.mirror.MirrorResult;
Expand Down Expand Up @@ -102,29 +101,16 @@ void setUp() throws Exception {

@Test
void triggerMirroring() throws Exception {
// Put an invalid credential to project with ID PRIVATE_KEY_FILE.
final NoneCredential noneCredential = new NoneCredential(PRIVATE_KEY_FILE, true);
final PublicKeyCredential credential = getCredential();
ResponseEntity<PushResultDto> response =
systemAdminClient.prepare()
.post("/api/v1/projects/{proj}/credentials")
.pathParam("proj", FOO_PROJ)
.contentJson(noneCredential)
.contentJson(credential)
.asJson(PushResultDto.class)
.execute();
assertThat(response.status()).isEqualTo(HttpStatus.CREATED);

// Put valid credential to repository with ID PRIVATE_KEY_FILE.
// This credential will be used for mirroring because it has higher priority than project credential.
final PublicKeyCredential credential = getCredential();
response = systemAdminClient.prepare()
.post("/api/v1/projects/{proj}/repos/{repo}/credentials")
.pathParam("proj", FOO_PROJ)
.pathParam("repo", BAR_REPO)
.contentJson(credential)
.asJson(PushResultDto.class)
.execute();
assertThat(response.status()).isEqualTo(HttpStatus.CREATED);

final MirrorRequest newMirror = newMirror(repoMirrorCredentialId(FOO_PROJ, BAR_REPO, PRIVATE_KEY_FILE));
response = systemAdminClient.prepare()
.post("/api/v1/projects/{proj}/repos/{repo}/mirrors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CredentialServiceV1(ProjectApiManager projectApiManager, CommandExecutor
*
* <p>Returns the list of the credentials in the project.
*/
@RequiresProjectRole(ProjectRole.OWNER)
@RequiresProjectRole(ProjectRole.MEMBER)
@Get("/projects/{projectName}/credentials")
public CompletableFuture<List<Credential>> listCredentials(User loginUser,
@Param String projectName) {
Expand All @@ -93,7 +93,7 @@ private static CompletableFuture<List<Credential>> maybeMaskSecret(
*
* <p>Returns the credential for the ID in the project.
*/
@RequiresProjectRole(ProjectRole.OWNER)
@RequiresProjectRole(ProjectRole.MEMBER)
@Get("/projects/{projectName}/credentials/{id}")
public CompletableFuture<Credential> getCredentialById(User loginUser,
@Param String projectName, @Param String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ public boolean zonePinned() {

/**
* Returns whether the migration should be run.
*
* @deprecated Will be removed after the migration is done.
*/
@Deprecated
public boolean runMigration() {
return runMigration;
}
Expand Down

0 comments on commit e81bdc3

Please sign in to comment.