Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikWoelfel2323 authored Mar 23, 2020
2 parents 6ce4913 + 3ceb8d0 commit 469ba66
Show file tree
Hide file tree
Showing 58 changed files with 2,098 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: java

jdk:
- openjdk8
- oraclejdk11
- openjdk11

install: /bin/true # skip gradle assemble

Expand Down
58 changes: 56 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Release Notes

## 2.2.5
* **[general]**: Use latest AWS SDK 2.10.56 as per AWS recommendation (important bugfixes)

## 2.2.4
* **[edison-jobs]**: DynamoDb Support
* fix ETag handling for DynamoJobRepository

## 2.2.3
* **[edison-jobs]**: DynamoDb Support
* creation of tables removed
* Fixes for Enabling Jobs and ClearRunningJob
* Clear table when calling deleteAll instead of deleting and recreating table

## 2.2.2
* **[edison-jobs]**: add DynamoDb Support for Edison-Jobs
* Properties for enabling DynamoDb:
* **edison.jobs.dynamo.enabled**: Enable DynamoDb (disabled by default)
* **edison.jobs.mongo.enabled**: MongoDb needs to be disabled
* **edison.jobs.dynamo.jobinfo.tableName**: Name for JobInfo table (gets created if non-existent)
* **edison.jobs.dynamo.jobinfo.pageSize**: PageSize for scan-requests against JobInfo table
* **edison.jobs.dynamo.jobmeta.tableName**: Name for JobMeta table (gets created if non-existent)

## 2.2.1
* **[general]**: upgrade aws sdk
* **[edison-core]**: Fix basic auth credentials retrieval on wrong format

## 2.2.0
* **[general]**: Update to Spring Boot 2.2

See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes for a migration guide

## 2.1.3
* **[general]**: Update dependencies

## 2.1.2
* **[general]**: increase gradle version

## 2.1.1
* **[edison-togglz]**:
* Make S3TogglzRepository cache dependent from String instead of Feature in order to support kotlin togglz
* Add `getFeatureFromName(String name)`- function to be able to retrieve current feature by its name

## 2.1.0
* **[edison-togglz]**:
* Make FeatureManager @ConditionalOnMissingBean to allow overriding
* Get @Label and other annotations from FeatureManager.getMetaData so that this works with Features that are not enums, too
* Add methods to FeatureManagerSupport that get the FeatureManager as parameter instead of from the FeatureContext

## 2.0.1
* **[edison-validation]**: Make error profile configurable via application property 'edison.validation.error-profile'

## 2.0.0
* **[edison-validation]**: Add EnumListValidator to be able to validate a list of enums

Expand All @@ -23,10 +74,13 @@ Suppress unnecessary warning on startup
Block query of public keys until keys have been initially fetched from server

## 2.0.0-rc5

* **[edison-jobs]**:
Reimplement the JobEventPublisher from Edison 1.x for backwards compatibility
- Reimplement the JobEventPublisher from Edison 1.x for backwards compatibility

* **[edison-oauth]**:
Add dependency to org.springframework.security:spring-security-web:5.1.4.RELEASE
- Add dependency to org.springframework.security:spring-security-web:5.1.4.RELEASE
- Fixes thread-safety issue in OAuthPublicKeyInMemoryRepository

## 2.0.0-rc4

Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ Collection of independent libraries on top of Spring Boot to provide a faster se

> "I never did anything by accident, nor did any of my inventions come by accident; they came by work." - Thomas Edison

## Status

