diff --git a/NOTICE b/NOTICE index 11aa6a4a79874cd381ada113a573b1b0a830b028..2d0d130ef1c2fc8dda6e40c436cd0baec0f2b0f1 100644 --- a/NOTICE +++ b/NOTICE @@ -473,11 +473,9 @@ The following software have components provided under the terms of this license: - Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#) - Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/) - Spring Boot Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty) -- Spring Boot Security 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 Validation Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-validation) - Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) @@ -622,6 +620,8 @@ The following software have components provided under the terms of this license: - spring-boot-starter-jersey (from https://spring.io/projects/spring-boot) - spring-boot-starter-json (from https://spring.io/projects/spring-boot) - spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) +- spring-boot-starter-security (from https://spring.io/projects/spring-boot) +- spring-boot-starter-test (from https://spring.io/projects/spring-boot) - spring-boot-starter-tomcat (from https://spring.io/projects/spring-boot) - spring-boot-starter-web (from https://spring.io/projects/spring-boot) - spring-security-config (from https://spring.io/projects/spring-security) diff --git a/README.md b/README.md index 724f7df4cd11d492bcdffbc8005551e83c4a1218..8bfcb90b5e426329e082c09d3ef9aeb0ad8b23dc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,4 @@ running the `os-indexer` Azure implementation ## GCP Implementation -All documentation for the GCP implementation of `os-indexer` lives [here](./provider/indexer-gcp/README.md) - - +All documentation for the GCP implementation of `os-indexer` lives [here](./provider/indexer-gcp/README.md) \ No newline at end of file diff --git a/docs/tutorial/IndexerService.md b/docs/tutorial/IndexerService.md index fdd258cee3b0d64921cfd8aa7b451101d35d2e9d..9966f7cbbfc0a23fcc0fac4bc326431f23801b2f 100644 --- a/docs/tutorial/IndexerService.md +++ b/docs/tutorial/IndexerService.md @@ -6,6 +6,7 @@ - [Reindex <a name="reindex"></a>](#reindex) - [Schema Service adoption <a name="schema-service-adoption"></a>](#schema-service-adoption) - [R3 Schema Support <a name="r3-schema-support"></a>](#r3-schema-support) +- [Version info endpoint](#version-info-endpoint) ##Introduction <a name="introduction"></a> @@ -185,3 +186,38 @@ data-partition-id: opendes ``` [Back to table of contents](#TOC) +## Version info endpoint +For deployment available public `/info` endpoint, which provides build and git related information. +#### Example response: +```json +{ + "groupId": "org.opengroup.osdu", + "artifactId": "storage-gcp", + "version": "0.10.0-SNAPSHOT", + "buildTime": "2021-07-09T14:29:51.584Z", + "branch": "feature/GONRG-2681_Build_info", + "commitId": "7777", + "commitMessage": "Added copyright to version info properties file", + "connectedOuterServices": [ + { + "name": "elasticSearch", + "version":"..." + }, + { + "name": "postgresSql", + "version":"..." + }, + { + "name": "redis", + "version":"..." + } + ] +} +``` +This endpoint takes information from files, generated by `spring-boot-maven-plugin`, +`git-commit-id-plugin` plugins. Need to specify paths for generated files to matching +properties: +- `version.info.buildPropertiesPath` +- `version.info.gitPropertiesPath` + +[Back to table of contents](#TOC) \ No newline at end of file diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/api/InfoApi.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/api/InfoApi.java new file mode 100644 index 0000000000000000000000000000000000000000..c9e7b6b15b62775df9cca6ecbdb26cbf63f8a58a --- /dev/null +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/api/InfoApi.java @@ -0,0 +1,40 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 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.indexer.api; + +import java.io.IOException; +import org.opengroup.osdu.core.common.info.VersionInfoBuilder; +import org.opengroup.osdu.core.common.model.info.VersionInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping +public class InfoApi { + + @Autowired + private VersionInfoBuilder versionInfoBuilder; + + @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) + public VersionInfo info() throws IOException { + return versionInfoBuilder.buildVersionInfo(); + } +} \ No newline at end of file diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceImpl.java index 6cefb9bca8b6090d3ff1f807da91050aab6ace3b..46e570767ee8a1676aa3119723fcf147276ebc6b 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceImpl.java @@ -14,11 +14,15 @@ package org.opengroup.osdu.indexer.service; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.apache.http.HttpStatus; import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService; import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository; import org.opengroup.osdu.core.common.provider.interfaces.IElasticCredentialsCache; import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService; @@ -31,7 +35,8 @@ public class ElasticSettingServiceImpl implements IElasticSettingService { @Inject private TenantInfo tenantInfo; - + @Inject + private javax.inject.Provider<ITenantInfoService> tenantInfoServiceProvider; @Inject private IElasticRepository elasticRepository; @Inject @@ -43,18 +48,33 @@ public class ElasticSettingServiceImpl implements IElasticSettingService { @Override public ClusterSettings getElasticClusterInformation() { + return getClusterSettingsByTenantInfo(tenantInfo); + } + + @Override + public Map<String, ClusterSettings> getAllClustersSettings() { + List<TenantInfo> tenantInfos = tenantInfoServiceProvider.get().getAllTenantInfos(); + return tenantInfos.stream() + .collect(Collectors.toMap(TenantInfo::getDataPartitionId, + this::getClusterSettingsByTenantInfo)); + } + + private ClusterSettings getClusterSettingsByTenantInfo(TenantInfo tenantInfo) { + String cacheKey = String.format("%s-%s", configurationProperties.getGaeService(), + tenantInfo.getName()); - String cacheKey = String.format("%s-%s", configurationProperties.getGaeService(), tenantInfo.getName()); ClusterSettings clusterInfo = (ClusterSettings) this.elasticCredentialCache.get(cacheKey); if (clusterInfo != null) { return clusterInfo; } - log.warning(String.format("elastic-credential cache missed for tenant: %s", tenantInfo.getName())); + log.warning(String.format("elastic-credential cache missed for tenant: %s", + tenantInfo.getName())); clusterInfo = this.elasticRepository.getElasticClusterSettings(tenantInfo); if (clusterInfo == null) { - throw new AppException(HttpStatus.SC_NOT_FOUND, "Tenant not found", "No information about the given tenant was found"); + throw new AppException(HttpStatus.SC_NOT_FOUND, "Tenant not found", + "No information about the given tenant was found"); } this.elasticCredentialCache.put(cacheKey, clusterInfo); diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/CloudConnectedOuterServicesBuilder.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/CloudConnectedOuterServicesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..13c0007bbaacb5a81aa6e2a4d6586652b3f09a25 --- /dev/null +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/CloudConnectedOuterServicesBuilder.java @@ -0,0 +1,112 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 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.indexer.util; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestHighLevelClient; +import org.opengroup.osdu.core.common.cache.RedisCache; +import org.opengroup.osdu.core.common.info.ConnectedOuterServicesBuilder; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService; +import org.opengroup.osdu.core.common.model.info.ConnectedOuterService; +import org.opengroup.osdu.core.common.model.search.ClusterSettings; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@Component +@ConditionalOnMissingBean(type = "ConnectedOuterServicesBuilder") +@Slf4j +@RequestScope +public class CloudConnectedOuterServicesBuilder implements ConnectedOuterServicesBuilder { + + private static final String NAME_PREFIX = "ElasticSearch-"; + private static final String REDIS_PREFIX = "Redis-"; + private static final String NOT_AVAILABLE = "N/A"; + + private final List<RedisCache> redisCaches; + private final ElasticClientHandler elasticClient; + private final IElasticSettingService elasticSettingService; + + public CloudConnectedOuterServicesBuilder( + List<RedisCache> redisCaches, + ElasticClientHandler elasticClient, + IElasticSettingService elasticSettingService) { + this.redisCaches = redisCaches; + this.elasticClient = elasticClient; + this.elasticSettingService = elasticSettingService; + } + + @Override + public List<ConnectedOuterService> buildConnectedOuterServices() { + return Stream.concat(redisCaches.stream().map(this::fetchRedisInfo), + fetchElasticInfos().stream()) + .collect(Collectors.toList()); + } + + private ConnectedOuterService fetchRedisInfo(RedisCache cache) { + String redisVersion = StringUtils.substringBetween(cache.info(), ":", "\r"); + return ConnectedOuterService.builder() + .name(REDIS_PREFIX + StringUtils.substringAfterLast(cache.getClass().getName(), ".")) + .version(redisVersion) + .build(); + } + + private List<ConnectedOuterService> fetchElasticInfos() { + try { + return elasticSettingService.getAllClustersSettings() + .entrySet().stream() + .map(entry -> fetchElasticInfo(entry.getKey(), entry.getValue())) + .collect(Collectors.toList()); + } catch (AppException e) { + log.error("Can't fetch cluster settings", e.getOriginalException()); + return Collections.singletonList(ConnectedOuterService.builder() + .name(NAME_PREFIX + NOT_AVAILABLE) + .version(NOT_AVAILABLE) + .build()); + } + } + + private ConnectedOuterService fetchElasticInfo(String partitionId, ClusterSettings settings) { + try (RestHighLevelClient client = elasticClient.createRestClient(settings)) { + return ConnectedOuterService.builder() + .name(NAME_PREFIX + partitionId) + .version(client.info(RequestOptions.DEFAULT).getVersion().getNumber()) + .build(); + } catch (AppException e) { + log.error("Can't create elastic client", e.getOriginalException()); + return ConnectedOuterService.builder() + .name(NAME_PREFIX + partitionId) + .version(NOT_AVAILABLE) + .build(); + } catch (IOException e) { + log.error("Can't fetch elastic info.", e); + return ConnectedOuterService.builder() + .name(NAME_PREFIX + partitionId) + .version(NOT_AVAILABLE) + .build(); + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2cb9edb547ad76e0b7204436cecbcd524cbbd5e3..88e47b0df7c5f8f736face8b4ef79565fdba813c 100644 --- a/pom.xml +++ b/pom.xml @@ -174,5 +174,45 @@ </profile> </profiles> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <executions> + <execution> + <id>build-info</id> + <goals> + <goal>build-info</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + <plugins> + <plugin> + <groupId>pl.project13.maven</groupId> + <artifactId>git-commit-id-plugin</artifactId> + <version>4.0.5</version> + <executions> + <execution> + <goals> + <goal>revision</goal> + </goals> + </execution> + </executions> + <configuration> + <verbose>true</verbose> + <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat> + <generateGitPropertiesFile>true</generateGitPropertiesFile> + <generateGitPropertiesFilename> + ${project.build.outputDirectory}/git.properties + </generateGitPropertiesFilename> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/TenantInfoService.java b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/TenantInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..16f82e4f309ce82d56a675351517240d37ded27e --- /dev/null +++ b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/TenantInfoService.java @@ -0,0 +1,33 @@ +package org.opengroup.osdu.indexer.aws.di; + +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; + +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@RequestScope +@Component +public class TenantInfoService implements ITenantInfoService { + + @Inject + private ITenantFactory tenantFactory; + + @Inject + private DpsHeaders headers; + + @Override + public TenantInfo getTenantInfo() { + return tenantFactory.getTenantInfo(headers.getPartitionId()); + } + + @Override + public List<TenantInfo> getAllTenantInfos() { + return new ArrayList<>(tenantFactory.listTenantInfo()); + } +} \ No newline at end of file diff --git a/provider/indexer-azure/pom.xml b/provider/indexer-azure/pom.xml index a91cc0902f87daddd54c4e417dd99504c5809e8d..e72f50d6d77e850e0b6375742d32de1bd01cb4b1 100644 --- a/provider/indexer-azure/pom.xml +++ b/provider/indexer-azure/pom.xml @@ -184,6 +184,12 @@ <groupId>org.opengroup.osdu</groupId> <artifactId>core-lib-azure</artifactId> <version>${osdu.corelibazure.version}</version> + <exclusions> + <exclusion> + <groupId>org.opengroup.osdu</groupId> + <artifactId>os-core-common</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/TenantInfoService.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/TenantInfoService.java index b54253284aa6cfb11e69f0eb776bd8c2897c4e93..53bcd253133745122a4770b868bf92bfd91ff10c 100644 --- a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/TenantInfoService.java +++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/di/TenantInfoService.java @@ -14,6 +14,8 @@ package org.opengroup.osdu.indexer.azure.di; +import java.util.ArrayList; +import java.util.List; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService; @@ -36,4 +38,9 @@ public class TenantInfoService implements ITenantInfoService { public TenantInfo getTenantInfo() { return tenantFactory.getTenantInfo(headers.getPartitionId()); } + + @Override + public List<TenantInfo> getAllTenantInfos() { + return new ArrayList<>(tenantFactory.listTenantInfo()); + } } diff --git a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/security/AADSecurityConfig.java b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/security/AADSecurityConfig.java index ff1bd512a2b333947365187500254b98f3209087..ce59f2e5c65b6aa3aea5361b7bb1a11c2cd1f690 100644 --- a/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/security/AADSecurityConfig.java +++ b/provider/indexer-azure/src/main/java/org/opengroup/osdu/indexer/azure/security/AADSecurityConfig.java @@ -44,6 +44,7 @@ public class AADSecurityConfig extends WebSecurityConfigurerAdapter { "/swagger-resources/**", "/configuration/security", "/swagger", + "/info", "/swagger-ui.html", "/webjars/**").permitAll() .anyRequest().authenticated() diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..84b3ca3597ebb4a046ce39c2d9588f56f6bc4e7c --- /dev/null +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java @@ -0,0 +1,33 @@ +package org.opengroup.osdu.indexer.di; + +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; + +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@RequestScope +@Component +public class TenantInfoService implements ITenantInfoService { + + @Inject + private ITenantFactory tenantFactory; + + @Inject + private DpsHeaders headers; + + @Override + public TenantInfo getTenantInfo() { + return tenantFactory.getTenantInfo(headers.getPartitionId()); + } + + @Override + public List<TenantInfo> getAllTenantInfos() { + return new ArrayList<>(tenantFactory.listTenantInfo()); + } +} \ No newline at end of file diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/DatastoreFactory.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/DatastoreFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..9a6dc9ef7e3920668aa2155c1c39dc8531ed3529 --- /dev/null +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/DatastoreFactory.java @@ -0,0 +1,70 @@ +/* + * Copyright 2021 Google LLC + * Copyright 2021 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.indexer.persistence; + +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.TransportOptions; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.http.HttpTransportOptions; +import java.util.HashMap; +import java.util.Map; +import javax.inject.Inject; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.gcp.multitenancy.credentials.DatastoreCredential; +import org.opengroup.osdu.indexer.cache.DatastoreCredentialCache; +import org.springframework.stereotype.Component; +import org.threeten.bp.Duration; + +@Component("indexerDatastoreFactory") +public class DatastoreFactory { + + @Inject + private DatastoreCredentialCache cache; + + private static Map<String, Datastore> datastoreClients = new HashMap<>(); + + private static final RetrySettings RETRY_SETTINGS = RetrySettings.newBuilder() + .setMaxAttempts(6) + .setInitialRetryDelay(Duration.ofSeconds(10)) + .setMaxRetryDelay(Duration.ofSeconds(32)) + .setRetryDelayMultiplier(2.0) + .setTotalTimeout(Duration.ofSeconds(50)) + .setInitialRpcTimeout(Duration.ofSeconds(50)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofSeconds(50)) + .build(); + + private static final TransportOptions TRANSPORT_OPTIONS = HttpTransportOptions.newBuilder() + .setReadTimeout(30000) + .build(); + + public Datastore getDatastoreInstance(TenantInfo tenantInfo) { + if (datastoreClients.get(tenantInfo.getName()) == null) { + Datastore googleDatastore = DatastoreOptions.newBuilder() + .setCredentials(new DatastoreCredential(tenantInfo)) + .setRetrySettings(RETRY_SETTINGS) + .setTransportOptions(TRANSPORT_OPTIONS) + .setNamespace(tenantInfo.getName()) + .setProjectId(tenantInfo.getProjectId()) + .build().getService(); + datastoreClients.put(tenantInfo.getName(), googleDatastore); + } + return datastoreClients.get(tenantInfo.getName()); + } +} diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java index 7e773c20b9c7f12bec2878c7c3ef4d3d349f8ab1..a8e3373f44926527a271d4d4390b5f4d5e647177 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java @@ -26,7 +26,6 @@ import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository; import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.core.common.search.Preconditions; -import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.springframework.stereotype.Component; @@ -52,7 +51,7 @@ public class ElasticRepositoryDatastore implements IElasticRepository { @Override public ClusterSettings getElasticClusterSettings(TenantInfo tenantInfo) { - Datastore googleDatastore = this.datastoreFactory.getDatastore(tenantInfo); + Datastore googleDatastore = this.datastoreFactory.getDatastoreInstance(tenantInfo); Key key = googleDatastore.newKeyFactory().setKind(properties.getElasticDatastoreKind()).newKey(properties.getElasticDatastoreId()); Entity datastoreEntity = googleDatastore.get(key); diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java index 8be38e24bb075a6042ecf6aaafe312d97bb177b1..0f70a40bc444ae9fd7e1553c319684df1286273b 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java @@ -40,6 +40,7 @@ public class GSuiteSecurityConfig extends WebSecurityConfigurerAdapter { @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/api-docs") + .antMatchers("/info") .antMatchers("/swagger"); } diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/TenantInfoService.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/TenantInfoService.java index 9bb0fe9675a7ec8c1b9f1da1610cab9733edda21..041d9a6d315bfbe67618436ffb0fccf2745c5b25 100644 --- a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/TenantInfoService.java +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/TenantInfoService.java @@ -3,6 +3,8 @@ package org.opengroup.osdu.indexer.ibm.di; +import java.util.ArrayList; +import java.util.List; import javax.inject.Inject; import org.opengroup.osdu.core.common.model.http.DpsHeaders; @@ -25,4 +27,9 @@ public class TenantInfoService implements ITenantInfoService { public TenantInfo getTenantInfo() { return tenantFactory.getTenantInfo(headers.getPartitionId()); } + + @Override + public List<TenantInfo> getAllTenantInfos() { + return new ArrayList<>(tenantFactory.listTenantInfo()); + } } diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/security/SecurityConfig.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/security/SecurityConfig.java index 475ba059435176cc018af71a868fde9e7eaf9397..d0737cfecfcb767083f8ade4939234f6bfc8da5c 100644 --- a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/security/SecurityConfig.java +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/security/SecurityConfig.java @@ -26,6 +26,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/swagger-resources/**", "/configuration/security", "/swagger", + "/info", "/swagger-ui.html", "/webjars/**").permitAll() .anyRequest().anonymous(); diff --git a/provider/indexer-ibm/src/main/resources/application.properties b/provider/indexer-ibm/src/main/resources/application.properties index 38a394adc7fc3c8230acc4a554212832c3e8861f..1e3ac9496d6694cfe536d328681b201dea528004 100644 --- a/provider/indexer-ibm/src/main/resources/application.properties +++ b/provider/indexer-ibm/src/main/resources/application.properties @@ -66,6 +66,4 @@ ELASTIC_DATASTORE_ID=indexer-service ELASTIC_HOST=elasticsearch.com ELASTIC_PORT=443 -ELASTIC_USER_PASSWORD=REPLACE_ME:REPLACE_ME - - +ELASTIC_USER_PASSWORD=REPLACE_ME:REPLACE_ME \ No newline at end of file diff --git a/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java b/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..095c346f0f30ce28d1a4a603babc318fd61a792c --- /dev/null +++ b/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/di/TenantInfoService.java @@ -0,0 +1,33 @@ +package org.opengroup.osdu.indexer.di; + +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; + +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@RequestScope +@Component +public class TenantInfoService implements ITenantInfoService { + + @Inject + private ITenantFactory tenantFactory; + + @Inject + private DpsHeaders headers; + + @Override + public TenantInfo getTenantInfo() { + return tenantFactory.getTenantInfo(headers.getPartitionId()); + } + + @Override + public List<TenantInfo> getAllTenantInfos() { + return new ArrayList<>(tenantFactory.listTenantInfo()); + } +} diff --git a/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java b/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java index 0db2f9e557efcc69fbd0419df57fc3a821e024de..6fd8a720a7fd9cf48729aeb85520f792b7ecae3e 100644 --- a/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java +++ b/provider/indexer-reference/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java @@ -38,6 +38,7 @@ public class GSuiteSecurityConfig extends WebSecurityConfigurerAdapter { @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/api-docs") + .antMatchers("/info") .antMatchers("/swagger"); } diff --git a/provider/indexer-reference/src/main/resources/application.properties b/provider/indexer-reference/src/main/resources/application.properties index 8690c57a906c0aae8cf6ecc5b0c282be392bbafb..4f83a153bbfe8c8f1969d57bed237c6f162983ca 100644 --- a/provider/indexer-reference/src/main/resources/application.properties +++ b/provider/indexer-reference/src/main/resources/application.properties @@ -70,7 +70,4 @@ redis-search-host=127.0.0.1 google-audiences=689762842995-pv217jo3k8j803kk6gqf52qb5amos3a9.apps.googleusercontent.com -mb-rabbitmq-uri=amqp://guest:guest@127.0.0.1:5672 - - - +mb-rabbitmq-uri=amqp://guest:guest@127.0.0.1:5672 \ No newline at end of file diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cba0839f389e3f230834c60088862021b86bc271 --- /dev/null +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/info/Info.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/info"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-info.xml"}) +public class RunTest {} \ No newline at end of file diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..ba386451b3bb3ca9f32ce3591e6b3e9fd16e3d46 --- /dev/null +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java @@ -0,0 +1,46 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.info.InfoSteps; +import org.opengroup.osdu.util.AWSHTTPClient; +import org.opengroup.osdu.util.Config; + +public class Steps extends InfoSteps { + + public Steps() { + super(new AWSHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new AWSHTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I send get request to version info endpoint") + public void i_send_get_request_to_version_info_endpoint() { + super.i_send_get_request_to_version_info_endpoint(); + } + + /******************Assert final response**************/ + + @Then("^I should get version info in response$") + public void i_should_get_version_info_in_response() { + super.i_should_get_version_info_in_response(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + @Override + protected String getApi() { + return Config.getIndexerBaseURL() + "info"; + } +} \ No newline at end of file diff --git a/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cba0839f389e3f230834c60088862021b86bc271 --- /dev/null +++ b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/info/Info.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/info"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-info.xml"}) +public class RunTest {} \ No newline at end of file diff --git a/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..a7871ae9130150ddf1c07688489136ea58667cbb --- /dev/null +++ b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java @@ -0,0 +1,46 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.info.InfoSteps; +import org.opengroup.osdu.util.AzureHTTPClient; +import org.opengroup.osdu.util.Config; + +public class Steps extends InfoSteps { + + public Steps() { + super(new AzureHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new AzureHTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I send get request to version info endpoint") + public void i_send_get_request_to_version_info_endpoint() { + super.i_send_get_request_to_version_info_endpoint(); + } + + /******************Assert final response**************/ + + @Then("^I should get version info in response$") + public void i_should_get_version_info_in_response() { + super.i_should_get_version_info_in_response(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + @Override + protected String getApi() { + return Config.getIndexerBaseURL() + "info"; + } +} \ No newline at end of file diff --git a/testing/indexer-test-core/pom.xml b/testing/indexer-test-core/pom.xml index 7e7a0e821ecb21d523a4ba630d1c233c32261672..8fbb5bb85063e6c4a6acbfc4f3c7a8a65644ed57 100644 --- a/testing/indexer-test-core/pom.xml +++ b/testing/indexer-test-core/pom.xml @@ -17,7 +17,7 @@ <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> <cucumber.version>1.2.5</cucumber.version> - <os-core-common.version>0.3.19</os-core-common.version> + <os-core-common.version>0.11.0-SNAPSHOT</os-core-common.version> </properties> <dependencies> diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/InfoBase.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/InfoBase.java new file mode 100644 index 0000000000000000000000000000000000000000..509b23c9b06946e7f5aab9e7323a2c512fa3a2da --- /dev/null +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/InfoBase.java @@ -0,0 +1,68 @@ +package org.opengroup.osdu.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; +import joptsimple.internal.Strings; +import lombok.extern.slf4j.Slf4j; +import org.opengroup.osdu.response.InfoResponseMock; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.ElasticUtils; +import org.opengroup.osdu.util.HTTPClient; + +@Slf4j +public class InfoBase extends TestsBase { + + protected Map<String, String> headers = new HashMap<>(); + private InfoResponseMock response; + + public InfoBase(HTTPClient httpClient) { + super(httpClient); + } + + public InfoBase(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + } + + @Override + protected String getApi() { + return Config.getIndexerBaseURL() + "info"; + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + public void i_send_get_request_to_version_info_endpoint() { + if (Config.getIndexerBaseURL().isEmpty()) { + log.warn("Env variable INDEXER_HOST is empty. Version info endpoint test is skipped"); + return; + } + + response = + executeQuery( + this.getApi(), + Strings.EMPTY, + headers, + httpClient.getAccessToken(), + InfoResponseMock.class); + } + + public void i_should_get_version_info_in_response() { + if (response != null) { + assertEquals(200, response.getResponseCode()); + assertNotNull(response.getGroupId()); + assertNotNull(response.getArtifactId()); + assertNotNull(response.getVersion()); + assertNotNull(response.getBuildTime()); + assertNotNull(response.getBranch()); + assertNotNull(response.getCommitId()); + assertNotNull(response.getCommitMessage()); + } else { + log.warn("Version info endpoint provided null response"); + } + } +} diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java index e4d6322f715941c1bc18d5fc82ee9b33ce9e2c97..2b8d960eccc3cc1a934e480e9e2d6b31c725be47 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java @@ -18,6 +18,7 @@ import javax.ws.rs.core.MultivaluedMap; import java.util.*; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.opengroup.osdu.util.Config.*; @Log @@ -109,7 +110,7 @@ public abstract class TestsBase { private <T extends ResponseBase> T getResponse(ClientResponse clientResponse, Class<T> typeParameterClass) { log.info(String.format("Response status: %s, type: %s", clientResponse.getStatus(), clientResponse.getType().toString())); - assertEquals(MediaType.APPLICATION_JSON, clientResponse.getType().toString()); + assertTrue(clientResponse.getType().toString().contains(MediaType.APPLICATION_JSON)); String responseEntity = clientResponse.getEntity(String.class); T response = new Gson().fromJson(responseEntity, typeParameterClass); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/info/InfoSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/info/InfoSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..02924b4d055aa4a444ab79174ec2c0f978ae3818 --- /dev/null +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/info/InfoSteps.java @@ -0,0 +1,16 @@ +package org.opengroup.osdu.common.info; + +import org.opengroup.osdu.common.InfoBase; +import org.opengroup.osdu.util.ElasticUtils; +import org.opengroup.osdu.util.HTTPClient; + +public class InfoSteps extends InfoBase { + + public InfoSteps(HTTPClient httpClient) { + super(httpClient); + } + + public InfoSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + } +} \ No newline at end of file diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/response/InfoResponseMock.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/response/InfoResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..682226c3d88f4b1a09195cddba665711c581c639 --- /dev/null +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/response/InfoResponseMock.java @@ -0,0 +1,16 @@ +package org.opengroup.osdu.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InfoResponseMock extends ResponseBase { + private String groupId; + private String artifactId; + private String version; + private String buildTime; + private String branch; + private String commitId; + private String commitMessage; +} \ No newline at end of file diff --git a/testing/indexer-test-core/src/main/resources/features/info/Info.feature b/testing/indexer-test-core/src/main/resources/features/info/Info.feature new file mode 100644 index 0000000000000000000000000000000000000000..6344baeab9b9e20810990e438381b869e8ac79c0 --- /dev/null +++ b/testing/indexer-test-core/src/main/resources/features/info/Info.feature @@ -0,0 +1,5 @@ +Feature: Fetch info about maven build and git repository. + + Scenario: Verify version info endpoint content + When I send get request to version info endpoint + Then I should get version info in response \ No newline at end of file diff --git a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cba0839f389e3f230834c60088862021b86bc271 --- /dev/null +++ b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/info/Info.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/info"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-info.xml"}) +public class RunTest {} \ No newline at end of file diff --git a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..e9b432e6ca920063543e10e5fe2b1935e85c4a87 --- /dev/null +++ b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java @@ -0,0 +1,46 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.info.InfoSteps; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.GCPHTTPClient; + +public class Steps extends InfoSteps { + + public Steps() { + super(new GCPHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new GCPHTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I send get request to version info endpoint") + public void i_send_get_request_to_version_info_endpoint() { + super.i_send_get_request_to_version_info_endpoint(); + } + + /******************Assert final response**************/ + + @Then("^I should get version info in response$") + public void i_should_get_version_info_in_response() { + super.i_should_get_version_info_in_response(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + @Override + protected String getApi() { + return Config.getIndexerBaseURL() + "info"; + } +} \ No newline at end of file diff --git a/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cba0839f389e3f230834c60088862021b86bc271 --- /dev/null +++ b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/info/Info.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/info"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-info.xml"}) +public class RunTest {} \ No newline at end of file diff --git a/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..7524db63d9b6f35e2757972a5fa7ac245b2f7e96 --- /dev/null +++ b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java @@ -0,0 +1,46 @@ +package org.opengroup.osdu.step_definitions.info; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.info.InfoSteps; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.IBMHTTPClient; + +public class Steps extends InfoSteps { + + public Steps() { + super(new IBMHTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new IBMHTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I send get request to version info endpoint") + public void i_send_get_request_to_version_info_endpoint() { + super.i_send_get_request_to_version_info_endpoint(); + } + + /******************Assert final response**************/ + + @Then("^I should get version info in response$") + public void i_should_get_version_info_in_response() { + super.i_should_get_version_info_in_response(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + @Override + protected String getApi() { + return Config.getIndexerBaseURL() + "info"; + } +} \ No newline at end of file