use of io.restassured.module.mockmvc.specification.MockMvcAuthenticationScheme in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method authentication_is_not_overwritten_when_not_defined_in_specification.
@Test
public void authentication_is_not_overwritten_when_not_defined_in_specification() {
// Given
MockMvcAuthenticationScheme thisAuth = RestAssuredMockMvc.principal("this");
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().addQueryParam("param1", "value1").build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().spec(new MockMvcRequestSpecBuilder().setAuth(thisAuth).build()).spec(specToMerge);
// Then
assertThat(((TestingAuthenticationToken) implOf(spec).getAuthentication()).getPrincipal()).isEqualTo("this");
Assertions.assertThat(implOf(spec).getQueryParams()).containsOnly(entry("param1", "value1"));
}
use of io.restassured.module.mockmvc.specification.MockMvcAuthenticationScheme in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method authentication_is_overwritten_when_defined_in_specification.
@Test
public void authentication_is_overwritten_when_defined_in_specification() {
// Given
MockMvcAuthenticationScheme otherAuth = RestAssuredMockMvc.principal("other");
MockMvcAuthenticationScheme thisAuth = RestAssuredMockMvc.principal("this");
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setAuth(otherAuth).build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().spec(new MockMvcRequestSpecBuilder().setAuth(thisAuth).build()).spec(specToMerge);
// Then
assertThat(((TestingAuthenticationToken) implOf(spec).getAuthentication()).getPrincipal()).isEqualTo("other");
}
use of io.restassured.module.mockmvc.specification.MockMvcAuthenticationScheme in project rest-assured by rest-assured.
the class MockMvcRequestSpecificationMergingTest method authentication_is_overwritten_when_using_dsl_and_defined_in_specification.
@Test
public void authentication_is_overwritten_when_using_dsl_and_defined_in_specification() {
// Given
MockMvcAuthenticationScheme otherAuth = RestAssuredMockMvc.principal("other");
MockMvcRequestSpecification specToMerge = new MockMvcRequestSpecBuilder().setAuth(otherAuth).build();
// When
MockMvcRequestSpecification spec = RestAssuredMockMvc.given().auth().principal("this").and().spec(specToMerge);
// Then
assertThat(((TestingAuthenticationToken) implOf(spec).getAuthentication()).getPrincipal()).isEqualTo("other");
}
Aggregations