|
|
|
@ -23,8 +23,6 @@ import org.mockito.junit.MockitoJUnitRunner; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.mock.web.server.MockServerWebExchange; |
|
|
|
import org.springframework.mock.web.server.MockServerWebExchange; |
|
|
|
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; |
|
|
|
|
|
|
|
import org.springframework.security.core.AuthenticationException; |
|
|
|
|
|
|
|
import org.springframework.web.server.ServerWebExchange; |
|
|
|
import org.springframework.web.server.ServerWebExchange; |
|
|
|
|
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
@ -47,16 +45,14 @@ public class DefaultServerRedirectStrategyTests { |
|
|
|
private DefaultServerRedirectStrategy strategy = |
|
|
|
private DefaultServerRedirectStrategy strategy = |
|
|
|
new DefaultServerRedirectStrategy(); |
|
|
|
new DefaultServerRedirectStrategy(); |
|
|
|
|
|
|
|
|
|
|
|
private AuthenticationException exception = new AuthenticationCredentialsNotFoundException("Authentication Required"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
public void sendRedirectWhenLocationNullThenException() { |
|
|
|
public void sendRedirectWhenLocationNullThenException() { |
|
|
|
this.strategy.sendRedirect(this.exchange, (URI) null); |
|
|
|
this.strategy.sendRedirect(this.exchange, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
public void sendRedirectWhenExchangeNullThenException() { |
|
|
|
public void sendRedirectWhenExchangeNullThenException() { |
|
|
|
this.strategy.sendRedirect((ServerWebExchange) null, this.location); |
|
|
|
this.strategy.sendRedirect(null, this.location); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -67,7 +63,7 @@ public class DefaultServerRedirectStrategyTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void sendRedirectWhenNoContextThenStatusAndLocationSet() { |
|
|
|
public void sendRedirectWhenNoContextPathThenStatusAndLocationSet() { |
|
|
|
this.exchange = exchange(MockServerHttpRequest.get("/")); |
|
|
|
this.exchange = exchange(MockServerHttpRequest.get("/")); |
|
|
|
|
|
|
|
|
|
|
|
this.strategy.sendRedirect(this.exchange, this.location).block(); |
|
|
|
this.strategy.sendRedirect(this.exchange, this.location).block(); |
|
|
|
@ -122,7 +118,7 @@ public class DefaultServerRedirectStrategyTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
@Test(expected = IllegalArgumentException.class) |
|
|
|
public void setHttpStatusWhenNullLocationThenException() { |
|
|
|
public void setHttpStatusWhenNullThenException() { |
|
|
|
this.strategy.setHttpStatus(null); |
|
|
|
this.strategy.setHttpStatus(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|