Skip to content

Commit

Permalink
DATAGO-81464: OAuth2 conditional auto configuration activation issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mayur-solace committed Jul 26, 2024
1 parent 01290f7 commit 9a867dc
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.solace.spring.boot.autoconfigure;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import com.solacesystems.jcsmp.SolaceSessionOAuth2TokenProvider;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
Expand Down Expand Up @@ -42,4 +44,20 @@ void verifyApplicationContextContainsRequiredBeans2() {
context.getBean(AuthorizedClientServiceOAuth2AuthorizedClientManager.class)).isNotNull();
}
}

@Test
void verifyApplicationContextDoesNotContainOAuth2BeansWhenAuthSchemeIsNotOAuth2() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder()
.profiles("oauthConfigIT").sources(TestApp.class)
.properties(String.format("%s=%s", "solace.java.apiProperties.AUTHENTICATION_SCHEME",
"AUTHENTICATION_SCHEME_BASIC"))
.run()) {
assertThat(context.isRunning()).isTrue();

assertThatThrownBy(() -> context.getBean(SolaceSessionOAuth2TokenProvider.class))
.isInstanceOf(NoSuchBeanDefinitionException.class);
assertThatThrownBy(() -> context.getBean(AuthorizedClientServiceOAuth2AuthorizedClientManager.class))
.isInstanceOf(NoSuchBeanDefinitionException.class);
}
}
}

0 comments on commit 9a867dc

Please sign in to comment.