Skip to content

Commit

Permalink
Fix AutoConfigureAfter for SecretsManagerAutoConfiguration (#1235)
Browse files Browse the repository at this point in the history
Fixes #1232
  • Loading branch information
marcindabrowski authored Sep 26, 2024
1 parent d491d81 commit c6a99ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
package io.awspring.cloud.autoconfigure.config.secretsmanager;

import io.awspring.cloud.autoconfigure.core.AwsAutoConfiguration;
import io.awspring.cloud.autoconfigure.core.AwsClientBuilderConfigurer;
import io.awspring.cloud.autoconfigure.core.AwsClientCustomizer;
import io.awspring.cloud.autoconfigure.core.AwsConnectionDetails;
import io.awspring.cloud.autoconfigure.core.CredentialsProviderAutoConfiguration;
import io.awspring.cloud.autoconfigure.core.RegionProviderAutoConfiguration;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -33,15 +31,15 @@
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder;

/**
* {@link EnableAutoConfiguration Auto-Configuration} for Secrets Manager integration.
* {@link AutoConfiguration Auto-Configuration} for Secrets Manager integration.
*
* @author Maciej Walkowiak
* @since 3.2.0
*/
@AutoConfiguration
@EnableConfigurationProperties(SecretsManagerProperties.class)
@ConditionalOnClass({ SecretsManagerClient.class })
@AutoConfigureAfter({ CredentialsProviderAutoConfiguration.class, RegionProviderAutoConfiguration.class })
@AutoConfigureAfter(AwsAutoConfiguration.class)
@ConditionalOnProperty(name = "spring.cloud.aws.secretsmanager.enabled", havingValue = "true", matchIfMissing = true)
public class SecretsManagerAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.awspring.cloud.autoconfigure.core;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
Expand All @@ -28,6 +29,7 @@
* @since 3.0
*/
@AutoConfiguration
@AutoConfigureAfter({ CredentialsProviderAutoConfiguration.class, RegionProviderAutoConfiguration.class })
@EnableConfigurationProperties(AwsProperties.class)
public class AwsAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2013-2024 the original author or 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
*
* https://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.
*/
package io.awspring.cloud.autoconfigure.core;

import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

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

/**
* Tests for {@link AwsAutoConfiguration}.
*
* @author Marcin Dąbrowski
*/
class AwsAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withPropertyValues("spring.cloud.aws.region.static:eu-west-1")
.withConfiguration(AutoConfigurations.of(AwsAutoConfiguration.class,
CredentialsProviderAutoConfiguration.class, RegionProviderAutoConfiguration.class));

@Test
void createsAwsClientBuilderConfigurerBeanByDefault() {
this.contextRunner.run(context -> assertThat(context).hasSingleBean(AwsClientBuilderConfigurer.class));
}
}

0 comments on commit c6a99ad

Please sign in to comment.