Skip to content

Commit

Permalink
docker: fixes spring config in zipkin-eureka test image
Browse files Browse the repository at this point in the history
Formerly, we didn't test the authenticated side, so some review drift
passed even though authenticating would crash on startup:

```
Parameter 0 of method filterChain in zipkin.test.EurekaSecurity required a bean of type 'org.springframework.security.config.annotation.web.builders.HttpSecurity' that could not be found.
```

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
Adrian Cole committed Jan 23, 2024
1 parent 5ff651f commit b329a4b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
32 changes: 32 additions & 0 deletions build-bin/docker-compose-zipkin-eureka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright 2015-2024 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

# uses 2.4 so we can use condition: service_healthy
version: "2.4"

# Test both authenticated and unauthenticated, as if there is a Spring problem,
# the latter will crash. We only need to use HEALTHCHECK for this.
services:
eureka:
image: openzipkin/zipkin-eureka:test
container_name: eureka
sut:
image: openzipkin/zipkin-eureka:test
container_name: sut
environment:
EUREKA_USERNAME: testuser
EUREKA_PASSWORD: testpassword
depends_on:
eureka:
condition: service_healthy
9 changes: 7 additions & 2 deletions docker/test-images/zipkin-eureka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
The `zipkin-eureka` testing image runs Eureka Server for service discovery
integration of the Zipkin server. This listens on port 8761.

Besides norms defined in [docker-java](https://github.com/openzipkin/docker-java), this accepts the
following environment variables:

* `EUREKA_USERNAME`: password for authenticating endpoints under "/eureka".
* `EUREKA_PASSWORD`: password for authenticating endpoints under "/eureka".
* `JAVA_OPTS`: to change settings such as heap size for Eureka.

To build `openzipkin/zipkin-eureka:test`, from the top-level of the repository, run:
```bash
$ DOCKER_FILE=docker/test-images/zipkin-eureka/Dockerfile build-bin/docker/docker_build openzipkin/zipkin-eureka:test
$ docker run -p 8761:8761 --rm openzipkin/zipkin-eureka:test
```

You can use the env variable `JAVA_OPTS` to change settings such as heap size for Eureka.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*/
package zipkin.test;

import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.userdetails.User;
Expand All @@ -33,7 +33,7 @@
@Configuration
@ConditionalOnProperty("eureka.username")
@EnableConfigurationProperties(EurekaProperties.class)
@ImportAutoConfiguration(SecurityAutoConfiguration.class)
@Import(SecurityAutoConfiguration.class)
public class EurekaSecurity {
@Bean InMemoryUserDetailsManager userDetailsService(EurekaProperties props) {
PasswordEncoder encoder = createDelegatingPasswordEncoder();
Expand Down

0 comments on commit b329a4b

Please sign in to comment.