Commit 2b748a7b authored by Andy Wilkinson's avatar Andy Wilkinson

Fix SampleOAuth2SsoApplicationTests

The redirect happens in two stages, first from / to /login on localhost
and then to github.com. This commit updates the test to check that the
first redirect has worked, i.e. from / to /login on localhost.
parent 315e63b0
package sample.secure.sso; package sample.secure.sso;
import static org.hamcrest.CoreMatchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -19,6 +13,12 @@ import org.springframework.test.context.web.WebAppConfiguration; ...@@ -19,6 +13,12 @@ import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import static org.hamcrest.CoreMatchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
/** /**
* Series of automated integration tests to verify proper behavior of auto-configured, * Series of automated integration tests to verify proper behavior of auto-configured,
* OAuth2-secured system * OAuth2-secured system
...@@ -47,8 +47,9 @@ public class SampleOAuth2SsoApplicationTests { ...@@ -47,8 +47,9 @@ public class SampleOAuth2SsoApplicationTests {
@Test @Test
public void everythingIsSecuredByDefault() throws Exception { public void everythingIsSecuredByDefault() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isFound()) this.mvc.perform(get("/"))
.andExpect(header().string("location", containsString("github.com"))); .andExpect(status().isFound())
.andExpect(header().string("location", containsString("localhost/login")));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment