Browse Source

Polish tests

pull/6376/head
Johnny Lim 7 years ago committed by Rob Winch
parent
commit
c94f13a971
  1. 6
      config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java
  2. 2
      oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java
  3. 2
      oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java
  4. 2
      web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java

6
config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java

@ -16,6 +16,7 @@
package org.springframework.security.config; package org.springframework.security.config;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.fail;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -57,14 +58,15 @@ public class InvalidConfigurationTests {
public void missingAuthenticationManagerGivesSensibleErrorMessage() { public void missingAuthenticationManagerGivesSensibleErrorMessage() {
try { try {
setContext("<http auto-config='true' />"); setContext("<http auto-config='true' />");
fail();
} }
catch (BeanCreationException e) { catch (BeanCreationException e) {
Throwable cause = ultimateCause(e); Throwable cause = ultimateCause(e);
assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue(); assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue();
NoSuchBeanDefinitionException nsbe = (NoSuchBeanDefinitionException) cause; NoSuchBeanDefinitionException nsbe = (NoSuchBeanDefinitionException) cause;
assertThat(nsbe.getBeanName()).isEqualTo(BeanIds.AUTHENTICATION_MANAGER); assertThat(nsbe.getBeanName()).isEqualTo(BeanIds.AUTHENTICATION_MANAGER);
assertThat(nsbe.getMessage().endsWith( assertThat(nsbe.getMessage()).endsWith(
AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE)); AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE);
} }
} }

2
oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java

@ -140,7 +140,7 @@ public class ClientRegistrationsTest {
@Test @Test
public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception { public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception {
assertThat(registration("")).isNotNull(); assertThat(registration("")).isNotNull();
assertThat(this.issuer.endsWith("/")).isTrue(); assertThat(this.issuer).endsWith("/");
} }
/** /**

2
oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java

@ -97,7 +97,7 @@ public class JwtDecodersTests {
prepareOpenIdConfigurationResponse(); prepareOpenIdConfigurationResponse();
this.server.enqueue(new MockResponse().setBody(JWK_SET)); this.server.enqueue(new MockResponse().setBody(JWK_SET));
assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull(); assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull();
assertThat(this.issuer.endsWith("/")).isTrue(); assertThat(this.issuer).endsWith("/");
} }
@Test @Test

2
web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java

@ -92,7 +92,7 @@ public class AbstractRememberMeServicesTests {
String encoded = services.encodeCookie(cookie); String encoded = services.encodeCookie(cookie);
// '=' aren't allowed in version 0 cookies. // '=' aren't allowed in version 0 cookies.
assertThat(encoded.endsWith("=")).isFalse(); assertThat(encoded).doesNotEndWith("=");
String[] decoded = services.decodeCookie(encoded); String[] decoded = services.decodeCookie(encoded);
assertThat(decoded).containsExactly("name:with:colon", "cookie", "tokens", "blah"); assertThat(decoded).containsExactly("name:with:colon", "cookie", "tokens", "blah");

Loading…
Cancel
Save