|
|
@ -19,6 +19,9 @@ package org.springframework.boot.actuate.autoconfigure.wavefront;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
|
|
|
|
|
|
import com.wavefront.sdk.common.WavefrontSender;
|
|
|
|
import com.wavefront.sdk.common.WavefrontSender;
|
|
|
|
|
|
|
|
import com.wavefront.sdk.common.clients.service.token.CSPTokenService;
|
|
|
|
|
|
|
|
import com.wavefront.sdk.common.clients.service.token.NoopProxyTokenService;
|
|
|
|
|
|
|
|
import com.wavefront.sdk.common.clients.service.token.WavefrontTokenService;
|
|
|
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
|
|
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +30,7 @@ import org.springframework.boot.test.context.FilteredClassLoader;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.as;
|
|
|
|
import static org.assertj.core.api.Assertions.as;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
@ -118,6 +122,51 @@ class WavefrontSenderConfigurationTests {
|
|
|
|
.run((context) -> assertThat(context).hasSingleBean(WavefrontSender.class).hasBean("customSender"));
|
|
|
|
.run((context) -> assertThat(context).hasSingleBean(WavefrontSender.class).hasBean("customSender"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void shouldApplyTokenTypeWavefrontApiToken() {
|
|
|
|
|
|
|
|
this.contextRunner
|
|
|
|
|
|
|
|
.withPropertyValues("management.wavefront.api-token-type=WAVEFRONT_API_TOKEN",
|
|
|
|
|
|
|
|
"management.wavefront.api-token=abcde")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
WavefrontSender sender = context.getBean(WavefrontSender.class);
|
|
|
|
|
|
|
|
Object tokenService = ReflectionTestUtils.getField(sender, "tokenService");
|
|
|
|
|
|
|
|
assertThat(tokenService).isInstanceOf(WavefrontTokenService.class);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void shouldApplyTokenTypeCspApiToken() {
|
|
|
|
|
|
|
|
this.contextRunner
|
|
|
|
|
|
|
|
.withPropertyValues("management.wavefront.api-token-type=CSP_API_TOKEN",
|
|
|
|
|
|
|
|
"management.wavefront.api-token=abcde")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
WavefrontSender sender = context.getBean(WavefrontSender.class);
|
|
|
|
|
|
|
|
Object tokenService = ReflectionTestUtils.getField(sender, "tokenService");
|
|
|
|
|
|
|
|
assertThat(tokenService).isInstanceOf(CSPTokenService.class);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void shouldApplyTokenTypeCspClientCredentials() {
|
|
|
|
|
|
|
|
this.contextRunner
|
|
|
|
|
|
|
|
.withPropertyValues("management.wavefront.api-token-type=CSP_CLIENT_CREDENTIALS",
|
|
|
|
|
|
|
|
"management.wavefront.api-token=clientid=cid,clientsecret=csec")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
WavefrontSender sender = context.getBean(WavefrontSender.class);
|
|
|
|
|
|
|
|
Object tokenService = ReflectionTestUtils.getField(sender, "tokenService");
|
|
|
|
|
|
|
|
assertThat(tokenService).isInstanceOf(CSPTokenService.class);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void shouldApplyTokenTypeNoToken() {
|
|
|
|
|
|
|
|
this.contextRunner.withPropertyValues("management.wavefront.api-token-type=NO_TOKEN").run((context) -> {
|
|
|
|
|
|
|
|
WavefrontSender sender = context.getBean(WavefrontSender.class);
|
|
|
|
|
|
|
|
Object tokenService = ReflectionTestUtils.getField(sender, "tokenService");
|
|
|
|
|
|
|
|
assertThat(tokenService).isInstanceOf(NoopProxyTokenService.class);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
static class CustomSenderConfiguration {
|
|
|
|
static class CustomSenderConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|