-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into CB-5292-keep-alive-all-drivers
- Loading branch information
Showing
165 changed files
with
2,031 additions
and
2,072 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SET mypath=%~dp0 | ||
|
||
.\..\idea-rcp-launch-config-generator\runGenerator.cmd -f %mypath% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./../idea-rcp-launch-config-generator/runGenerator.sh -f $(dirname "$0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
workspaceName=cloudbeaver | ||
featuresPaths=\ | ||
dbeaver/features;\ | ||
cloudbeaver/server/features; | ||
bundlesPaths=\ | ||
dbeaver-common/modules;\ | ||
dbeaver/plugins;\ | ||
cloudbeaver/server/bundles; | ||
repositories=\ | ||
https://p2.dev.dbeaver.com/eclipse-repo/;\ | ||
https://download.eclipse.org/releases/${eclipse-version}/; | ||
testBundles=\ | ||
org.junit;\ | ||
org.mockito.mockito-core;\ | ||
junit-jupiter-api;\ | ||
org.opentest4j | ||
productsPaths=\ | ||
dbeaver/product/community/DBeaver.product;\ | ||
cloudbeaver/server/product/web-server/CloudbeaverServer.product:../../opt/cloudbeaver; | ||
ideaConfigurationFilesPaths=\ | ||
dbeaver/.ide/idea/copyright;\ | ||
dbeaver/.ide/idea/scopes; | ||
testBundlePaths=\ | ||
dbeaver/test;\ | ||
cloudbeaver/server/test; | ||
additionalModuleRoots=\ | ||
opt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/test/WebGQLClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.cloudbeaver.test; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import org.jkiss.code.NotNull; | ||
import org.jkiss.code.Nullable; | ||
import org.jkiss.dbeaver.DBException; | ||
import org.jkiss.dbeaver.model.data.json.JSONUtils; | ||
import org.jkiss.dbeaver.utils.GeneralUtils; | ||
|
||
import java.net.URI; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* GraphQL client for tests. | ||
*/ | ||
public class WebGQLClient { | ||
private static final Gson gson = new GsonBuilder() | ||
.setPrettyPrinting() | ||
.create(); | ||
public static final String GQL_AUTHENTICATE = """ | ||
query authLogin($provider: ID!, $configuration: ID, $credentials: Object, $linkUser: Boolean, $forceSessionsLogout: Boolean) { | ||
result: authLogin( | ||
provider: $provider | ||
configuration: $configuration | ||
credentials: $credentials | ||
linkUser: $linkUser | ||
forceSessionsLogout: $forceSessionsLogout | ||
) { | ||
authId | ||
authStatus | ||
} | ||
}"""; | ||
|
||
@NotNull | ||
private final HttpClient httpClient; | ||
@NotNull | ||
private final String apiUrl; | ||
|
||
public WebGQLClient(@NotNull HttpClient httpClient, @NotNull String apiUrl) { | ||
this.httpClient = httpClient; | ||
this.apiUrl = apiUrl; | ||
} | ||
|
||
/** | ||
* Sends GraphQL request without additional headers | ||
* | ||
* @param query GraphQL query | ||
* @param variables GraphQL query variables | ||
* @return GraphQL response | ||
*/ | ||
@NotNull | ||
public <T> T sendQuery(@NotNull String query, @Nullable Map<String, Object> variables) throws Exception { | ||
return sendQueryWithHeaders(query, variables, List.of()); | ||
} | ||
|
||
/** | ||
* Sends GraphQL request without additional headers | ||
* | ||
* @param query GraphQL query | ||
* @param variables GraphQL query variables | ||
* @param headers HTTP request headers | ||
* @return GraphQL response | ||
*/ | ||
@NotNull | ||
public <T> T sendQueryWithHeaders( | ||
@NotNull String query, | ||
@Nullable Map<String, Object> variables, | ||
@NotNull List<String> headers | ||
) throws Exception { | ||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder() | ||
.uri(URI.create(apiUrl)) | ||
.POST(HttpRequest.BodyPublishers.ofString(makeGQLRequest(query, variables))) | ||
.setHeader("TE-Client-Version", GeneralUtils.getMajorVersion()) | ||
.header("Content-Type", "application/json"); | ||
if (!headers.isEmpty()) { | ||
requestBuilder.headers(headers.toArray(String[]::new)); | ||
} | ||
HttpRequest request = requestBuilder.build(); | ||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); | ||
Map<String, Object> body = gson.fromJson( | ||
response.body(), | ||
JSONUtils.MAP_TYPE_TOKEN | ||
); | ||
if (body.containsKey("errors")) { | ||
String message = JSONUtils.getString(JSONUtils.getObjectList(body, "errors").get(0), "message"); | ||
throw new DBException(message); | ||
} | ||
// graphql response will be in "data" key | ||
return (T) JSONUtils.getObject(body, "data").get("result"); | ||
} | ||
|
||
@NotNull | ||
private String makeGQLRequest(@NotNull String text, @Nullable Map<String, Object> variables) { | ||
Map<String, Object> request = new LinkedHashMap<>(); | ||
request.put("query", text); | ||
if (variables != null && !variables.isEmpty()) { | ||
request.put("variables", variables); | ||
} | ||
|
||
return gson.toJson(request, Map.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.