Skip to content

Commit

Permalink
fixup! Add Azure DevOps Server support
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Mar 3, 2025
1 parent 9e52d56 commit d689ed0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,15 @@ public Optional<Boolean> isValid(PersonalAccessToken personalAccessToken) {
}

@Override
public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params)
throws ScmCommunicationException {
public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params) {
if (!isValidAzureDevOpsSAASUrl(params.getScmProviderUrl())) {
if (OAUTH_PROVIDER_NAME.equals(params.getScmProviderName())) {
AzureDevOpsServerApiClient azureDevOpsServerApiClient =
new AzureDevOpsServerApiClient(params.getScmProviderUrl(), params.getOrganization());
try {
AzureDevOpsServerUserProfile user = azureDevOpsServerApiClient.getUser(params.getToken());
return Optional.of(Pair.of(Boolean.TRUE, user.getIdentity().getAccountName()));
} catch (ScmItemNotFoundException | ScmBadRequestException e) {
} catch (ScmItemNotFoundException | ScmBadRequestException | ScmCommunicationException e) {
return Optional.empty();
}
} else {
Expand All @@ -198,7 +197,10 @@ public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params)
user = azureDevOpsApiClient.getUserWithPAT(params.getToken(), params.getOrganization());
}
return Optional.of(Pair.of(Boolean.TRUE, user.getEmailAddress()));
} catch (ScmItemNotFoundException | ScmBadRequestException | ScmUnauthorizedException e) {
} catch (ScmItemNotFoundException
| ScmBadRequestException
| ScmUnauthorizedException
| ScmCommunicationException e) {
return Optional.empty();
}
}
Expand Down

0 comments on commit d689ed0

Please sign in to comment.