[![Next Selected Stories](https://badge.waffle.io/otto-de/edison-microservice.svg?label=Ready&title=Selected)](http://waffle.io/otto-de/edison-microservice)
[![Active Stories](https://badge.waffle.io/otto-de/edison-microservice.svg?label=In%20Progress&title=Doing)](http://waffle.io/otto-de/edison-microservice)

[![build](https://travis-ci.org/otto-de/edison-microservice.svg)](https://travis-ci.org/otto-de/edison-microservice)
[![build](https://travis-ci.org/otto-de/edison-microservice.svg?branch=master)](https://travis-ci.org/otto-de/edison-microservice)
[![codecov](https://codecov.io/gh/otto-de/edison-microservice/branch/master/graph/badge.svg)](https://codecov.io/gh/otto-de/edison-microservice)
[![Known Vulnerabilities](https://snyk.io/test/github/otto-de/edison-microservice/badge.svg)](https://snyk.io/test/github/otto-de/edison-microservice)
[![release](https://maven-badges.herokuapp.com/maven-central/de.otto.edison/edison-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.otto.edison/edison-core)
[![license](https://img.shields.io/github/license/otto-de/edison-microservice.svg)](./LICENSE)

Have a look at the [release notes](CHANGELOG.md) for details about updates and changes.


## About

This project contains a number of independent libraries on top of Spring Boot to provide a faster setup of jvm microservices.
Expand All @@ -45,7 +40,7 @@ This project maintains its roadmap with [issues](https://github.com/otto-de/edis

**[1.x.0](https://github.com/otto-de/edison-microservice/milestone/2)**: Edison Microservices for Spring Boot 1.5 ✔

**[2.0.0](https://github.com/otto-de/edison-microservice/milestone/3)**: Edison Microservices for Spring Boot 2.0
**[2.0.0](https://github.com/otto-de/edison-microservice/milestone/3)**: Edison Microservices for Spring Boot 2.x


## Migration from Edison 1.x to Edison 2
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ buildscript {
apply from: "${rootDir}/gradle/dependencies.gradle"

repositories {
maven { url 'http://repo.spring.io/libs-snapshot' }
maven { url 'http://repo.spring.io/plugins-release' }
mavenCentral()
jcenter()
mavenLocal()
}

Expand Down Expand Up @@ -37,7 +37,8 @@ subprojects {
// DO NOT FORGET TO DOCUMENT CHANGES IN CHANGELOG.md
//
// Add a GitHub release for every new release: https://github.com/otto-de/edison-microservice/releases
version = '2.0.1-SNAPSHOT'

version = '2.2.6-SNAPSHOT'
group = 'de.otto.edison'

repositories {
Expand All @@ -50,6 +51,7 @@ subprojects {
// Override some Spring Boot default versions
// see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-customize-dependency-versions
ext['mockito.version'] = test_versions.mockito_core
ext['jackson.version'] = versions.jackson

task allDeps(type: DependencyReportTask) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,27 @@ public String getPassword() {
*/
public static Optional<Credentials> readFrom(HttpServletRequest request) {
String authorizationHeader = request.getHeader("Authorization");
if (!StringUtils.isEmpty(authorizationHeader)) {
if (!StringUtils.isEmpty(authorizationHeader) && authorizationHeader.contains("Basic")) {
String credentials = authorizationHeader.substring(6, authorizationHeader.length());
String[] decodedCredentialParts = new String(Base64Utils.decode(credentials.getBytes())).split(":", 2);
if (!decodedCredentialParts[0].isEmpty() && !decodedCredentialParts[1].isEmpty()) {
Optional<String> decodedCredentials = base64Decode(credentials);
String[] decodedCredentialParts = decodedCredentials
.map(s1 -> s1.split(":", 2))
.orElse(new String[0]);
if (decodedCredentialParts.length >= 2
&& !decodedCredentialParts[0].isEmpty()
&& !decodedCredentialParts[1].isEmpty()) {

return Optional.of(new Credentials(decodedCredentialParts[0], decodedCredentialParts[1]));
}
}
return Optional.empty();
}

private static Optional<String> base64Decode(String input) {
try {
return Optional.of(new String(Base64Utils.decode(input.getBytes())));
} catch (IllegalArgumentException e) {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private List<Map<String,?>> getLoggers() {
.keySet()
.stream()
.map(key -> key.contains("$") ? null : new HashMap<String,Object>() {{
final LoggerLevels logger = (LoggerLevels) loggers.get(key);
final LoggersEndpoint.SingleLoggerLevels logger = (LoggersEndpoint.SingleLoggerLevels) loggers.get(key);
put("name", key);
put("displayName", displayNameOf(key));
put("configuredLevel", logger.getConfiguredLevel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import de.otto.edison.status.indicator.ApplicationStatusAggregator;
import org.springframework.scheduling.annotation.Scheduled;

public final class CronScheduler implements Scheduler {
public class CronScheduler implements Scheduler {

private final ApplicationStatusAggregator aggregator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import de.otto.edison.status.indicator.ApplicationStatusAggregator;
import org.springframework.scheduling.annotation.Scheduled;

public final class EveryTenSecondsScheduler implements Scheduler{
public class EveryTenSecondsScheduler implements Scheduler{

private static final int TEN_SECONDS = 10 * 1000;

Expand Down
2 changes: 1 addition & 1 deletion edison-core/src/main/resources/templates/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h3 class="panel-title">Version</h3>
<dt>Commit Message:</dt>
<dd th:text="${vcs.messageShort}">Short Message</dd>
<dt>Commit ID:</dt>
<dd th:text="${vcs.commitId}">Git commit</dd>
<dd th:text="${vcs.commitIdAbbrev}">Git commit</dd>
<dt>Commit Time:</dt>
<dd th:text="${vcs.commitTime}">Git time</dd>
<dt>Branch:</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void shouldGetInternalStatusAsMonitoringStatusJson() throws IOException {

then(
assertThat(the_status_code().value(), is(200)),
assertThat(the_response_headers().get("Content-Type"), contains("application/vnd.otto.monitoring.status+json;charset=UTF-8"))
assertThat(the_response_headers().get("Content-Type"), contains("application/vnd.otto.monitoring.status+json"))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public void shouldReturnEmptyCredentialsIfUsernameNotSet() {
assertThat(credentials.isPresent(), is(false));
}

@Test
public void shouldReturnEmptyCredentialsIfAnotherAuthorizationSchemeThanBasicIsUsed() {
// given
when(httpServletRequest.getHeader("Authorization"))
.thenReturn(
"Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");

// when
final Optional<Credentials> credentials = Credentials.readFrom(httpServletRequest);

// then
assertThat(credentials.isPresent(), is(false));
}

@Test
public void shouldReturnCorrectCredentialsIfPasswordContainsColons() {
// given
Expand All @@ -88,4 +102,29 @@ public void shouldReturnCorrectCredentialsIfPasswordContainsColons() {
assertThat(credentials.get().getUsername(), is("user"));
assertThat(credentials.get().getPassword(), is("pass:word"));
}

@Test
public void shouldReturnEmptyCredentialsIfColonDoesNotExist() {
// given
mockHttpServletRequestWithAuthentication("userpass");

// when
final Optional<Credentials> credentials = Credentials.readFrom(httpServletRequest);

// then
assertThat(credentials.isPresent(), is(false));
}

@Test
public void shouldReturnEmptyCredentialsIfAuthenticationNotBasic() {
// given
when(httpServletRequest.getHeader("Authorization"))
.thenReturn("Bearer someToken");

// when
final Optional<Credentials> credentials = Credentials.readFrom(httpServletRequest);

// then
assertThat(credentials.isPresent(), is(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public void shouldDisableEndpoint() {
@Configuration
static class TestEndpointConfiguration {
@Bean
Object someTestMvcEndpoint() {
static Object someTestMvcEndpoint() {
return new Object();
}
}

@Configuration
static class RemoveTestEndpointConfiguration {
@Bean
DisableEndpointPostProcessor withoutSomeBean() {
static DisableEndpointPostProcessor withoutSomeBean() {
return new DisableEndpointPostProcessor("someTest");
}
}
Expand Down
10 changes: 9 additions & 1 deletion edison-core/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@ spring:
favor-parameter: true
media-types:
html: text/html
#jmx:
# enabled: true

# context + port of the application
server:
servlet:
context-path: /testcore
port: 8084



# context of the management endpoints like metrics, health, and so on
# default is /actuator
management:
endpoints:
web:
base-path: /actuator
expose: '*'
exposure:
include: '*'
endpoint:
loggers:
enabled: true

# edison-specific configuration
edison:
Expand Down
5 changes: 5 additions & 0 deletions edison-jobs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ dependencies {

implementation libraries.mongodb_driver
implementation project(":edison-mongo")
implementation libraries.aws_sdk_dynamodb

implementation project(":edison-core")

implementation group: 'io.micrometer', name: 'micrometer-core', version: '1.2.0'
implementation libraries.jcip_annotations
Expand All @@ -20,6 +23,8 @@ dependencies {
testImplementation test_libraries.json_path
testImplementation test_libraries.jsonassert
testImplementation test_libraries.embedded_mongo
testImplementation test_libraries.testcontainers

}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.otto.edison.jobs.configuration;

import de.otto.edison.jobs.repository.JobMetaRepository;
import de.otto.edison.jobs.repository.JobRepository;
import de.otto.edison.jobs.repository.dynamo.DynamoJobMetaRepository;
import de.otto.edison.jobs.repository.dynamo.DynamoJobRepository;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;

import static org.slf4j.LoggerFactory.getLogger;

@Configuration
@ConditionalOnProperty(prefix = "edison.jobs", name = "dynamo.enabled", havingValue = "true")
@ConditionalOnBean(type = "software.amazon.awssdk.services.dynamodb.DynamoDbClient")
public class DynamoJobsConfiguration {

private static final Logger LOG = getLogger(DynamoJobsConfiguration.class);

@Bean
public JobRepository jobRepository(final DynamoDbClient dynamoDbClient,
final @Value("${edison.jobs.dynamo.jobinfo.tableName}") String tableName,
final @Value("${edison.jobs.dynamo.jobinfo.pageSize}") int pageSize) {
LOG.info("===============================");
LOG.info("Using DynamoJobRepository with tableName {} and pageSize {}.",tableName, pageSize);
LOG.info("===============================");
return new DynamoJobRepository(dynamoDbClient, tableName, pageSize);
}

@Bean
public JobMetaRepository jobMetaRepository(final DynamoDbClient dynamoDbClient,
final @Value("${edison.jobs.dynamo.jobmeta.tableName}") String tableName) {
LOG.info("===============================");
LOG.info("Using DynamoJobMetaRepository with tableName {}.", tableName);
LOG.info("===============================");
return new DynamoJobMetaRepository(dynamoDbClient, tableName);
}

}
Loading

0 comments on commit 469ba66

Please sign in to comment.