Skip to content

Commit

Permalink
Us601302 onboarding spring enabler na (#480)
Browse files Browse the repository at this point in the history
* US601302# Buildable, Runnable: Onboarding enabler spring, v1, v2, disco client. Bad config.

* US601302: Change service onboarding config according to new PJE config format

* US601302: resolve PR#466 comments

From Ilkin:
2. EurekaClientWrapper 3x
3. ApiMlLogger Configuration
6.7. eureka.* properties
9. config/local/* vs application.yml - clean up
10.  discoverableclient2 and discoverableclient.

Still needed to check configs and clean comments

* US601302: Clean app config

* US601302: logging in spring enabler event listener

* US601302: Add dummy tests classes for onboarding enablers (required by sonarqube); Change springfox version

* US601302: Exclude onboarding-enabler-spring-v1 from sonarqube analysis

* US601302: Exclude onboarding-enabler-spring-v2 from sonarqube analysis

* US601302# Buildable, Runnable: Onboarding enabler spring, v1, v2, disco client. Bad config.

* US601302: Change service onboarding config according to new PJE config format

* US601302: resolve PR#466 comments

From Ilkin:
2. EurekaClientWrapper 3x
3. ApiMlLogger Configuration
6.7. eureka.* properties
9. config/local/* vs application.yml - clean up
10.  discoverableclient2 and discoverableclient.

Still needed to check configs and clean comments

* US601302: Clean app config

* US601302: logging in spring enabler event listener

* US601302: Add dummy tests classes for onboarding enablers (required by sonarqube); Change springfox version

* US601302: Exclude onboarding-enabler-spring-v1 from sonarqube analysis

* US601302: Exclude onboarding-enabler-spring-v2 from sonarqube analysis

* US601302: Improve spring beans usage

Substitute EurekaClientWrapper with ApiMediationClient, which holds EurekaClient.
Temporarily commented out spring enabler tests due to spring configuration properties issues.

* US601302: get rid of EurekaClientWrapper

* US601302: Improve APIML seervice registration flow

Unregister first if registration called repeatedly;
Add log messages

* US601302: Remove unused Config and Bean classes

* US601392: Improvements

- App Context configuration
- Unit tests properties and profile
- Apiml logging
- Context reload
- Unregister
- Autowiring

* US601302: Service YAML configuration

* US601302: Resolve PRR comments

* US601302: Process PRR comments

* US601302: Format of @import single class

* FIX: jacoco failing on Jenkins

* changed IDEA setup parameter for launching services from Spring's Services dashboard

Signed-off-by: Elena Kubantseva <[email protected]>

* fixed apidoc

* US601302: Solve review issues

* tmp commit: added additional log messages

Signed-off-by: Elena Kubantseva <[email protected]>

* US601302: Unregister from DiscoServ on ContextClosedEvent

* US601302: Fix - Swagger ApiParam example number value not set throws exception

* US601302: Removed deprecated description in Swagger api-doc

* US601302: Setting config to newConfig to. Handling closing context event by unregistering from DS.

* US601302: Rename _config to newConfig

* US601302: Clean comment and TODO

* US601302: Remove obsolete comments

* US601302: Fix apiml.service.ssl referencing server.ssl properties

* US601302: Fix externalized apiml.service.properties

* US601302: Process PR review comments

* US601302: Move ApimlEurekaInstanceConfig. Clean-up comments and ext config obsolet settings

* US601302: Chenge order of apiml and server segments, because on MF -D properties set primarily the apiml. segment

* US602301: Reverse order of apiml: and server: config segments

* US602301: Reverse order of apiml: and server: config segments

* US601302: Move ssl properties to additional config file. Expected to be set from -D on mainframe

* US601302: Chenge order of apiml and server segments, because on MF -D properties set primarily the apiml. segment

* US601302: Remaster config; removed empty tests class

* US601302: 1. DC config of spring.address; 2. Integration tests dependency on jackson modules

* US601302: WIP: Set server.addres s to apiml.service.ipAddress

* US601302: FIX: WebsocketTEst, Encoding characters

* US601302: FIX - @Ingore integartion test for encoded characters. Must introduce configuration first in following story.

* US601302: Fix websocket jetty implementation version string format.

Co-authored-by: pz891284 <[email protected]>
Co-authored-by: Elena Kubantseva <[email protected]>
Co-authored-by: Ilkin <[email protected]>
  • Loading branch information
4 people authored Jan 30, 2020
1 parent 3e3a532 commit 8b3b548
Show file tree
Hide file tree
Showing 96 changed files with 1,025 additions and 436 deletions.
2 changes: 0 additions & 2 deletions Api-Layer-Java.ppf
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<Source exclude="false" path="./helloworld-jersey/src/test/java" web="false"/>
<Source exclude="false" path="./helloworld-spring/src/main/java" web="false"/>
<Source exclude="false" path="./helloworld-spring/src/test/java" web="false"/>
<Source exclude="false" path="./integration-enabler-java/src/main/java" web="false"/>
<Source exclude="false" path="./integration-enabler-java/src/test/java" web="false"/>
<Source exclude="false" path="./integration-enabler-spring-v1-sample-app/src/main/java" web="false"/>
<Source exclude="false" path="./integration-enabler-spring-v1-sample-app/src/test/java" web="false"/>
<Source exclude="false" path="./integration-enabler-spring-v1/src/main/java" web="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String transformApiDoc(String serviceId, ApiDocInfo apiDocInfo) {
private void updateSchemeHostAndLink(Swagger swagger, String serviceId, boolean hidden) {
GatewayConfigProperties gatewayConfigProperties = gatewayClient.getGatewayConfigProperties();
String swaggerLink = OpenApiUtil.getOpenApiLink(serviceId, gatewayConfigProperties);

log.debug("Updating host for service with id: " + serviceId + " to: " + gatewayConfigProperties.getHostname());
swagger.setSchemes(Collections.singletonList(Scheme.forValue(gatewayConfigProperties.getScheme())));
swagger.setHost(gatewayConfigProperties.getHostname());
if (!hidden) {
Expand Down
5 changes: 2 additions & 3 deletions apiml-common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies {
compile(project(':common-service-core'))
compile project(':apiml-logging')
//compile project(':common-service-core')

compile libraries.spring_boot_starter_web
compile libraries.commons_validator
compile libraries.spring_cloud_starter_eureka_server
compile libraries.jackson_databind
compile libraries.apache_commons_lang3
compile libraries.http_client
Expand All @@ -19,5 +19,4 @@ dependencies {
testCompile libraries.power_mock_junit4
testCompile libraries.power_mock_junit4_rule
testCompile libraries.lombok
testCompile libraries.gson
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private GatewayConfigProperties process(InstanceInfo instanceInfo) {
try {
String gatewayHomePage = instanceInfo.getHomePageUrl();
URI uri = new URI(gatewayHomePage);

log.debug("Gateway homePageUrl: " + gatewayHomePage);
return GatewayConfigProperties.builder()
.scheme(uri.getScheme())
.hostname(uri.getHost() + ":" + uri.getPort())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,32 @@ public InstanceInfo createInstance(String serviceId, String instanceId,
InstanceInfo.InstanceStatus status,
InstanceInfo.ActionType actionType,
HashMap<String, String> metadata) {
return new InstanceInfo(instanceId, serviceId.toUpperCase(), null, "192.168.0.1", null,
new InstanceInfo.PortWrapper(true, 9090), null, null, null, null, null, null, null, 0, null, "hostname",
status, null, null, null, null, metadata, null, null, actionType, null);
return new InstanceInfo(
instanceId,
serviceId.toUpperCase(),
null,
"192.168.0.1",
null,
new InstanceInfo.PortWrapper(true, 9090),
null,
null,
null,
null,
null,
null,
null,
0,
null,
"hostname",
status,
null,
null,
null,
null,
metadata,
null,
null,
actionType,
null);
}
}
22 changes: 22 additions & 0 deletions apiml-logging/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
dependencies {
compile(project(':common-service-core'))

compile libraries.spring_boot_starter_web
compile libraries.commons_validator
compile libraries.jackson_databind
compile libraries.apache_commons_lang3
compile libraries.http_client
compile libraries.http_core
compile libraries.jetty_websocket_client

compileOnly libraries.spring_boot_configuration_processor
compileOnly libraries.lombok

testCompile libraries.javax_servlet_api
testCompile libraries.spring_boot_starter_test
testCompile libraries.powermock_api_mockito2
testCompile libraries.power_mock_junit4
testCompile libraries.power_mock_junit4_rule
testCompile libraries.lombok
//testCompile libraries.gson
}
1 change: 1 addition & 0 deletions common-service-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies {
compile(libraries.http_core)
compile(libraries.jackson_annotations)
compile(libraries.jackson_databind)
compile libraries.logback_classic
compile(libraries.slf4j_api)
compile(libraries.snakeyaml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,13 @@ public EurekaJerseyClientBuilder createEurekaJerseyClientBuilder(String eurekaSe
builder.withMaxTotalConnections(10);
builder.withMaxConnectionsPerHost(10);

// See:
// https://github.com/Netflix/eureka/blob/master/eureka-core/src/main/java/com/netflix/eureka/transport/JerseyReplicationClient.java#L160
if (eurekaServerUrl.startsWith("http://")) {
apimlLog.log("apiml.common.insecureHttpWarning");
} else {
// Setup HTTPS for Eureka replication client:
System.setProperty("com.netflix.eureka.shouldSSLConnectionsUseSystemSocketFactory", "true");
setSystemSslProperties();
// See:
// https://github.com/Netflix/eureka/blob/master/eureka-core/src/main/java/com/netflix/eureka/transport/JerseyReplicationClient.java#L160

// Setup HTTPS for Eureka client:
builder.withCustomSSL(createSecureSslContext());
builder.withHostnameVerifier(createHostnameVerifier());
}
Expand Down
2 changes: 1 addition & 1 deletion config/local/api-defs/staticclient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
apiInfo:
- apiId: org.zowe.discoverableclient
gatewayUrl: api/v1
swaggerUrl: https://localhost:10012/discoverableclient/api-doc
swaggerUrl: https://localhost:10012/discoverableclient/v2/api-docs

- serviceId: staticclient2 # unique lowercase ID of the service
catalogUiTileId: static # ID of the API Catalog UI tile (visual grouping of the services)
Expand Down
43 changes: 28 additions & 15 deletions config/local/discoverable-client.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
spring.profiles.include: diag

apiml:
service:
hostname: localhost
ipAddress: 127.0.0.1
port: 10012
discoveryServiceUrls: https://localhost:10011/eureka/

spring:
profiles:
include: diag
output:
ansi:
enabled: always

apiml:
security:
ssl:
ciphers: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
# The `apiml` node contains API Mediation Layer specific configuration
service:
# The `apiml.service` node contains information required by any APIML service
id: discoverableclient # Service ID of this service
hostname: localhost # Hostname that is advertised in Eureka. Default is valid only for localhost
port: 10012 # Default port name for discoverable-clinet service
ipAddress: 127.0.0.1 # IP address that is advertised in Eureka. Default is valid only for localhost
preferIpAddress: false
discoveryServiceUrls: https://localhost:10011/eureka/

server:
ssl:
keyAlias: localhost
keyPassword: password
keyStore: keystore/localhost/localhost.keystore.p12
# keyStore: keystore/selfsigned/localhost.keystore.p12
# keyStore: keystore/selfsigned/localhost-untrusted.keystore.p12
keyStorePassword: password
keyStoreType: PKCS12
trustStore: keystore/localhost/localhost.truststore.p12
# trustStore: keystore/selfsigned/localhost.truststore.p12
# trustStore: keystore/selfsigned/localhost-untrusted.truststore.p12
trustStorePassword: password
trustStoreType: PKCS12

eureka:
client:
enabled: true
serviceUrl:
defaultZone: ${apiml.service.discoveryServiceUrls}
instance:
metadata-map:
discovery:
service:
title: Service Spring Integration Enabler sample application API
description: Sample API services to demonstrate Spring Integration Enabler
20 changes: 10 additions & 10 deletions discoverable-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ gitProperties {
}

dependencies {
compile(project(':integration-enabler-spring-v2'))
compile(project(':apiml-common'))
implementation project(':onboarding-enabler-spring-v2')

compile libraries.gson
compile libraries.spring_boot_starter_actuator
compile libraries.spring_boot_starter_web
compile libraries.spring_boot_starter_websocket
compile libraries.spring_cloud_starter_eureka
implementation libraries.spring_boot_starter
implementation libraries.spring_boot_starter_actuator
implementation libraries.spring_boot_starter_web
implementation libraries.spring_boot_starter_websocket

compile('org.webjars:bootstrap:4.1.3')
compile('org.webjars:jquery:3.3.1-1')
implementation libraries.bootstrap
implementation libraries.jquery

implementation libraries.gson

compileOnly libraries.lombok

testCompile libraries.spring_boot_starter_test
testImplementation libraries.spring_boot_starter_test
}

bootJar.archiveName = "${bootJar.baseName}.jar"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
package com.ca.mfaas.client;

import com.ca.mfaas.enable.EnableApiDiscovery;
import com.ca.apiml.enable.EnableApiDiscovery;
import com.ca.mfaas.product.logging.annotations.EnableApimlLogger;
import com.ca.mfaas.product.monitoring.LatencyUtilsConfigInitializer;
import com.ca.mfaas.product.service.ServiceStartupEventHandler;
Expand All @@ -18,21 +18,14 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.hystrix.HystrixAutoConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

@SpringBootApplication(exclude = HystrixAutoConfiguration.class)
@SpringBootApplication
@EnableApiDiscovery
@EnableConfigurationProperties
@EnableWebSocket
@EnableApimlLogger
@ComponentScan(value = {
"com.ca.mfaas.client",
"com.ca.mfaas.enable",
"com.ca.mfaas.product.security",
"com.ca.mfaas.product.web" })
public class DiscoverableClientSampleApplication implements ApplicationListener<ApplicationReadyEvent> {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Response Header and returns status code 307
*/
@RestController
@Api(tags = {"Other Operations"}, description = "General Operations")
@Api(tags = {"Other Operations"})
public class PageRedirectionController {

/**
Expand All @@ -50,7 +50,7 @@ public class PageRedirectionController {
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Redirect to specified location", response = String.class)
})
public RedirectLocation redirectPage(@ApiParam(value = "Location that need to be redirected to", required = true)
public RedirectLocation redirectPage(@ApiParam(value = "Location that need to be redirected to", required = true, example = "https://host:port/context/path")
@RequestBody RedirectLocation redirectLocation,
HttpServletResponse response) {
response.setHeader(LOCATION, redirectLocation.getLocation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Pet addPet(@ApiParam(value = "Pet object that needs to be added", require
@ApiResponse(code = 401, message = "Authentication is required", response = ApiMessageView.class),
@ApiResponse(code = 404, message = "The pet with id is not found.", response = ApiMessageView.class)
})
public Pet getPetById(@ApiParam(value = "Pet id to return", required = true)
public Pet getPetById(@ApiParam(value = "Pet id to return", required = true, example = "1")
@PathVariable("id") Long id) {
Pet pet = petService.getById(id);
if (pet == null) {
Expand Down Expand Up @@ -156,7 +156,7 @@ public Pet getPetById(@ApiParam(value = "Pet id to return", required = true)
@ApiResponse(code = 401, message = "Authentication is required", response = ApiMessageView.class),
@ApiResponse(code = 404, message = "Pet not found", response = ApiMessageView.class)
})
public Pet updatePetById(@ApiParam(value = "Pet id to update", required = true)
public Pet updatePetById(@ApiParam(value = "Pet id to update", required = true, example = "1")
@PathVariable("id") Long id,
@ApiParam(value = "Pet object that needs to be updated", required = true)
@Validated(value = {Existing.class})
Expand Down Expand Up @@ -193,7 +193,7 @@ public Pet updatePetById(@ApiParam(value = "Pet id to update", required = true)
@ApiResponse(code = 403, message = "Forbidden", response = ApiMessageView.class),
@ApiResponse(code = 404, message = "Pet not found", response = ApiMessageView.class)
})
public void deletePetById(@ApiParam(value = "Pet id to delete", required = true)
public void deletePetById(@ApiParam(value = "Pet id to delete", required = true, example = "1")
@PathVariable("id") Long id) {
petService.deleteById(id);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/
package com.ca.mfaas.client.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Collections;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

@Value("${apiml.service.title}")
private String apiTitle;

@Value("${apiml.service.apiInfo[0].version}")
private String apiVersion;

@Value("${apiml.service.description}")
private String apiDescription;

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/api/v1/**"))
.build()
.apiInfo(
new ApiInfo(
apiTitle,
apiDescription,
apiVersion,
null,
null,
null,
null,
Collections.emptyList()
)
);
}
}
Loading

0 comments on commit 8b3b548

Please sign in to comment.