Skip to content

Commit

Permalink
Cleanup some unused test resources (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvmw committed Dec 22, 2023
1 parent 5d86d70 commit 512c459
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.config.client.ConfigClientProperties;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -40,7 +39,6 @@
"spring.cloud.config.client.oauth2.client-id=id",
"spring.cloud.config.client.oauth2.client-secret=secret",
"spring.cloud.config.client.oauth2.access-token-uri=http://uaa.local/token/uri" })
@ActiveProfiles("integration-test")
@WireMockTest(proxyMode = true)
public class ConfigResourceClientTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
* @author Dylan Roberts
*/
@SpringBootTest(classes = ConfigServerTestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.profiles.active=plaintext,native", "spring.cloud.config.enabled=true",
"eureka.client.enabled=false", "spring.config.import=optional:configserver:" })
properties = { "spring.cloud.config.enabled=true", "spring.config.import=optional:configserver:" })
public class OAuth2ConfigResourceClientTest {

// @formatter:off
Expand Down Expand Up @@ -81,12 +80,12 @@ public void setup() {

@Test
public void shouldFindSimplePlainFile() {
assertThat(read(configClient.getPlainTextResource(null, "master", "nginx.conf"))).isEqualTo(NGINX_CONFIG);
assertThat(read(configClient.getPlainTextResource(null, "main", "nginx.conf"))).isEqualTo(NGINX_CONFIG);

assertThat(read(configClient.getPlainTextResource("dev", "master", "nginx.conf"))).isEqualTo(DEV_NGINX_CONFIG);
assertThat(read(configClient.getPlainTextResource("dev", "main", "nginx.conf"))).isEqualTo(DEV_NGINX_CONFIG);

configClientProperties.setProfile("test");
assertThat(read(configClient.getPlainTextResource(null, "master", "nginx.conf"))).isEqualTo(TEST_NGINX_CONFIG);
assertThat(read(configClient.getPlainTextResource(null, "main", "nginx.conf"))).isEqualTo(TEST_NGINX_CONFIG);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = PropertyMaskingEnvironmentPostProcessorTest.TestVaultApplication.class,
loader = PropertyMaskingEnvironmentPostProcessorTest.VaultPropertySourceContextLoader.class)
public class PropertyMaskingEnvironmentPostProcessorTest {

private static final String VAULT_TEST_SANITIZE_PROPERTY = "MyHiddenVaultData";
Expand All @@ -41,6 +43,36 @@ public class PropertyMaskingEnvironmentPostProcessorTest {

private static final String GIT_TEST_NON_SANITIZE_PROPERTY = "ReadableProperty";

@Autowired
Environment environment;

@Test
public void vaultPropertyIsIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).contains(VAULT_TEST_SANITIZE_PROPERTY);
}

@Test
public void credhubPropertyIsIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).contains(CREDHUB_TEST_SANITIZE_PROPERTY);
}

@Test
public void gitPropertyIsNotIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).doesNotContain(GIT_TEST_NON_SANITIZE_PROPERTY);
}

@SpringBootApplication
public static class TestVaultApplication {

Expand Down Expand Up @@ -77,41 +109,4 @@ protected ConfigurableEnvironment getEnvironment() {

}

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles({ "integration-test", "native" })
@ContextConfiguration(classes = TestVaultApplication.class, loader = VaultPropertySourceContextLoader.class)
public static class TestVaultConfigClientProperties {

@Autowired
Environment environment;

@Test
public void vaultPropertyIsIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).contains(VAULT_TEST_SANITIZE_PROPERTY);
}

@Test
public void credhubPropertyIsIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).contains(CREDHUB_TEST_SANITIZE_PROPERTY);
}

@Test
public void gitPropertyIsNotIncludedInSanitizeEndpoints() {
String sanitizeEndpointsProp = environment
.getProperty(PropertyMaskingEnvironmentPostProcessor.SANITIZE_ENV_KEY);

assertThat(sanitizeEndpointsProp).isNotNull();
assertThat(sanitizeEndpointsProp).doesNotContain(GIT_TEST_NON_SANITIZE_PROPERTY);
}

}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
spring:
main:
banner-mode: "off"
profiles:
active: native

This file was deleted.

Binary file not shown.

0 comments on commit 512c459

Please sign in to comment.