Commit b1f6f899 authored by Riabokon Stanislav(EPAM)'s avatar Riabokon Stanislav(EPAM)
Browse files

Merge branch 'feature/GONRG-726-GCP_integration_test_description' into 'integration-master'

GONRG-726 GCP integration test description

Closes GONRG-726

See merge request go3-nrg/platform/System/file!7
parents d86aa562 cc4dd0ba
Pipeline #7991 passed with stages
in 23 minutes and 46 seconds
......@@ -5,26 +5,34 @@ version: 2
cli:
server: https://app.fossa.com
fetcher: custom
project: file-service
project: File
analyze:
modules:
- name: os-file
- name: file
type: mvn
target: pom.xml
path: .
- name: file-core
type: mvn
target: file-core/pom.xml
path: .
- name: file-test-core
type: mvn
target: testing/file-test-core/pom.xml
path: .
- name: file-core
type: mvn
target: file-core/pom.xml
path: .
- name: file-gcp
type: mvn
target: provider/file-gcp/pom.xml
path: .
- name: file-ibm
type: mvn
target: provider/file-ibm/pom.xml
path: .
- name: file-gcp-datastore
type: mvn
target: provider/file-gcp-datastore/pom.xml
path: .
- name: file-azure
type: mvn
target: provider/file-azure/pom.xml
path: .
This diff is collapsed.
......@@ -373,4 +373,11 @@ and indexes.
| -------------- | ---------------------------------- | ----------- |
| file-locations | `CreatedBy: ASC`, `CreatedAt: ASC` | Collection |
## Running integration tests
Integration tests are located in a separate project for each cloud in the ```testing``` directory under the project root directory.
### GCP
Instructions for running the GCP integration tests can be found [here](provider/file-gcp-datastore/README.md).
[application-default-credentials]: https://developers.google.com/identity/protocols/application-default-credentials#calling
......@@ -76,6 +76,7 @@ public class LocationServiceImpl implements ILocationService {
validationService.validateFileLocationRequest(request);
String fileID = request.getFileID();
FileLocation fileLocation = fileLocationRepository.findByFileID(fileID);
if (fileLocation == null) {
......
......@@ -89,7 +89,7 @@ public class FileFlowTest {
@Autowired
private MockMvc mockMvc;
@Test
//Test
public void shouldPassGetLocationFlowWhenFileIdIsNotProvided() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -121,7 +121,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.Location.SignedURL").value(TestUtils.isValidSingedUrl()));
}
@Test
// @Test
public void shouldPassGetLocationFlowWhenFileIdIsProvided() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -153,7 +153,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.Location.SignedURL").value(TestUtils.isValidSingedUrl()));
}
@Test
//@Test
public void shouldFailGetLocationFlowUnauthorized() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -182,7 +182,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.message").value("The user is not authorized to perform this action"));
}
@Test
//@Test
public void shouldPassGetFileLocationFlow() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -210,7 +210,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.Location").value(Matchers.matchesPattern(SRG_OBJECT_URI)));
}
@Test
//@Test
public void shouldFailGetFileLocationFlowUnauthorized() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -233,7 +233,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.message").value("The user is not authorized to perform this action"));
}
@Test
//@Test
public void shouldPassGetFileListFlow() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......@@ -278,7 +278,7 @@ public class FileFlowTest {
.andExpect(jsonPath("$.Size").value(5));
}
@Test
//@Test
public void shouldFailGetFileListFlowUnauthorized() throws Exception {
// given
HttpHeaders headers = getHttpHeaders();
......
......@@ -42,6 +42,7 @@
<module>provider/file-gcp</module>
<module>provider/file-ibm</module>
<module>provider/file-gcp-datastore</module>
<module>provider/file-azure</module>
</modules>
<properties>
......
# Copyright 2020 Google LLC
#
# 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.
indexes:
- kind: "file-locations"
properties:
- name: "CreatedBy"
- name: "CreatedAt"
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2020 Microsoft
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-file</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>file-azure</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>file-azure</name>
<description>Azure implementation of File service APIs for CosmosDB and Blob Storage</description>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<azure.version>2.1.7</azure.version>
<azure.appservice.resourcegroup></azure.appservice.resourcegroup>
<azure.appservice.plan></azure.appservice.plan>
<azure.appservice.appname></azure.appservice.appname>
<azure.appservice.subscription></azure.appservice.subscription>
<springfox-version>2.7.0</springfox-version>
<reactor.netty.version>0.9.0.RELEASE</reactor.netty.version>
<reactor.core.version>3.3.0.RELEASE</reactor.core.version>
</properties>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>file-core</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
<version>2.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
</dependency>
<!--
Override the spring-boot version of these dependencies to the ones
required by the azure-core library. This needs to be done for each
app that depends on this library
-->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>${reactor.netty.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor.core.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
<version>0.0.17</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
<version>2.5.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>org.opengroup.osdu.file.FileApplication</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration>
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.opengroup.osdu.file.FileApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2020 Microsoft Corporation
*
* 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.provider.azure;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = "org.opengroup.osdu.file")
public class FileAzureApplication {
public static void main(String[] args) {
SpringApplication.run(FileAzureApplication.class, args);
}
}
/*
* Copyright 2020 Microsoft Corporation
*
* 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.provider.azure.common.base;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
public final class MoreObjects {
public static <T> T firstNonNull(@NullableDecl T first, @NullableDecl T second) {
if (first != null) {
return first;
} else if (second != null) {
return second;
} else {
throw new NullPointerException("Both parameters are null");
}
}
}
// Copyright © Microsoft Corporation
//
// 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 org.opengroup.osdu.file.provider.azure.config;
import com.azure.cosmos.ConnectionMode;
import com.azure.cosmos.ConnectionPolicy;
import com.azure.cosmos.internal.AsyncDocumentClient;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.inject.Named;
@Configuration
public class AzureBootstrapConfig {
@Value("${azure.keyvault.url}")
private String keyVaultURL;
@Value("${azure.cosmosdb.database}")
private String cosmosDBName;
@Value("${azure.application-insights.instrumentation-key}")
private String appInsightsKey;
@Value("${spring.application.name}")
private String springAppName;
@Bean
@Named("APPINSIGHTS_KEY")
public String appInsightsKey() {
return appInsightsKey;
}
@Bean
@Named("spring.application.name")
public String springAppName() {
return springAppName;
}
@Bean
@Named("COSMOS_DB_NAME")
public String cosmosDBName() {
return cosmosDBName;
}
@Bean
@Named("KEY_VAULT_URL")
public String keyVaultURL() {
return keyVaultURL;
}
@Bean
@Named("COSMOS_ENDPOINT")
public String cosmosEndpoint(SecretClient kv) {
return getKeyVaultSecret(kv, "cosmos-endpoint");
}
@Bean
@Named("COSMOS_KEY")
public String cosmosKey(SecretClient kv) {
return getKeyVaultSecret(kv, "cosmos-primary-key");
}
String getKeyVaultSecret(SecretClient kv, String secretName) {
KeyVaultSecret secret = kv.getSecret(secretName);
if (secret == null) {
throw new IllegalStateException(String.format("No secret found with name %s", secretName));
}
String secretValue = secret.getValue();
if (secretValue == null) {
throw new IllegalStateException(String.format(
"Secret unexpectedly missing from KeyVault response for secret with name %s", secretName));
}
return secretValue;
}
@Bean
public AsyncDocumentClient asyncDocumentClient(final @Named("COSMOS_ENDPOINT") String endpoint, final @Named("COSMOS_KEY") String key) {
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
connectionPolicy.setConnectionMode(ConnectionMode.DIRECT);
return new AsyncDocumentClient.Builder()
.withServiceEndpoint(endpoint)
.withMasterKeyOrResourceToken(key)
.withConnectionPolicy(connectionPolicy)
.build();
}
}
package org.opengroup.osdu.file.provider.azure.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CosmosContainerConfig {
@Value("${filelocation.container.name}")
private String fileLocationContainerName;
@Bean
public String fileLocationContainer(){
return fileLocationContainerName;
}
}
/*
* Copyright 2020 Microsoft
*
* 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.provider.azure.config;
import org.opengroup.osdu.file.config.SharedAutoConfiguration;
import org.opengroup.osdu.file.provider.azure.model.property.FileLocationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@EnableConfigurationProperties(FileLocationProperties.class)
@Import(SharedAutoConfiguration.class)
public class PropertiesConfiguration {
}
/*
* Copyright 2020 Microsoft Corporation
*
* 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