|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | import org.junit.jupiter.api.Test;
|
23 | 23 |
|
24 | 24 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
| 25 | +import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException; |
25 | 26 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
26 | 27 | import org.springframework.context.annotation.Bean;
|
27 | 28 | import org.springframework.context.annotation.Configuration;
|
@@ -90,6 +91,24 @@ void stopsMeterRegistryWhenContextIsClosed() {
|
90 | 91 | });
|
91 | 92 | }
|
92 | 93 |
|
| 94 | + @Test |
| 95 | + void apiKeyCredentialsIsMutuallyExclusiveWithUserName() { |
| 96 | + this.contextRunner.withUserConfiguration(BaseConfiguration.class) |
| 97 | + .withPropertyValues("management.metrics.export.elastic.api-key-credentials:secret", |
| 98 | + "management.metrics.export.elastic.user-name:alice") |
| 99 | + .run((context) -> assertThat(context).hasFailed().getFailure().getRootCause() |
| 100 | + .isInstanceOf(MutuallyExclusiveConfigurationPropertiesException.class)); |
| 101 | + } |
| 102 | + |
| 103 | + @Test |
| 104 | + void apiKeyCredentialsIsMutuallyExclusiveWithPassword() { |
| 105 | + this.contextRunner.withUserConfiguration(BaseConfiguration.class) |
| 106 | + .withPropertyValues("management.metrics.export.elastic.api-key-credentials:secret", |
| 107 | + "management.metrics.export.elastic.password:secret") |
| 108 | + .run((context) -> assertThat(context).hasFailed().getFailure().getRootCause() |
| 109 | + .isInstanceOf(MutuallyExclusiveConfigurationPropertiesException.class)); |
| 110 | + } |
| 111 | + |
93 | 112 | @Configuration(proxyBeanMethods = false)
|
94 | 113 | static class BaseConfiguration {
|
95 | 114 |
|
|
0 commit comments