WebFlux HTTP Basic & Form Login Sessions
By default both HTTP Basic and form log are enabled. Now HTTP Session will not be used for HTTP Basic, but will be for form log in.
This commit is contained in:
@@ -22,11 +22,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.ExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||
|
||||
@@ -89,28 +87,6 @@ public class HelloWebfluxApplicationITests {
|
||||
.expectBody().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWorks() throws Exception {
|
||||
ExchangeResult result = this.rest
|
||||
.mutate()
|
||||
.filter(userCredentials())
|
||||
.build()
|
||||
.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.returnResult(String.class);
|
||||
|
||||
ResponseCookie session = result.getResponseCookies().getFirst("SESSION");
|
||||
|
||||
this.rest
|
||||
.get()
|
||||
.uri("/")
|
||||
.cookie(session.getName(), session.getValue())
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
|
||||
private ExchangeFilterFunction userCredentials() {
|
||||
return basicAuthentication("user","user");
|
||||
}
|
||||
|
||||
@@ -23,11 +23,9 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.ExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||
|
||||
@@ -91,28 +89,6 @@ public class HelloWebfluxApplicationTests {
|
||||
.expectBody().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWorks() throws Exception {
|
||||
ExchangeResult result = this.rest
|
||||
.mutate()
|
||||
.filter(userCredentials())
|
||||
.build()
|
||||
.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.returnResult(String.class);
|
||||
|
||||
ResponseCookie session = result.getResponseCookies().getFirst("SESSION");
|
||||
|
||||
this.rest
|
||||
.get()
|
||||
.uri("/")
|
||||
.cookie(session.getName(), session.getValue())
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mockSupportWhenValidMockUserThenOk() throws Exception {
|
||||
this.rest
|
||||
|
||||
@@ -22,11 +22,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.ExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||
|
||||
@@ -88,28 +86,6 @@ public class HelloWebfluxFnApplicationITests {
|
||||
.expectBody().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWorks() throws Exception {
|
||||
ExchangeResult result = this.rest
|
||||
.mutate()
|
||||
.filter(userCredentials())
|
||||
.build()
|
||||
.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.returnResult(String.class);
|
||||
|
||||
ResponseCookie session = result.getResponseCookies().getFirst("SESSION");
|
||||
|
||||
this.rest
|
||||
.get()
|
||||
.uri("/")
|
||||
.cookie(session.getName(), session.getValue())
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
|
||||
private ExchangeFilterFunction userCredentials() {
|
||||
return basicAuthentication("user","user");
|
||||
}
|
||||
|
||||
@@ -22,12 +22,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.ExchangeResult;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
@@ -95,28 +93,6 @@ public class HelloWebfluxFnApplicationTests {
|
||||
.expectBody().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWorks() throws Exception {
|
||||
ExchangeResult result = this.rest
|
||||
.mutate()
|
||||
.filter(userCredentials())
|
||||
.build()
|
||||
.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.returnResult(String.class);
|
||||
|
||||
ResponseCookie session = result.getResponseCookies().getFirst("SESSION");
|
||||
|
||||
this.rest
|
||||
.get()
|
||||
.uri("/")
|
||||
.cookie(session.getName(), session.getValue())
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mockSupportWhenValidMockUserThenOk() throws Exception {
|
||||
this.rest
|
||||
|
||||
Reference in New Issue
Block a user