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

test: CGS connect negative tests #38120

Merged
merged 1 commit into from
Dec 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 @@ -371,27 +371,7 @@ public Mono<? extends Artifact> connectArtifactToGit(
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ORIGIN));
}

Mono<UserData> currentUserMono = userDataService
.getForCurrentUser()
.filter(userData -> !CollectionUtils.isEmpty(userData.getGitProfiles()))
.switchIfEmpty(
Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_PROFILE_ERROR)));

Mono<GitUser> gitUserMono = currentUserMono
.map(userData -> {
GitProfile profile = userData.getGitProfileByKey(baseArtifactId);
if (profile == null
|| Boolean.TRUE.equals(profile.getUseGlobalProfile())
|| !StringUtils.hasText(profile.getAuthorName())) {
profile = userData.getGitProfileByKey(DEFAULT);
}

GitUser gitUser = new GitUser();
gitUser.setName(profile.getAuthorName());
gitUser.setEmail(profile.getAuthorEmail());
return gitUser;
})
.cache();
Mono<GitUser> gitUserMono = getGitUserForArtifactId(baseArtifactId);

Mono<Map<String, GitProfile>> profileMono = gitProfileUtils
.updateOrCreateGitProfileForCurrentUser(gitConnectDTO.getGitProfile(), baseArtifactId)
Expand Down Expand Up @@ -441,9 +421,10 @@ public Mono<? extends Artifact> connectArtifactToGit(
.onErrorResume(error -> {
log.error("Error while cloning the remote repo, ", error);

AppsmithException appsmithException =
new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, error.getMessage());
if (error instanceof TransportException) {
AppsmithException appsmithException = null;
if (error instanceof AppsmithException e) {
appsmithException = e;
} else if (error instanceof TransportException) {
appsmithException =
new AppsmithException(AppsmithError.INVALID_GIT_SSH_CONFIGURATION);
} else if (error instanceof InvalidRemoteException) {
Expand All @@ -458,6 +439,9 @@ public Mono<? extends Artifact> connectArtifactToGit(
appsmithException =
new AppsmithException(AppsmithError.INVALID_GIT_SSH_URL);
}
} else {
appsmithException = new AppsmithException(
AppsmithError.GIT_GENERIC_ERROR, error.getMessage());
}

ArtifactJsonTransformationDTO jsonTransformationDTO =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public Mono<String> fetchRemoteRepository(
} else if (error instanceof TimeoutException) {
return Mono.error(new AppsmithException(AppsmithError.GIT_EXECUTION_TIMEOUT));
}
return Mono.error(
new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "clone", error));
return Mono.error(new AppsmithException(
AppsmithError.GIT_ACTION_FAILED, "clone", error.getMessage()));
});
});
}
Expand Down Expand Up @@ -325,13 +325,16 @@ public Mono<String> createFirstCommit(ArtifactJsonTransformationDTO jsonTransfor
jsonTransformationDTO.getBaseArtifactId(),
jsonTransformationDTO.getRepoName());

return fsGitHandler.commitArtifact(
repoSuffix,
commitDTO.getMessage(),
commitDTO.getAuthor().getName(),
commitDTO.getAuthor().getEmail(),
true,
commitDTO.getIsAmendCommit());
return fsGitHandler
.commitArtifact(
repoSuffix,
commitDTO.getMessage(),
commitDTO.getAuthor().getName(),
commitDTO.getAuthor().getEmail(),
true,
commitDTO.getIsAmendCommit())
.onErrorResume(error -> Mono.error(
new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "commit", error.getMessage())));
}

@Override
Expand Down
Loading
Loading