Skip to content

Commit 2dde089

Browse files
Bump org.jmailen.kotlinter from 3.9.0 to 3.12.0 (#220)
Bumps org.jmailen.kotlinter from 3.9.0 to 3.12.0. --- updated-dependencies: - dependency-name: org.jmailen.kotlinter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent b22165e commit 2dde089

File tree

15 files changed

+41
-76
lines changed

15 files changed

+41
-76
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
`maven-publish`
1515
jacoco
1616
id("com.github.kt3k.coveralls") version "2.12.0"
17-
id("org.jmailen.kotlinter") version "3.9.0"
17+
id("org.jmailen.kotlinter") version "3.12.0"
1818
}
1919

2020
group = "com.github.moia-dev"

router-openapi-request-validator/src/main/kotlin/io/moia/router/openapi/OpenApiValidator.kt

+22-16
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,38 @@ class OpenApiValidator(val specUrlOrPayload: String) {
2020

2121
fun assertValid(request: APIGatewayProxyRequestEvent, response: APIGatewayProxyResponseEvent) {
2222
return validate(request, response).let {
23-
if (it.hasErrors()) throw ApiInteractionInvalid(
24-
specUrlOrPayload,
25-
request,
26-
response,
27-
it
28-
)
23+
if (it.hasErrors()) {
24+
throw ApiInteractionInvalid(
25+
specUrlOrPayload,
26+
request,
27+
response,
28+
it
29+
)
30+
}
2931
}
3032
}
3133

3234
fun assertValidRequest(request: APIGatewayProxyRequestEvent) =
3335
validator.validateRequest(request.toRequest()).let {
34-
if (it.hasErrors()) throw ApiInteractionInvalid(
35-
spec = specUrlOrPayload,
36-
request = request,
37-
validationReport = it
38-
)
36+
if (it.hasErrors()) {
37+
throw ApiInteractionInvalid(
38+
spec = specUrlOrPayload,
39+
request = request,
40+
validationReport = it
41+
)
42+
}
3943
}
4044

4145
fun assertValidResponse(request: APIGatewayProxyRequestEvent, response: APIGatewayProxyResponseEvent) =
4246
request.toRequest().let { r ->
4347
validator.validateResponse(r.path, r.method, response.toResponse()).let {
44-
if (it.hasErrors()) throw ApiInteractionInvalid(
45-
spec = specUrlOrPayload,
46-
request = request,
47-
validationReport = it
48-
)
48+
if (it.hasErrors()) {
49+
throw ApiInteractionInvalid(
50+
spec = specUrlOrPayload,
51+
request = request,
52+
validationReport = it
53+
)
54+
}
4955
}
5056
}
5157

router-openapi-request-validator/src/main/kotlin/io/moia/router/openapi/ValidatingRequestRouterWrapper.kt

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class ValidatingRequestRouterWrapper(
3131
handleRequest(input = input, context = context, skipRequestValidation = true, skipResponseValidation = true)
3232

3333
private fun handleRequest(input: APIGatewayProxyRequestEvent, context: Context, skipRequestValidation: Boolean, skipResponseValidation: Boolean): APIGatewayProxyResponseEvent {
34-
3534
if (!skipRequestValidation) {
3635
try {
3736
openApiValidator.assertValidRequest(input)

router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoDeserializationHandler.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class ProtoDeserializationHandler : DeserializationHandler {
1616
private val protoStructuredSuffixWildcard = MediaType.parse("application/*+x-protobuf")
1717

1818
override fun supports(input: APIGatewayProxyRequestEvent): Boolean =
19-
if (input.contentType() == null)
19+
if (input.contentType() == null) {
2020
false
21-
else {
21+
} else {
2222
MediaType.parse(input.contentType()).let { proto.isCompatibleWith(it) || protoStructuredSuffixWildcard.isCompatibleWith(it) }
2323
}
2424

router-protobuf/src/test/kotlin/io/moia/router/proto/RequestHandlerTest.kt

-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class RequestHandlerTest {
2323

2424
@Test
2525
fun `should match request to proto handler and return json`() {
26-
2726
val response = testRequestHandler.handleRequest(
2827
APIGatewayProxyRequestEvent()
2928
.withPath("/some-proto")
@@ -38,7 +37,6 @@ class RequestHandlerTest {
3837

3938
@Test
4039
fun `should match request to proto handler with version accept header and return json`() {
41-
4240
val response = testRequestHandler.handleRequest(
4341
APIGatewayProxyRequestEvent()
4442
.withPath("/some-proto")
@@ -53,7 +51,6 @@ class RequestHandlerTest {
5351

5452
@Test
5553
fun `should match request to proto handler and return proto`() {
56-
5754
val response = testRequestHandler.handleRequest(
5855
APIGatewayProxyRequestEvent()
5956
.withPath("/some-proto")
@@ -68,7 +65,6 @@ class RequestHandlerTest {
6865

6966
@Test
7067
fun `should match request to proto handler and deserialize and return proto`() {
71-
7268
val request = Sample.newBuilder().setHello("Hello").setRequest("").build()
7369

7470
val response = testRequestHandler.handleRequest(
@@ -92,7 +88,6 @@ class RequestHandlerTest {
9288

9389
@Test
9490
fun `should return 406-unacceptable error in proto`() {
95-
9691
val response = testRequestHandler.handleRequest(
9792
GET("/some-proto")
9893
.withHeaders(
@@ -109,7 +104,6 @@ class RequestHandlerTest {
109104

110105
@Test
111106
fun `should return api error in protos`() {
112-
113107
val response = testRequestHandler.handleRequest(
114108
GET("/some-error")
115109
.withHeaders(

router/src/main/kotlin/io/moia/router/DeserializationHandler.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class JsonDeserializationHandler(private val objectMapper: ObjectMapper) : Deser
4848
private val jsonStructuredSuffixWildcard = MediaType.parse("application/*+json; charset=UTF-8")
4949

5050
override fun supports(input: APIGatewayProxyRequestEvent) =
51-
if (input.contentType() == null)
51+
if (input.contentType() == null) {
5252
false
53-
else {
53+
} else {
5454
MediaType.parse(input.contentType()!!)
5555
.let { json.isCompatibleWith(it) || jsonStructuredSuffixWildcard.isCompatibleWith(it) }
5656
}
@@ -74,10 +74,11 @@ class JsonDeserializationHandler(private val objectMapper: ObjectMapper) : Deser
7474
object PlainTextDeserializationHandler : DeserializationHandler {
7575
private val text = MediaType.parse("text/*")
7676
override fun supports(input: APIGatewayProxyRequestEvent): Boolean =
77-
if (input.contentType() == null)
77+
if (input.contentType() == null) {
7878
false
79-
else
79+
} else {
8080
MediaType.parse(input.contentType()!!).isCompatibleWith(text)
81+
}
8182

8283
override fun deserialize(input: APIGatewayProxyRequestEvent, target: KType?): Any? =
8384
input.body

router/src/main/kotlin/io/moia/router/MediaTypeExtensions.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import com.google.common.net.MediaType
1818

1919
fun MediaType.isCompatibleWith(other: MediaType): Boolean =
20-
if (this.`is`(other))
20+
if (this.`is`(other)) {
2121
true
22-
else {
22+
} else {
2323
type() == other.type() && (subtype().contains("+") && other.subtype().contains("+")) && this.subtype()
2424
.substringBeforeLast("+") == "*" && this.subtype().substringAfterLast("+") == other.subtype()
2525
.substringAfterLast("+") && (other.parameters().isEmpty || this.parameters() == other.parameters())

router/src/main/kotlin/io/moia/router/PermissionHandler.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ open class JwtPermissionHandler(
6868
) : this(JwtAccessor(request), permissionsClaim, permissionSeparator)
6969

7070
override fun hasAnyRequiredPermission(requiredPermissions: Set<String>): Boolean =
71-
if (requiredPermissions.isEmpty()) true
72-
else extractPermissions().any { requiredPermissions.contains(it) }
71+
if (requiredPermissions.isEmpty()) {
72+
true
73+
} else {
74+
extractPermissions().any { requiredPermissions.contains(it) }
75+
}
7376

7477
internal open fun extractPermissions(): Set<String> =
7578
accessor.extractJwtClaims()

router/src/main/kotlin/io/moia/router/RequestHandler.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ abstract class RequestHandler : RequestHandler<APIGatewayProxyRequestEvent, APIG
5656
val matchResult = routerFunction.requestPredicate.match(input)
5757
log.debug("match result for route '$routerFunction' is '$matchResult'")
5858
if (matchResult.match) {
59-
6059
val matchedAcceptType = routerFunction.requestPredicate.matchedAcceptType(input.acceptedMediaTypes())
6160
?: MediaType.parse(router.defaultContentType)
6261

@@ -109,7 +108,8 @@ abstract class RequestHandler : RequestHandler<APIGatewayProxyRequestEvent, APIG
109108
}
110109

111110
open fun serializationHandlers(): List<SerializationHandler> = listOf(
112-
JsonSerializationHandler(objectMapper), PlainTextSerializationHandler()
111+
JsonSerializationHandler(objectMapper),
112+
PlainTextSerializationHandler()
113113
)
114114

115115
open fun deserializationHandlers(): List<DeserializationHandler> = listOf(

router/src/test/kotlin/io/moia/router/APIGatewayProxyEventExtensionsTest.kt

-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class APIGatewayProxyEventExtensionsTest {
2525

2626
@Test
2727
fun `should add location header`() {
28-
2928
val request = GET()
3029
.withHeader("Host", "example.com")
3130
.withHeader("X-Forwarded-Proto", "http")
@@ -39,7 +38,6 @@ class APIGatewayProxyEventExtensionsTest {
3938

4039
@Test
4140
fun `should add location header with default host and proto and without port`() {
42-
4341
val request = GET()
4442

4543
val response = APIGatewayProxyResponseEvent()
@@ -50,7 +48,6 @@ class APIGatewayProxyEventExtensionsTest {
5048

5149
@Test
5250
fun `should omit default https port`() {
53-
5451
val request = GET()
5552
.withHeader("Host", "example.com")
5653
.withHeader("X-Forwarded-Proto", "https")
@@ -63,7 +60,6 @@ class APIGatewayProxyEventExtensionsTest {
6360

6461
@Test
6562
fun `should omit default http port`() {
66-
6763
val request = GET()
6864
.withHeader("Host", "example.com")
6965
.withHeader("X-Forwarded-Proto", "http")
@@ -76,15 +72,13 @@ class APIGatewayProxyEventExtensionsTest {
7672

7773
@Test
7874
fun `header class should work as expected with APIGatewayProxyRequestEvent`() {
79-
8075
val request = APIGatewayProxyRequestEvent().withHeader(Header("foo", "bar"))
8176

8277
then(request.headers["foo"]).isEqualTo("bar")
8378
}
8479

8580
@Test
8681
fun `header class should work as expected with APIGatewayProxyResponseEvent`() {
87-
8882
val request = APIGatewayProxyResponseEvent().withHeader(Header("foo", "bar"))
8983

9084
then(request.headers["foo"]).isEqualTo("bar")

router/src/test/kotlin/io/moia/router/JwtPermissionHandlerTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class JwtPermissionHandlerTest {
3131
}
3232
*/
3333
val jwtWithScopeClaimSpace = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJzY29wZSI6Im9uZSB0d28ifQ.2tPrDymXDejHfVjNlVh4XUj22ZuDrKHP6dvWN7JNAWY"
34+
3435
/*
3536
{
3637
"sub": "1234567890",

router/src/test/kotlin/io/moia/router/PlainTextDeserializationHandlerTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class PlainTextDeserializationHandlerTest {
5555
)
5656
)
5757
}
58+
5859
@Test
5960
fun `should not support anything when content type is null`() {
6061
assertFalse(PlainTextDeserializationHandler.supports(APIGatewayProxyRequestEvent()))

0 commit comments

Comments
 (0)