Conversation
259113e to
4c865ce
Compare
|
/retest |
1 similar comment
|
/retest |
| } | ||
|
|
||
| public AzureDevOpsUrl withServerUrl(String serverUrl) { | ||
| this.serverUrl = serverUrl; |
There was a problem hiding this comment.
When use set serverUrl, then hostname is null, which is used later in getRepositoryLocation
There was a problem hiding this comment.
The hostName does not rely on serverUrl, we set it independently:
| if (!isValidScmServerUrl(params.getScmProviderUrl())) { | ||
| LOG.debug("not a valid url {} for current fetcher ", params.getScmProviderUrl()); | ||
| return Optional.empty(); | ||
| if (OAUTH_PROVIDER_NAME.equals(params.getScmProviderName())) { |
There was a problem hiding this comment.
Can we refactor this fuction?
For instance, move if (OAUTH_PROVIDER_NAME.equals(params.getScmProviderName())) { before if (!isValidScmServerUrl(params.getScmProviderUrl())) {
There was a problem hiding this comment.
We need to check if the token belongs to Azure DevOps SAAS or Server first. The isValidScmServerUrl function name is a bit misleading, so I renamed it.
| azureDevOpsApiClient.getUserWithPAT( | ||
| personalAccessToken.getToken(), personalAccessToken.getScmOrganization()); | ||
| return new GitUserData(user.getDisplayName(), user.getEmailAddress()); | ||
| if (personalAccessToken.getScmProviderUrl().equals("https://dev.azure.com")) { |
There was a problem hiding this comment.
We have AzureDevOps class for contants
| } catch (ScmUnauthorizedException e) { | ||
| return true; | ||
| // the error message is a JSON if it is a response from Gitlab. | ||
| return e.getMessage().startsWith("{"); |
There was a problem hiding this comment.
Do we really need this changes in context of azure?
There was a problem hiding this comment.
Yes, we need to specify the unauthorized exception as Azure also returns an unauthorized exception in this case.
There was a problem hiding this comment.
what is the response from Azure in this case?
There was a problem hiding this comment.
I moved the json validation check to a separate private function, enhanced the check with JSON parser and updated the Javadoc.
|
|
||
| private Optional<Matcher> getPatternMatcherByUrl(String url) { | ||
| String host = URI.create(url).getHost(); | ||
| Matcher matcher = compile(format(azureDevOpsPatternTemplate, host)).matcher(url); |
Check failure
Code scanning / CodeQL
Regular expression injection High
| if (matcher.matches()) { | ||
| return Optional.of(matcher); | ||
| } else { | ||
| matcher = compile(format(azureSSHDevOpsPatternTemplate, host)).matcher(url); |
Check failure
Code scanning / CodeQL
Regular expression injection High
| if (matcher.matches()) { | ||
| return Optional.of(matcher); | ||
| } else { | ||
| matcher = compile(format(azureSSHDevOpsServerPatternTemplate, host)).matcher(url); |
Check failure
Code scanning / CodeQL
Regular expression injection High
80c8b96 to
12721bc
Compare
...e/infrastructure/kubernetes/namespace/configurator/GitconfigAutomauntSecretConfigurator.java
Fixed
Show fixed
Hide fixed
...e/infrastructure/kubernetes/namespace/configurator/GitconfigAutomauntSecretConfigurator.java
Fixed
Show fixed
Hide fixed
cfaf300 to
95d556a
Compare
...e/infrastructure/kubernetes/namespace/configurator/GitconfigAutomauntSecretConfigurator.java
Fixed
Show fixed
Hide fixed
...e/infrastructure/kubernetes/namespace/configurator/GitconfigAutomauntSecretConfigurator.java
Fixed
Show fixed
Hide fixed
2e1f709 to
3531467
Compare
...-factory-azure-devops/src/test/resources/__files/azure-devops-server/rest/user/response.json
Outdated
Show resolved
Hide resolved
...i-factory-azure-devops/src/test/resources/__files/azure-devops/rest/user/email/response.json
Outdated
Show resolved
Hide resolved
...ore-api-factory-azure-devops/src/test/resources/__files/azure-devops/rest/user/response.json
Outdated
Show resolved
Hide resolved
| return true; | ||
| // Some Git providers e.g. Azure Devops Server, may return unauthorized exception on invalid | ||
| // API request, but Gitlab API returns unauthorized error message in JSON format, so to be | ||
| // sure that the URL belongs to Gitlab, we need to check if the error message is a valid | ||
| // JSON. | ||
| return isJsonValid(e.getMessage()); |
There was a problem hiding this comment.
@vinokurig I'm a bit lost with Gitlab change in general.
Could you clarify why are we changing AbstractGitlabUrlParser.java in the context of the Azure TFS onboarding? How come GitLab flow is affected by the Azure Devops Server ?
There was a problem hiding this comment.
When we resolve a factory url we iterate over provider implementations and check if the url corresponds to any known implemented provider.
In the Gitlab implementation, when we resolve a public Gitlab Server repo url but neither oauth is configured nor a PAT is added, we use the isApiRequestRelevant()function:
The function extracts the server url from the repository url and with this server url we make a test Gitlab Server API call. The idea is: if the test api call returns unauthorised error, it means that the extracted server url is a Gitlab Server url and we treat the repository url as a Gitlab Server url.
The problem is that Azure Devops Server Api returns unauthorized response on any invalid API request, so when we iterate the Azure repo url through the Gitlab implementation, the url is tested by the isApiRequestRelevant()function and according to the response status it becomes a Gitlab url.
To be able to distinguish the unauthorized response of Azure Devops Server url and Gitlab Server url, we check the error message format, if it is in JSON format, we can assume that the url is a Gitlab repo, but if the error message is a plain text, we continue the iteration because the url is an Azure Devops Server repo.
ibuziuk
left a comment
There was a problem hiding this comment.
@artaleks9 @dmytro-ndp folks, please provide your approval before merging as well. Looks like Gitlab test is failing right now (please make sure that all PR checks are merged before we merge)
|
@vinokurig: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@vinokurig : after the review of this feature demo, I can admit that adding |
|
@dmytro-ndp |
|
@vinokurig : hello verification of eclipse-che/che#23306 issue fix up has been passed. See test details below: Test scenario to check eclipse-che/che#23306 issue:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ibuziuk, SkorikSergey, vinokurig The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@vinokurig After adding token according to this documentation I have also started workspace from private repo GitHub Enterprise Server(OAuth accepted). Workspace started successfully but project was not cloned. After removing token from gitconfig works as expected. |
|
@vinokurig I think we should at very least mention this caveat in the docs |
|
Build 3.20 :: server_3.x/389: Console, Changes, Git Data |
|
Build 3.20 :: sync-to-downstream_3.x/8902: Console, Changes, Git Data |
|
Build 3.20 :: get-sources-rhpkg-container-build_3.x/9021: server : 3.x :: Failed in 66972204 : BREW:BUILD/STATUS:UNKNOWN |
Fix the build failure caused by merging #754


What does this PR do?
Depends on eclipse-che/che-dashboard#1313
Screenshot/screencast of this PR
What issues does this PR fix or reference?
fixes eclipse-che/che#23306
How to test this PR?
quay.io/eclipse/che-server:pr-754.Organizationinput to enter theCollectionname.See: workspace starts with the devfile resolve.
PR Checklist
As the author of this Pull Request I made sure that:
What issues does this PR fix or referenceandHow to test this PRcompletedRelease Notes
Reviewers
Reviewers, please comment how you tested the PR when approving it.