1
0
mirror of synced 2026-08-04 17:27:13 +00:00

Start AssertJ Migration

Issue gh-3175
This commit is contained in:
Rob Winch
2015-12-16 10:38:31 -06:00
parent 6cbb439701
commit bb600a473e
355 changed files with 3036 additions and 3133 deletions
@@ -1,6 +1,6 @@
package org.springframework.security.openid;
import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -113,7 +113,7 @@ public class OpenID4JavaConsumerTests {
OpenIDAuthenticationToken auth = consumer.endConsumption(request);
assertEquals(OpenIDAuthenticationStatus.FAILURE, auth.getStatus());
assertThat(auth.getStatus()).isEqualTo(OpenIDAuthenticationStatus.FAILURE);
}
@Test
@@ -184,7 +184,7 @@ public class OpenID4JavaConsumerTests {
OpenIDAuthenticationToken auth = consumer.endConsumption(request);
assertEquals(OpenIDAuthenticationStatus.SUCCESS, auth.getStatus());
assertThat(auth.getStatus()).isEqualTo(OpenIDAuthenticationStatus.SUCCESS);
}
@Test
@@ -199,8 +199,8 @@ public class OpenID4JavaConsumerTests {
List<OpenIDAttribute> fetched = consumer.fetchAxAttributes(msg, attributes);
assertEquals(1, fetched.size());
assertEquals(2, fetched.get(0).getValues().size());
assertThat(fetched).hasSize(1);
assertThat(fetched.get(0).getValues()).hasSize(2);
}
@Test(expected = OpenIDConsumerException.class)
@@ -1,6 +1,6 @@
package org.springframework.security.openid;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
@@ -59,16 +59,16 @@ public class OpenIDAuthenticationFilterTests {
public String beginConsumption(HttpServletRequest req,
String claimedIdentity, String returnToUrl, String realm)
throws OpenIDConsumerException {
assertEquals(CLAIMED_IDENTITY_URL, claimedIdentity);
assertEquals(DEFAULT_TARGET_URL, returnToUrl);
assertEquals("http://localhost:8080/", realm);
assertThat(claimedIdentity).isEqualTo(CLAIMED_IDENTITY_URL);
assertThat(returnToUrl).isEqualTo(DEFAULT_TARGET_URL);
assertThat(realm).isEqualTo("http://localhost:8080/");
return REDIRECT_URL;
}
});
FilterChain fc = mock(FilterChain.class);
filter.doFilter(req, response, fc);
assertEquals(REDIRECT_URL, response.getRedirectedUrl());
assertThat(response.getRedirectedUrl()).isEqualTo(REDIRECT_URL);
// Filter chain shouldn't proceed
verify(fc, never()).doFilter(any(HttpServletRequest.class),
any(HttpServletResponse.class));
@@ -88,8 +88,8 @@ public class OpenIDAuthenticationFilterTests {
URI returnTo = new URI(filter.buildReturnToUrl(req));
String query = returnTo.getRawQuery();
assertEquals(1, count(query, '='));
assertEquals(0, count(query, '&'));
assertThat(count(query).isCloseTo(1, within('=')));
assertThat(count(query).isCloseTo(0, within('&')));
}
/**
@@ -54,14 +54,14 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
Authentication preAuth = new OpenIDAuthenticationToken(
OpenIDAuthenticationStatus.CANCELLED, USERNAME, "", null);
assertFalse(preAuth.isAuthenticated());
assertThat(preAuth.isAuthenticated()).isFalse();
try {
provider.authenticate(preAuth);
fail("Should throw an AuthenticationException");
}
catch (AuthenticationCancelledException expected) {
assertEquals("Log in cancelled", expected.getMessage());
assertThat(expected.getMessage()).isEqualTo("Log in cancelled");
}
}
@@ -76,14 +76,14 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
Authentication preAuth = new OpenIDAuthenticationToken(
OpenIDAuthenticationStatus.ERROR, USERNAME, "", null);
assertFalse(preAuth.isAuthenticated());
assertThat(preAuth.isAuthenticated()).isFalse();
try {
provider.authenticate(preAuth);
fail("Should throw an AuthenticationException");
}
catch (AuthenticationServiceException expected) {
assertEquals("Error message from server: ", expected.getMessage());
assertThat(expected.getMessage()).isEqualTo("Error message from server: ");
}
}
@@ -99,7 +99,7 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
Authentication preAuth = new OpenIDAuthenticationToken(
OpenIDAuthenticationStatus.FAILURE, USERNAME, "", null);
assertFalse(preAuth.isAuthenticated());
assertThat(preAuth.isAuthenticated()).isFalse();
try {
provider.authenticate(preAuth);
@@ -122,7 +122,7 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
Authentication preAuth = new OpenIDAuthenticationToken(
OpenIDAuthenticationStatus.SETUP_NEEDED, USERNAME, "", null);
assertFalse(preAuth.isAuthenticated());
assertThat(preAuth.isAuthenticated()).isFalse();
try {
provider.authenticate(preAuth);
@@ -145,19 +145,19 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
Authentication preAuth = new OpenIDAuthenticationToken(
OpenIDAuthenticationStatus.SUCCESS, USERNAME, "", null);
assertFalse(preAuth.isAuthenticated());
assertThat(preAuth.isAuthenticated()).isFalse();
Authentication postAuth = provider.authenticate(preAuth);
assertNotNull(postAuth);
assertTrue(postAuth instanceof OpenIDAuthenticationToken);
assertTrue(postAuth.isAuthenticated());
assertNotNull(postAuth.getPrincipal());
assertTrue(postAuth.getPrincipal() instanceof UserDetails);
assertNotNull(postAuth.getAuthorities());
assertTrue(postAuth.getAuthorities().size() > 0);
assertTrue(((OpenIDAuthenticationToken) postAuth).getStatus() == OpenIDAuthenticationStatus.SUCCESS);
assertTrue(((OpenIDAuthenticationToken) postAuth).getMessage() == null);
assertThat(postAuth).isNotNull();
assertThat(postAuth instanceof OpenIDAuthenticationToken).isTrue();
assertThat(postAuth.isAuthenticated()).isTrue();
assertThat(postAuth.getPrincipal()).isNotNull();
assertThat(postAuth.getPrincipal() instanceof UserDetails).isTrue();
assertThat(postAuth.getAuthorities()).isNotNull();
assertThat(postAuth.getAuthorities().size() > 0).isTrue();
assertThat(((OpenIDAuthenticationToken) postAuth).getStatus() == OpenIDAuthenticationStatus.SUCCESS).isTrue();
assertThat(((OpenIDAuthenticationToken) postAuth).getMessage() == null).isTrue();
}
public void testDetectsMissingAuthoritiesPopulator() throws Exception {
@@ -180,7 +180,7 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
OpenIDAuthenticationProvider provider = new OpenIDAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsService());
assertFalse(provider.supports(UsernamePasswordAuthenticationToken.class));
assertThat(provider.supports(UsernamePasswordAuthenticationToken.class)).isFalse();
}
/*
@@ -193,7 +193,7 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
USERNAME, "password");
assertEquals(null, provider.authenticate(token));
assertThat(provider.authenticate(token)).isEqualTo(null);
}
/*
@@ -204,7 +204,7 @@ public class OpenIDAuthenticationProviderTests extends TestCase {
OpenIDAuthenticationProvider provider = new OpenIDAuthenticationProvider();
provider.setUserDetailsService(new MockUserDetailsService());
assertTrue(provider.supports(OpenIDAuthenticationToken.class));
assertThat(provider.supports(OpenIDAuthenticationToken.class)).isTrue();
}
public void testValidation() throws Exception {