AdminReactiveApplicationTest.java 2.45 KB
Newer Older
1
/*
2
 * Copyright 2014-2018 the original author or authors.
3 4 5 6 7
 *
 * 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
 *
Johannes Edmeier committed
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9 10 11 12 13 14 15
 *
 * 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.
 */
16

17 18 19 20
package de.codecentric.boot.admin.server;

import de.codecentric.boot.admin.server.config.EnableAdminServer;

21
import org.junit.After;
Johannes Edmeier committed
22 23
import org.junit.Before;
import org.springframework.boot.SpringBootConfiguration;
24
import org.springframework.boot.WebApplicationType;
25
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
26 27 28 29 30 31
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
32

33
public class AdminReactiveApplicationTest extends AbstractAdminApplicationTest {
34
    private ConfigurableApplicationContext instance;
35

Johannes Edmeier committed
36
    @Before
37
    public void setUp() {
38 39 40
        instance = new SpringApplicationBuilder().sources(TestAdminApplication.class)
                                                 .web(WebApplicationType.REACTIVE)
                                                 .run("--server.port=0", "--management.endpoints.web.base-path=/mgmt",
41
                                                     "--info.test=foobar", "--eureka.client.enabled=false");
42

43
        super.setUp(instance.getEnvironment().getProperty("local.server.port", Integer.class, 0));
Johannes Edmeier committed
44
    }
45

46 47 48
    @After
    public void shutdown() {
        instance.close();
Johannes Edmeier committed
49
    }
50 51

    @EnableAdminServer
Johannes Edmeier committed
52 53
    @EnableAutoConfiguration
    @SpringBootConfiguration
54
    @EnableWebFluxSecurity
55
    public static class TestAdminApplication {
56 57

        @Bean
58
        public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
59
            return http.authorizeExchange().anyExchange().permitAll().and().csrf().disable().build();
60 61
        }

62 63
    }
}