Skip to content

Commit 7681e71

Browse files
committed
fixup! Add Azure DevOps Server support
1 parent 9e52d56 commit 7681e71

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

wsmaster/che-core-api-factory-azure-devops/src/main/java/org/eclipse/che/api/factory/server/azure/devops/AzureDevOpsPersonalAccessTokenFetcher.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,15 @@ public Optional<Boolean> isValid(PersonalAccessToken personalAccessToken) {
172172
}
173173

174174
@Override
175-
public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params)
176-
throws ScmCommunicationException {
175+
public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params) {
177176
if (!isValidAzureDevOpsSAASUrl(params.getScmProviderUrl())) {
178177
if (OAUTH_PROVIDER_NAME.equals(params.getScmProviderName())) {
179178
AzureDevOpsServerApiClient azureDevOpsServerApiClient =
180179
new AzureDevOpsServerApiClient(params.getScmProviderUrl(), params.getOrganization());
181180
try {
182181
AzureDevOpsServerUserProfile user = azureDevOpsServerApiClient.getUser(params.getToken());
183182
return Optional.of(Pair.of(Boolean.TRUE, user.getIdentity().getAccountName()));
184-
} catch (ScmItemNotFoundException | ScmBadRequestException e) {
183+
} catch (ScmItemNotFoundException | ScmBadRequestException | ScmCommunicationException e) {
185184
return Optional.empty();
186185
}
187186
} else {
@@ -198,7 +197,10 @@ public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params)
198197
user = azureDevOpsApiClient.getUserWithPAT(params.getToken(), params.getOrganization());
199198
}
200199
return Optional.of(Pair.of(Boolean.TRUE, user.getEmailAddress()));
201-
} catch (ScmItemNotFoundException | ScmBadRequestException | ScmUnauthorizedException e) {
200+
} catch (ScmItemNotFoundException
201+
| ScmBadRequestException
202+
| ScmUnauthorizedException
203+
| ScmCommunicationException e) {
202204
return Optional.empty();
203205
}
204206
}

wsmaster/che-core-api-factory-azure-devops/src/test/resources/__files/azure-devops-server/rest/user/response.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"identity": {
33
"AccountName": "Azure DevOps"
44
}
5-
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"values": [{"email" : "[email protected]"}]
3-
}
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"displayName": "Display Name",
33
"emailAddress": "[email protected]"
4-
}
4+
}

0 commit comments

Comments
 (0)