Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Jan 14, 2025
1 parent 0e9f087 commit f653824
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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 @@ -99,16 +100,29 @@ void setUp() throws Exception {

@Test
void triggerMirroring() throws Exception {
final PublicKeyCredential credential = getCredential();
// Put an invalid credential to project with ID PRIVATE_KEY_FILE.
final NoneCredential noneCredential = new NoneCredential(PRIVATE_KEY_FILE, true);
ResponseEntity<PushResultDto> response =
systemAdminClient.prepare()
.post("/api/v1/projects/{proj}/credentials")
.pathParam("proj", FOO_PROJ)
.contentJson(credential)
.contentJson(noneCredential)
.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();
response = systemAdminClient.prepare()
.post("/api/v1/projects/{proj}/repos/{repo}/mirrors")
Expand Down
Loading

0 comments on commit f653824

Please sign in to comment.