Commit 7cba6321 authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Riabokon Stanislav(EPAM)[GCP]
Browse files

Added new version info endpoint (GONRG-2811)

parent f7e77071
......@@ -125,7 +125,6 @@ The following software have components provided under the terms of this license:
- IBM COS SDK For Java (from https://github.com/ibm/ibm-cos-sdk-java)
- IBM COS SDK for Java - Core (from https://github.com/ibm/ibm-cos-sdk-java)
- Identity and Access Management (IAM) API v1-rev307-1.25.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-iam)
- IntelliJ IDEA Annotations (from http://www.jetbrains.org)
- J2ObjC Annotations (from https://github.com/google/j2objc/)
- J2ObjC Annotations (from https://github.com/google/j2objc/)
- JBoss Logging 3 (from http://www.jboss.org)
......@@ -168,6 +167,7 @@ The following software have components provided under the terms of this license:
- Java Servlet API (from http://servlet-spec.java.net)
- Java UUID Generator (from http://wiki.fasterxml.com/JugHome)
- Javassist (from http://www.javassist.org/)
- JetBrains Java Annotations (from https://github.com/JetBrains/java-annotations)
- Joda-Time (from https://www.joda.org/joda-time/)
- Joda-Time (from https://www.joda.org/joda-time/)
- KeePassJava2 :: All (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2)
......@@ -275,7 +275,7 @@ The following software have components provided under the terms of this license:
- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-protobuf)
- Proton-J (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j)
- QpidJMS Client (from )
- Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty)
- Reactor Netty with all modules (from https://github.com/reactor/reactor-netty)
- Retrofit (from https://github.com/square/retrofit)
- SnakeYAML (from http://www.snakeyaml.org)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
......
......@@ -14,7 +14,7 @@ limitations under the License.
# Register service
The Register Service is a Maven multi-module project with each cloud implemention placed in its submodule.
The Register Service is a Maven multi-module project with each cloud implementation placed in its submodule.
## GCP
......
......@@ -16,6 +16,8 @@ tags:
description: ""
- name: Subscription
description: ""
- name: Info
description: Version info endpoint
security:
- bearer: []
- appkey: []
......@@ -1052,6 +1054,21 @@ paths:
security:
- bearer: []
- appkey: []
/info:
get:
tags:
- Info
summary: "Version info"
description: "For deployment available public `/info` endpoint, \
\ which provides build and git related information."
operationId: "Version info"
produces:
- "application/json"
responses:
200:
description: "Version info."
schema:
$ref: "#/components/schemas/VersionInfo"
servers:
- url: https://evq.csp.osdu.com/api/register/v1
description: EVT
......@@ -1471,4 +1488,44 @@ components:
example: common:source:type:1.0.0
op:
type: string
example: deleted
\ No newline at end of file
example: deleted
VersionInfo:
type: "object"
properties:
groupId:
type: "string"
description: "Maven artifact group ID."
actifactId:
type: "string"
description: "Maven artifact ID."
version:
type: "string"
description: "Maven artifact version"
buildTime:
type: "string"
description: "Maven artifact build time"
branch:
type: "string"
description: "Current git branch"
commitId:
type: "string"
description: "Latest commit hash"
commitMessage:
type: "string"
description: "Latest commit message"
connectedOuterServices:
type: "array"
description: "Connected outer services information"
items:
$ref: "#/components/schemas/ConnectedOuterService"
description: "Version info."
ConnectedOuterService:
type: "object"
properties:
name:
type: "string"
description: "Connected outer service name."
version:
type: "string"
description: "Connected outer service version."
description: "Connected outer service information."
\ No newline at end of file
......@@ -9,6 +9,7 @@
* [Retrieve Actions](#retrieve-action)
* [Delete an Action by ID](#delete-action)
* [Validate action](#regex-test)
* [Version info endpoint](#version-info-endpoint)
- [Current Limitations](#limitation)
## Introduction <a name="introduction"></a>
......@@ -302,6 +303,42 @@ The regular expression match per record field is capped at a maximum of 2 second
[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)
## Current Limitations <a name="limitation"></a>
There are mainly 2 limitations currently:
......
......@@ -30,7 +30,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springfox-version>2.7.0</springfox-version>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<licenses>
......@@ -90,9 +90,39 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.9.RELEASE</version>
<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>
......
......@@ -88,7 +88,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
......
......@@ -58,7 +58,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......
......@@ -40,7 +40,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
......
......@@ -37,7 +37,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
......
......@@ -83,7 +83,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
......
/*
* 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.register.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
......@@ -46,10 +46,9 @@ public class AuthorizationFilter {
public boolean hasAnyPermission(String... requiredRoles) {
String path = request.getServletPath();
if ("GET".equals(request.getMethod())) {
if (path.equals("/swagger-ui.html")) {
return true;
}
if ("GET".equals(request.getMethod()) &&
(path.equals("/swagger-ui.html") || path.equals("/info"))) {
return true;
}
if (StringUtils.isBlank(this.headers.getAuthorization())) {
......
......@@ -70,7 +70,7 @@ public class RegisterFilter implements Filter {
private boolean validateIsHttps(HttpServletResponse httpServletResponse) {
String uri = requestInfo.getUri();
if (isLocalHost(uri) || isSwagger(uri)) {
if (isLocalHost(uri) || isSwagger(uri) || isVersionInfo(uri)) {
return true;
}
if (isAcceptHttp() || requestInfo.isHttps()) {
......@@ -91,6 +91,10 @@ public class RegisterFilter implements Filter {
return uri.contains("/swagger") || uri.contains("/v2/api-docs") || uri.contains("/configuration/ui") || uri.contains("/webjars/");
}
private boolean isVersionInfo(String uri) {
return (uri.contains("/info"));
}
public boolean isAcceptHttp() {
return this.serviceConfig.getAcceptHttp();
}
......
package org.opengroup.osdu.register.api;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.opengroup.osdu.core.common.info.VersionInfoBuilder;
import org.opengroup.osdu.core.common.model.info.VersionInfo;
@RunWith(MockitoJUnitRunner.class)
public class InfoApiTest {
@InjectMocks
private InfoApi sut;
@Mock
private VersionInfoBuilder versionInfoBuilder;
@Test
public void should_return200_getVersionInfo() throws IOException {
VersionInfo versionInfo = VersionInfo.builder()
.groupId("group")
.artifactId("artifact")
.version("0.1.0")
.buildTime("1000")
.branch("master")
.commitId("7777")
.commitMessage("Merge commit")
.build();
when(versionInfoBuilder.buildVersionInfo()).thenReturn(versionInfo);
VersionInfo response = this.sut.info();
assertEquals(versionInfo, response);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment