fix: fix after rebase

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/598/head
Anatolii Bazko 2023-11-06 09:39:13 +01:00
parent 79ced94cc9
commit 5eacae1797
1 changed files with 13 additions and 11 deletions

View File

@ -142,12 +142,7 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
new PersonalAccessTokenParams(
scmServerUrl, tokenName, tokenId, oAuthToken.getToken(), null));
if (valid.isEmpty()) {
throw new ScmCommunicationException(
"Unable to verify if current token is a valid GitHub token. Token's scm-url needs to be '"
+ GithubApiClient.GITHUB_SAAS_ENDPOINT
+ "' and was '"
+ scmServerUrl
+ "'");
throw buildScmUnauthorizedException(cheSubject);
} else if (!valid.get().first) {
throw new ScmCommunicationException(
"Current token doesn't have the necessary privileges. Please make sure Che app scopes are correct and containing at least: "
@ -161,11 +156,7 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
tokenId,
oAuthToken.getToken());
} catch (UnauthorizedException e) {
throw new ScmUnauthorizedException(
cheSubject.getUserName() + " is not authorized in " + providerName + " OAuth provider.",
providerName,
"2.0",
getLocalAuthenticateUrl());
throw buildScmUnauthorizedException(cheSubject);
} catch (NotFoundException nfe) {
throw new UnknownScmProviderException(nfe.getMessage(), scmServerUrl);
} catch (ServerException | ForbiddenException | BadRequestException | ConflictException e) {
@ -174,6 +165,17 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
}
}
private ScmUnauthorizedException buildScmUnauthorizedException(Subject cheSubject) {
return new ScmUnauthorizedException(
cheSubject.getUserName()
+ " is not authorized in "
+ this.providerName
+ " OAuth provider.",
this.providerName,
"2.0",
getLocalAuthenticateUrl());
}
@Override
@Deprecated
public Optional<Boolean> isValid(PersonalAccessToken personalAccessToken) {