Skip to content

Commit

Permalink
adding a test for the PreAuthenticationAutoConfigurationTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
pmauduit committed Oct 12, 2023
1 parent c10349d commit 73ace03
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.georchestra.gateway.autoconfigure.security;

import org.georchestra.gateway.security.preauth.ResolveHttpHeadersGeorchestraUserFilter;
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;

public class PreAuthenticationAutoConfigurationTest {
private ApplicationContextRunner runner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(PreAuthenticationAutoConfiguration.class));

public @Test void resolveHttpHeadersGeorchestraUserFilterIsAvailable() {
runner.withPropertyValues(""//
, "georchestra.gateway.headerAuthentication: true" //
).run(context -> {
assertThat(context).hasNotFailed().hasSingleBean(ResolveHttpHeadersGeorchestraUserFilter.class);
});
}

public @Test void resolveHttpHeadersGeorchestraUserFilterIsUnavailable() {
runner.withPropertyValues(""//
, "georchestra.gateway.headerAuthentication: false" //
).run(context -> {
assertThat(context).hasNotFailed().doesNotHaveBean(ResolveHttpHeadersGeorchestraUserFilter.class);
});
}
}

0 comments on commit 73ace03

Please sign in to comment.