Skip to content

Commit

Permalink
[SHIBUI-1724]
Browse files Browse the repository at this point in the history
changing media types to new version
  • Loading branch information
jj committed Feb 12, 2021
1 parent 7ddfbd6 commit db59610
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand All @@ -34,7 +33,6 @@
* Workaround for slashes in URL from [https://stackoverflow.com/questions/48453980/spring-5-0-3-requestrejectedexception-the-request-was-rejected-because-the-url]
*/
@Configuration
@AutoConfigureBefore(SpringBootWebSecurityConfiguration.class)
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
public class WebSecurityConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class EntitiesControllerTests extends Specification {
then:
def x = content()
result.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json(expectedBody, false))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class EntityDescriptorControllerTests extends Specification {
userRepository.findByUsername(username) >> TestHelpers.generateOptionalUser(username, role)
def emptyRecordsFromRepository = [].stream()
def expectedEmptyListResponseBody = '[]'
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedHttpResponseStatus = status().isOk()

when:
Expand Down Expand Up @@ -153,7 +153,7 @@ class EntityDescriptorControllerTests extends Specification {
]
"""

def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedHttpResponseStatus = status().isOk()

when:
Expand Down Expand Up @@ -229,7 +229,7 @@ class EntityDescriptorControllerTests extends Specification {
]
"""

def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedHttpResponseStatus = status().isOk()

when:
Expand Down Expand Up @@ -282,7 +282,7 @@ class EntityDescriptorControllerTests extends Specification {
]
"""

def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedHttpResponseStatus = status().isOk()

when:
Expand Down Expand Up @@ -361,7 +361,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
post('/api/EntityDescriptor')
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))

then:
Expand Down Expand Up @@ -413,7 +413,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
post('/api/EntityDescriptor')
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))

then:
Expand Down Expand Up @@ -449,7 +449,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
post('/api/EntityDescriptor')
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))

then:
Expand Down Expand Up @@ -933,7 +933,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("/api/EntityDescriptor/$resourceId")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand Down Expand Up @@ -966,7 +966,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("/api/EntityDescriptor/$resourceId")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand All @@ -992,7 +992,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("/api/EntityDescriptor/$resourceId")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand All @@ -1018,7 +1018,7 @@ class EntityDescriptorControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("/api/EntityDescriptor/$resourceId")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders
import spock.lang.Specification
import spock.lang.Subject

import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8
import static org.springframework.http.MediaType.APPLICATION_JSON
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
Expand Down Expand Up @@ -36,7 +36,7 @@ class EntityIdsSearchControllerTests extends Specification {
def limitValue = "5"
def expectedEntityIdsFromSearchService = new EntityIdsSearchResultRepresentation(["http://unicon.instructure.com/saml2", "https://idp.unicon.net/idp/shibboleth"])
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedResponseBody = """
{
"entityIds":[
Expand Down Expand Up @@ -66,7 +66,7 @@ class EntityIdsSearchControllerTests extends Specification {
def limitValue = "1"
def expectedEntityIdsFromSearchService = new EntityIdsSearchResultRepresentation(["http://unicon.instructure.com/saml2"])
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedResponseBody = """
{
"entityIds":[
Expand Down Expand Up @@ -104,7 +104,7 @@ class EntityIdsSearchControllerTests extends Specification {
"https://shibbox.lpplus.net/shibboleth",
"https://shibsp.amherst.edu/shibboleth"])
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedResponseBody = """
{
"entityIds":[
Expand Down Expand Up @@ -141,7 +141,7 @@ class EntityIdsSearchControllerTests extends Specification {
def limitValue = "5"
def expectedEntityIdsFromSearchService = new EntityIdsSearchResultRepresentation([])
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedResponseBody = """
{
"entityIds":[]
Expand All @@ -168,7 +168,7 @@ class EntityIdsSearchControllerTests extends Specification {
def limitValue = NO_LIMIT
def expectedEntityIdsFromSearchService = new EntityIdsSearchResultRepresentation([])
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON
def expectedResponseBody = """
{
"entityIds":[]
Expand All @@ -188,4 +188,4 @@ class EntityIdsSearchControllerTests extends Specification {
.andExpect(content().contentType(expectedResponseContentType))
.andExpect(content().json(expectedResponseBody, true))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import spock.lang.Specification
import spock.lang.Unroll

import static org.hamcrest.CoreMatchers.containsString
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8
import static org.springframework.http.MediaType.APPLICATION_JSON
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*

Expand Down Expand Up @@ -106,7 +106,7 @@ class MetadataFiltersControllerTests extends Specification {
1 * metadataResolverRepository.findByResourceId(_) >> metadataResolver

def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON

when:
def result = mockMvc.perform(get("$BASE_URI/foo/Filters"))
Expand All @@ -127,7 +127,7 @@ class MetadataFiltersControllerTests extends Specification {

def expectedResourceId = expectedFilter.resourceId
def expectedHttpResponseStatus = status().isOk()
def expectedResponseContentType = APPLICATION_JSON_UTF8
def expectedResponseContentType = APPLICATION_JSON

when:
def result = mockMvc.perform(get("$BASE_URI/foo/Filters/$expectedResourceId"))
Expand Down Expand Up @@ -163,7 +163,7 @@ class MetadataFiltersControllerTests extends Specification {
when:
def result = mockMvc.perform(
post("$BASE_URI/foo/Filters")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand Down Expand Up @@ -208,7 +208,7 @@ class MetadataFiltersControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("$BASE_URI/foo/Filters/$filterUUID")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand Down Expand Up @@ -245,7 +245,7 @@ class MetadataFiltersControllerTests extends Specification {
when:
def result = mockMvc.perform(
put("$BASE_URI/foo/Filters/$filterUUID")
.contentType(APPLICATION_JSON_UTF8)
.contentType(APPLICATION_JSON)
.content(postedJsonBody))
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class UsersControllerIntegrationTests extends Specification {
then: 'Request completed with HTTP 200 and returned a list of users'
result
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json(expectedJson, false))
}
Expand All @@ -106,7 +106,7 @@ class UsersControllerIntegrationTests extends Specification {
then: 'Request completed with HTTP 200 and returned one user'
result
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json(expectedJson, false))
}
Expand Down Expand Up @@ -156,7 +156,7 @@ class UsersControllerIntegrationTests extends Specification {

when:
def result = mockMvc.perform(post(RESOURCE_URI)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser))
.accept(MediaType.APPLICATION_JSON))

Expand All @@ -177,11 +177,11 @@ class UsersControllerIntegrationTests extends Specification {

when:
mockMvc.perform(post(RESOURCE_URI)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser))
.accept(MediaType.APPLICATION_JSON))
def result = mockMvc.perform(post(RESOURCE_URI)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser))
.accept(MediaType.APPLICATION_JSON))

Expand All @@ -202,7 +202,7 @@ class UsersControllerIntegrationTests extends Specification {

when:
def result = mockMvc.perform(post(RESOURCE_URI)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser))
.accept(MediaType.APPLICATION_JSON))

Expand All @@ -212,7 +212,7 @@ class UsersControllerIntegrationTests extends Specification {
when:
newUser['firstName'] = 'Bob'
result = mockMvc.perform(patch("$RESOURCE_URI/$newUser.username")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser))
.accept(MediaType.APPLICATION_JSON))

Expand All @@ -232,7 +232,7 @@ class UsersControllerIntegrationTests extends Specification {

when:
def result = mockMvc.perform(patch("$RESOURCE_URI/$newUser.username")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(JsonOutput.toJson(newUser)))

then:
Expand Down

0 comments on commit db59610

Please sign in to comment.