diff --git a/examples/rally-api/src/integration-test/groovy/yakworks/rest/ExceptionHandlerRestApiSpec.groovy b/examples/rally-api/src/integration-test/groovy/yakworks/rest/ExceptionHandlerRestApiSpec.groovy index 4bf30f534..b29ba4596 100644 --- a/examples/rally-api/src/integration-test/groovy/yakworks/rest/ExceptionHandlerRestApiSpec.groovy +++ b/examples/rally-api/src/integration-test/groovy/yakworks/rest/ExceptionHandlerRestApiSpec.groovy @@ -1,23 +1,11 @@ package yakworks.rest -import org.apache.poi.xssf.usermodel.XSSFWorkbook -import org.springframework.http.HttpStatus - import gorm.tools.transaction.WithTrx -import grails.gorm.transactions.Rollback import grails.testing.mixin.integration.Integration -import okhttp3.HttpUrl -import okhttp3.Request -import okhttp3.RequestBody import okhttp3.Response import spock.lang.Specification -import yakworks.rally.orgs.model.Contact -import yakworks.rally.orgs.model.Org -import yakworks.rally.tag.model.Tag import yakworks.rest.client.OkHttpRestTrait -import static yakworks.etl.excel.ExcelUtils.getHeader - @Integration class ExceptionHandlerRestApiSpec extends Specification implements OkHttpRestTrait, WithTrx { @@ -64,4 +52,16 @@ class ExceptionHandlerRestApiSpec extends Specification implements OkHttpRestTra body.code == "error.unexpected" body.detail.contains('nested exception is Assertion failed') } + + void "request method not supported - login"() { + when: + Response resp = get("/api/oauth/token") + Map body = bodyToMap(resp) + + then: + body + body.containsKey('ok') + !body.ok + body.code + } } diff --git a/gorm-tools/src/main/groovy/gorm/tools/problem/ProblemHandler.groovy b/gorm-tools/src/main/groovy/gorm/tools/problem/ProblemHandler.groovy index aaff336dc..79f994ed3 100644 --- a/gorm-tools/src/main/groovy/gorm/tools/problem/ProblemHandler.groovy +++ b/gorm-tools/src/main/groovy/gorm/tools/problem/ProblemHandler.groovy @@ -18,6 +18,7 @@ import org.springframework.dao.DataIntegrityViolationException import org.springframework.http.converter.HttpMessageNotReadableException import org.springframework.validation.Errors import org.springframework.validation.ObjectError +import org.springframework.web.HttpRequestMethodNotSupportedException import gorm.tools.repository.errors.EmptyErrors import yakworks.api.ApiStatus @@ -101,7 +102,8 @@ class ProblemHandler { else if (e instanceof DataAccessException) { return buildFromDataAccessException(e) } - else if (e instanceof HttpMessageNotReadableException || e instanceof JsonException) { + else if (e instanceof HttpMessageNotReadableException || e instanceof JsonException + || e instanceof HttpRequestMethodNotSupportedException) { //this happens if request contains bad data / malformed json. we dont want to log stacktraces for these as they are expected return DataProblem.of(e) }