Skip to content

Commit 6866d95

Browse files
authored
Reduce text in CORS response status (#10631)
Signed-off-by: Tim Quinn <[email protected]>
1 parent 408f661 commit 6866d95

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

webserver/cors/src/main/java/io/helidon/webserver/cors/CorsServerResponseAdapter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
2525
*/
2626
class CorsServerResponseAdapter implements CorsResponseAdapter<ServerResponse> {
2727

28+
private static final System.Logger LOGGER = System.getLogger(CorsServerResponseAdapter.class.getName());
29+
2830
private final ServerResponse serverResponse;
2931

3032
CorsServerResponseAdapter(ServerResponse serverResponse) {
@@ -45,7 +47,8 @@ public CorsServerResponseAdapter header(HeaderName key, Object value) {
4547

4648
@Override
4749
public ServerResponse forbidden(String message) {
48-
serverResponse.status(Status.create(Status.FORBIDDEN_403.code(), message));
50+
serverResponse.status(Status.create(Status.FORBIDDEN_403.code()));
51+
LOGGER.log(System.Logger.Level.TRACE, "Rejecting CORS request: " + message);
4952
return serverResponse;
5053
}
5154

webserver/cors/src/test/java/io/helidon/webserver/cors/AbstractCorsTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
4040
import static org.hamcrest.CoreMatchers.containsString;
4141
import static org.hamcrest.MatcherAssert.assertThat;
4242
import static org.hamcrest.Matchers.is;
43+
import static org.hamcrest.Matchers.isEmptyString;
4344
import static org.hamcrest.core.IsNot.not;
4445

4546
abstract class AbstractCorsTest extends CorsRouting {
@@ -110,7 +111,7 @@ void test2PreFlightForbiddenOrigin() {
110111
status = response.status();
111112
}
112113
assertThat(status.code(), is(Status.FORBIDDEN_403.code()));
113-
assertThat(status.reasonPhrase(), is("CORS origin is not in allowed list"));
114+
assertThat(status.reasonPhrase(), is("Forbidden"));
114115
}
115116

116117
@Test
@@ -146,7 +147,7 @@ void test2PreFlightForbiddenMethod() {
146147
status = response.status();
147148
}
148149
assertThat(status.code(), is(Status.FORBIDDEN_403.code()));
149-
assertThat(status.reasonPhrase(), is("CORS origin is denied"));
150+
assertThat(status.reasonPhrase(), is("Forbidden"));
150151
}
151152

152153
@Test
@@ -161,7 +162,7 @@ void test2PreFlightForbiddenHeader() {
161162
try (Http1ClientResponse response = request.request()) {
162163
Status status = response.status();
163164
assertThat(status.code(), is(Status.FORBIDDEN_403.code()));
164-
assertThat(status.reasonPhrase(), is("CORS headers not in allowed list"));
165+
assertThat(status.reasonPhrase(), is("Forbidden"));
165166
}
166167
}
167168

webserver/cors/src/test/java/io/helidon/webserver/cors/TestTwoCorsConfigs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ void test1PreFlightAllowedOriginOtherGreeting() {
6060

6161
Status status = response.status();
6262
assertThat(status.code(), is(Status.FORBIDDEN_403.code()));
63-
assertThat(status.reasonPhrase(), is("CORS origin is denied"));
63+
assertThat(status.reasonPhrase(), is("Forbidden"));
6464
}
6565

6666
}

0 commit comments

Comments
 (0)