Commit 24ec4cb3 authored by Dmitriy Rudko's avatar Dmitriy Rudko 💬
Browse files

Merge branch 'integration-test' into 'master'

Integration test (GONRG-540)

See merge request !8
parents 8f2da346 481011c0
Pipeline #6547 passed with stages
in 17 minutes and 52 seconds
......@@ -5,7 +5,7 @@ variables:
OSDU_GCP_BUILD_SUBDIR: provider/file-gcp-datastore
# OSDU_GCP_INT_TEST_SUBDIR: testing/file-test-core
OSDU_GCP_SERVICE: file
OSDU_GCP_BUCKET: nice-etching-277309-file
OSDU_GCP_BUCKET: nice-etching-277309-file
OSDU_GCP_NAMESPACE: osdu-namespace
OSDU_GCP_VPC_CONNECTOR: osdu-connector
OSDU_GCP_RECORDS_ROOT_URL: https://os-storage-dot-nice-etching-277309.uc.r.appspot.com/api/storage/v2
......@@ -13,7 +13,7 @@ variables:
OSDU_GCP_USER_ID: common-user
OSDU_GCP_APPLICATION_NAME: os-file
OSDU_GCP_SERVICE_ACCOUNT: osdu-gcp-sa@nice-etching-277309.iam.gserviceaccount.com
OSDU_GCP_ENV_VARS: OSDU_ENTITLEMENTS_URL=$OSDU_GCP_ENTITLEMENTS_URL,FILE_LOCATION_BUCKET_NAME=$OSDU_GCP_BUCKET,SPRING_CLOUD_GCP_DATASTORE_NAMESPACE=$OSDU_GCP_NAMESPACE,FILE_LOCATION_USER_ID=$OSDU_GCP_USER_ID,GCP_RECORDS_ROOT_URL=$OSDU_GCP_RECORDS_ROOT_URL --vpc-connector=$OSDU_GCP_VPC_CONNECTOR
OSDU_GCP_ENV_VARS: OSDU_ENTITLEMENTS_URL=$OSDU_GCP_ENTITLEMENTS_URL,FILE_LOCATION_BUCKET_NAME=$OSDU_GCP_BUCKET,SPRING_CLOUD_GCP_DATASTORE_NAMESPACE=$OSDU_GCP_NAMESPACE,FILE_LOCATION_USER_ID=$OSDU_GCP_USER_ID,GCP_RECORDS_ROOT_URL=$OSDU_GCP_RECORDS_ROOT_URL --vpc-connector=$OSDU_GCP_VPC_CONNECTOR
OSDU_GCP_ENVIRONMENT: dev
OSDU_GCP_PROJECT: nice-etching-277309
OSDU_GCP_TENANT_NAME: osdu
......@@ -29,7 +29,7 @@ include:
- project: 'osdu/platform/ci-cd-pipelines'
ref: 'master'
file: 'build/maven.yml'
- project: "osdu/platform/ci-cd-pipelines"
ref: 'master'
file: "cloud-providers/ibm.yml"
......@@ -37,11 +37,11 @@ include:
- project: 'osdu/platform/ci-cd-pipelines'
ref: 'master'
file: 'scanners/gitlab-ultimate.yml'
- project: 'osdu/platform/ci-cd-pipelines'
ref: 'master'
file: 'scanners/fossa.yml'
- project: 'osdu/platform/ci-cd-pipelines'
ref: 'master'
file: 'publishing/pages.yml'
......
......@@ -23,8 +23,11 @@ The following software have components provided under the terms of this license:
- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/)
- Apache HttpAsyncClient (from http://hc.apache.org/httpcomponents-asyncclient)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga)
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga)
- Apache HttpCore NIO (from http://hc.apache.org/httpcomponents-core-ga)
- Apache HttpCore NIO (from http://hc.apache.org/httpcomponents-core-ga)
- Apache Log4j API (from )
- Apache Log4j to SLF4J Adapter (from )
- AssertJ fluent assertions (from )
......@@ -38,6 +41,7 @@ The following software have components provided under the terms of this license:
- Commons Lang (from http://commons.apache.org/lang/)
- Elastic JNA Distribution (from https://github.com/java-native-access/jna)
- Elasticsearch: 5.0.0-alpha5 (from https://github.com/elastic/elasticsearch)
- Elasticsearch: 5.0.0-alpha5 (from https://github.com/elastic/elasticsearch)
- Feign Core (from )
- Feign Hystrix (from )
- Feign SLF4J (from )
......@@ -52,11 +56,13 @@ The following software have components provided under the terms of this license:
- Google Cloud NIO (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-contrib/google-cloud-nio)
- Google Cloud Storage (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-storage)
- Google HTTP Client Library for Java (from https://github.com/google/google-http-java-client.git)
- Google HTTP Client Library for Java (from https://github.com/google/google-http-java-client.git)
- Google OAuth Client Library for Java (from )
- Gson (from https://github.com/google/gson)
- Guava InternalFutureFailureAccess and InternalFutures (from )
- Guava ListenableFuture only (from )
- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git)
- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git)
- HPPC Collections (from http://labs.carrotsearch.com)
- Hibernate Validator Engine (from )
- J2ObjC Annotations (from https://github.com/google/j2objc/)
......@@ -68,12 +74,20 @@ The following software have components provided under the terms of this license:
- Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://github.com/google/google-http-java-client.git/google-http-client-jackson2)
- Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary)
- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310)
- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-annotations (from http://github.com/FasterXML/jackson)
- Jackson-core (from https://github.com/FasterXML/jackson-core)
- Jackson-core (from https://github.com/FasterXML/jackson-core)
- Jackson-dataformat-Smile (from http://github.com/FasterXML/jackson-dataformat-smile)
- Jackson-dataformat-Smile (from http://github.com/FasterXML/jackson-dataformat-smile)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson)
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson)
- Jackson-datatype-jdk8 (from )
- Jackson-datatype-jdk8 (from )
- Jackson-module-parameter-names (from )
- Jackson-module-parameter-names (from )
- Jakarta Bean Validation API (from https://beanvalidation.org)
- Jakarta Bean Validation API (from https://beanvalidation.org)
- Javassist (from http://www.javassist.org/)
- Joda-Time (from http://www.joda.org/joda-time/)
......@@ -96,10 +110,16 @@ The following software have components provided under the terms of this license:
- MapStruct Core (from )
- Mockito (from http://mockito.org)
- Netty/Buffer (from http://netty.io/)
- Netty/Buffer (from http://netty.io/)
- Netty/Codec (from )
- Netty/Codec (from )
- Netty/Common (from )
- Netty/Common (from )
- Netty/Handler (from )
- Netty/Handler (from )
- Netty/Resolver (from )
- Netty/Resolver (from )
- Netty/Transport (from http://netty.io/)
- Netty/Transport (from http://netty.io/)
- Objenesis (from http://objenesis.org)
- Open Feign Forms Core (from )
......@@ -108,24 +128,36 @@ The following software have components provided under the terms of this license:
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from )
- SnakeYAML (from http://www.snakeyaml.org)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
- Spring Beans (from https://github.com/spring-projects/spring-framework)
- Spring Beans (from https://github.com/spring-projects/spring-framework)
- Spring Boot (from http://projects.spring.io/spring-boot/)
- Spring Boot (from http://projects.spring.io/spring-boot/)
- Spring Boot AOP Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/)
- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/)
- Spring Boot Configuration Processor (from http://projects.spring.io/spring-boot/)
- Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json)
- Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json)
- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Security Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Test (from http://projects.spring.io/spring-boot/)
- Spring Boot Test Auto-Configure (from http://projects.spring.io/spring-boot/)
- Spring Boot Test Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Tomcat Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Tomcat Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/)
- Spring Cloud Commons (from )
- Spring Cloud Context (from )
- Spring Cloud GCP Autoconfigure Module (from )
......@@ -137,30 +169,40 @@ The following software have components provided under the terms of this license:
- Spring Cloud OpenFeign Core (from )
- Spring Cloud Starter OpenFeign (from https://projects.spring.io/spring-cloud)
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
- Spring Context (from https://github.com/spring-projects/spring-framework)
- Spring Context (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Data Core (from )
- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework)
- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework)
- Spring TestContext Framework (from https://github.com/spring-projects/spring-framework)
- Spring Transaction (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web MVC (from https://github.com/spring-projects/spring-framework)
- Spring Web MVC (from https://github.com/spring-projects/spring-framework)
- T-Digest (from https://github.com/tdunning/t-digest)
- aggs-matrix-stats (from https://github.com/elastic/elasticsearch)
- aggs-matrix-stats (from https://github.com/elastic/elasticsearch)
- archaius-core (from https://github.com/Netflix/archaius)
- cli (from https://github.com/elastic/elasticsearch)
- cli (from https://github.com/elastic/elasticsearch)
- com.google.api.grpc:proto-google-cloud-firestore-v1beta1 (from https://github.com/googleapis/googleapis)
- com.google.api.grpc:proto-google-common-protos (from https://github.com/googleapis/googleapis)
- com.google.api.grpc:proto-google-iam-v1 (from https://github.com/googleapis/googleapis)
- compiler (from http://github.com/spullara/mustache.java)
- datastore-v1-proto-client (from )
- elasticsearch-core (from https://github.com/elastic/elasticsearch)
- elasticsearch-core (from https://github.com/elastic/elasticsearch)
- error-prone annotations (from )
- hystrix-core (from https://github.com/Netflix/Hystrix)
- io.grpc:grpc-alts (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-api (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-auth (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-context (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-context (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-core (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-grpclb (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-netty-shaded (from https://github.com/grpc/grpc-java)
......@@ -168,7 +210,11 @@ The following software have components provided under the terms of this license:
- io.grpc:grpc-protobuf-lite (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-stub (from https://github.com/grpc/grpc-java)
- jackson-databind (from http://github.com/FasterXML/jackson)
- jackson-databind (from http://github.com/FasterXML/jackson)
- javax.inject (from http://code.google.com/p/atinject/)
- jersey-core (from )
- jsr311-api (from https://jsr311.dev.java.net)
- lang-mustache (from https://github.com/elastic/elasticsearch)
- lang-mustache (from https://github.com/elastic/elasticsearch)
- lettuce (from http://github.com/mp911de/lettuce/wiki)
- org.apiguardian:apiguardian-api (from https://github.com/apiguardian-team/apiguardian)
......@@ -176,15 +222,20 @@ The following software have components provided under the terms of this license:
- org.opentest4j:opentest4j (from https://github.com/ota4j-team/opentest4j)
- org.xmlunit:xmlunit-core (from http://www.xmlunit.org/)
- parent-join (from https://github.com/elastic/elasticsearch)
- parent-join (from https://github.com/elastic/elasticsearch)
- perfmark:perfmark-api (from https://github.com/perfmark/perfmark)
- proto-google-cloud-datastore-v1 (from https://github.com/googleapis/api-client-staging)
- proto-google-cloud-firestore-admin-v1 (from https://repo1.maven.org/maven2/com/google/api/grpc/proto-google-cloud-firestore-admin-v1)
- proto-google-cloud-firestore-v1 (from https://repo1.maven.org/maven2/com/google/api/grpc/proto-google-cloud-firestore-v1)
- rank-eval (from https://github.com/elastic/elasticsearch)
- rank-eval (from https://github.com/elastic/elasticsearch)
- rest (from https://github.com/elastic/elasticsearch)
- rest (from https://github.com/elastic/elasticsearch)
- rest-high-level (from https://github.com/elastic/elasticsearch)
- rest-high-level (from https://github.com/elastic/elasticsearch)
- rxjava (from https://github.com/ReactiveX/RxJava)
- secure-sm (from https://github.com/elastic/elasticsearch)
- secure-sm (from https://github.com/elastic/elasticsearch)
- spring-cloud-netflix-ribbon (from )
- spring-cloud-starter (from https://projects.spring.io/spring-cloud)
- spring-security-config (from http://spring.io/spring-security)
......@@ -196,9 +247,13 @@ The following software have components provided under the terms of this license:
- swagger-annotations (from )
- swagger-jaxrs (from )
- tomcat-embed-core (from http://tomcat.apache.org/)
- tomcat-embed-core (from http://tomcat.apache.org/)
- tomcat-embed-el (from http://tomcat.apache.org/)
- tomcat-embed-el (from http://tomcat.apache.org/)
- tomcat-embed-websocket (from http://tomcat.apache.org/)
- tomcat-embed-websocket (from http://tomcat.apache.org/)
- x-content (from https://github.com/elastic/elasticsearch)
- x-content (from https://github.com/elastic/elasticsearch)
========================================================================
BSD-2-Clause
......@@ -210,6 +265,7 @@ The following software have components provided under the terms of this license:
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- GAX (Google Api eXtensions) (from https://github.com/googleapis)
- Hamcrest (from http://hamcrest.org/JavaHamcrest/)
- Hamcrest Core (from http://hamcrest.org/)
- Lucene Common Analyzers (from )
- ThreeTen backport (from https://www.threeten.org/threetenbp)
......@@ -228,6 +284,7 @@ The following software have components provided under the terms of this license:
- Google Auth Library for Java - Credentials (from )
- Google Auth Library for Java - OAuth2 HTTP (from )
- Hamcrest (from http://hamcrest.org/JavaHamcrest/)
- Hamcrest Core (from http://hamcrest.org/)
- JavaBeans Activation Framework API jar (from )
- Lucene Common Analyzers (from )
- Lucene Core (from )
......@@ -237,6 +294,7 @@ The following software have components provided under the terms of this license:
- Reflections (from http://github.com/ronmamo/reflections)
- SnakeYAML (from http://www.snakeyaml.org)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- ThreeTen backport (from https://www.threeten.org/threetenbp)
- jakarta.xml.bind-api (from )
......@@ -253,12 +311,16 @@ CDDL-1.0
The following software have components provided under the terms of this license:
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
- jersey-client (from )
- jersey-core (from )
- jsr311-api (from https://jsr311.dev.java.net)
========================================================================
CDDL-1.1
========================================================================
The following software have components provided under the terms of this license:
- tomcat-embed-core (from http://tomcat.apache.org/)
- tomcat-embed-core (from http://tomcat.apache.org/)
========================================================================
......@@ -267,6 +329,7 @@ EPL-1.0
The following software have components provided under the terms of this license:
- AspectJ weaver (from http://www.aspectj.org)
- JUnit (from http://junit.org)
- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/)
- Logback Classic Module (from )
- Logback Core Module (from )
......@@ -298,6 +361,9 @@ The following software have components provided under the terms of this license:
- Commons Lang (from http://commons.apache.org/lang/)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
- jersey-client (from )
- jersey-core (from )
- tomcat-embed-core (from http://tomcat.apache.org/)
- tomcat-embed-core (from http://tomcat.apache.org/)
========================================================================
......@@ -315,6 +381,9 @@ The following software have components provided under the terms of this license:
- Checker Qual (from https://checkerframework.org)
- jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
- jersey-client (from )
- jersey-core (from )
- tomcat-embed-core (from http://tomcat.apache.org/)
- tomcat-embed-core (from http://tomcat.apache.org/)
========================================================================
......@@ -324,6 +393,8 @@ The following software have components provided under the terms of this license:
- Project Lombok (from https://projectlombok.org)
- jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca)
- jersey-client (from )
- jersey-core (from )
========================================================================
LGPL-2.1-only
......@@ -358,15 +429,19 @@ The following software have components provided under the terms of this license:
- Animal Sniffer Annotations (from )
- Bouncy Castle Provider (from http://www.bouncycastle.org/java.html)
- Checker Qual (from https://checkerframework.org)
- Checker Qual (from https://checkerframework.org)
- JOpt Simple (from http://pholser.github.io/jopt-simple)
- JUL to SLF4J bridge (from http://www.slf4j.org)
- JUL to SLF4J bridge (from http://www.slf4j.org)
- Java JWT (from http://www.jwt.io)
- Lucene Core (from )
- Lucene Sandbox (from )
- Mockito (from http://mockito.org)
- Netty/Common (from )
- Netty/Common (from )
- Project Lombok (from https://projectlombok.org)
- SLF4J API Module (from http://www.slf4j.org)
- SLF4J API Module (from http://www.slf4j.org)
- mockito-junit-jupiter (from https://github.com/mockito/mockito)
- spring-security-core (from http://spring.io/spring-security)
- spring-security-crypto (from http://spring.io/spring-security)
......@@ -400,6 +475,13 @@ The following software have components provided under the terms of this license:
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
========================================================================
SPL-1.0
========================================================================
The following software have components provided under the terms of this license:
- Checker Qual (from https://checkerframework.org)
========================================================================
WTFPL
========================================================================
......@@ -415,10 +497,12 @@ The following software have components provided under the terms of this license:
- Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html)
- Bouncy Castle Provider (from http://www.bouncycastle.org/java.html)
- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git)
- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git)
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Project Lombok (from https://projectlombok.org)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
========================================================================
unknown
......
<!--
~ Copyright 2020 Google LLC
~ Copyright 2020 EPAM Systems, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
......@@ -37,6 +38,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
<os-core-common.version>0.3.5</os-core-common.version>
</properties>
<dependencyManagement>
......@@ -53,10 +55,25 @@
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${os-core-common.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
......
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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
*
* https://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 org.opengroup.osdu.file;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import java.io.IOException;
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.ws.rs.core.MediaType;
import org.opengroup.osdu.file.apitest.Config;
public abstract class HttpClient {
protected static String accessToken;
protected static String noDataAccessToken;
public abstract String getAccessToken() throws IOException;
public abstract String getNoDataAccessToken() throws IOException;
public ClientResponse send(String path, String httpMethod, Map<String, String> headers,
String requestBody)
throws Exception {
Client client = this.getClient();
String mergedURL = new URL(Config.getFileServiceHost() + path).toString();
System.out.println(String.format("calling %s API:%s", httpMethod, mergedURL));
System.out.println(String.format("request body:%s", requestBody));
if (requestBody != null) {
headers.put("Content-Length", Long.toString(requestBody.length()));
} else {
headers.put("Content-Length", "0");
}
WebResource webResource = client.resource(mergedURL);
WebResource.Builder builder = webResource.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON);
headers.forEach(builder::header);
return builder.method(httpMethod, ClientResponse.class, requestBody);
}
private Client getClient() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}};
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
throw new Exception();
}
return Client.create();
}
}
......@@ -21,8 +21,8 @@ import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.DisplayNameGenerator;
/**
* JUnit display name generator. It replaces a "camelCase" name
* by "Capitalized Whitespace Separated" name.
* JUnit display name generator. It replaces a "camelCase" name by "Capitalized Whitespace
* Separated" name.
*/
public class ReplaceCamelCase extends DisplayNameGenerator.Standard {
......
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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
*
* https://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 org.opengroup.osdu.file;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.opengroup.osdu.file.apitest.Config;
import org.opengroup.osdu.file.util.CloudStorageUtil;
public abstract class TestBase {
protected static HttpClient client;
protected static CloudStorageUtil cloudStorageUtil;
public static Map<String, String> getCommonHeader() throws IOException {
return getHeaders(Config.getDataPartitionId(), client.getAccessToken());
}
public static Map<String, String> getHeaders(String dataPartition, String token) {
Map<String, String> headers = new HashMap<>();
if (dataPartition != null && !dataPartition.isEmpty()) {
headers.put("Data-Partition-Id", dataPartition);
}
if (token != null && !token.isEmpty()) {
headers.put("Authorization", token);
}
return headers;
}
}
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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
*
* https://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 org.opengroup.osdu.file.apitest;
import java.util.TimeZone;
public class Config {
private static final String FILE_SERVICE_HOST = "";
private static final String INTEGRATION_TESTER = "";
private static final String NO_DATA_ACCESS_TESTER = "";
private static final String TARGET_AUDIENCE = "";
private static final String DATA_PARTITION_ID = "";
private static final String USER_ID = "";
// Storage time zone id, example = UTC+0
private static final String TIME_ZONE = TimeZone.getDefault().getID();
public static String getFileServiceHost() {
return getEnvironmentVariableOrDefaultValue("FILE_SERVICE_HOST", FILE_SERVICE_HOST);
}
public static String getIntegrationTester() {
return getEnvironmentVariableOrDefaultValue("INTEGRATION_TESTER", INTEGRATION_TESTER);
}
public static String getNoAccessTester() {
return getEnvironmentVariableOrDefaultValue("NO_DATA_ACCESS_TESTER", NO_DATA_ACCESS_TESTER);
}
public static String getTargetAudience() {
return getEnvironmentVariableOrDefaultValue("TARGET_AUDIENCE", TARGET_AUDIENCE);
}
public static String getDataPartitionId() {
return getEnvironmentVariableOrDefaultValue("DATA_PARTITION_ID", DATA_PARTITION_ID);
}
public static String getUserId() {
return getEnvironmentVariableOrDefaultValue("USER_ID", USER_ID);
}
public static String getTimeZone() {
return getEnvironmentVariableOrDefaultValue("TIME_ZONE", TIME_ZONE);
}
private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) {
String environmentVariable = getEnvironmentVariable(key);
if (environmentVariable == null) {
environmentVariable = defaultValue;
}
return environmentVariable;
}
private static String getEnvironmentVariable(String propertyKey) {
return System.getProperty(propertyKey, System.getenv(propertyKey));
}