Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2002,4 +2002,9 @@ public static void safeSleep(long millis) {
throw new AssertionError("unexpected", e);
}
}

protected static boolean isTurkishLocale() {
return Locale.getDefault().getLanguage().equals(new Locale("tr").getLanguage())
|| Locale.getDefault().getLanguage().equals(new Locale("az").getLanguage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ public static void localeChecks() throws Exception {
}
}

private static boolean isTurkishLocale() {
return Locale.getDefault().getLanguage().equals(new Locale("tr").getLanguage())
|| Locale.getDefault().getLanguage().equals(new Locale("az").getLanguage());
}

@AfterClass
public static void restoreLocale() {
if (restoreLocale != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public static void setupSaml() throws Exception {
SamlUtils.initialize(logger);
}

private static boolean isTurkishLocale() {
return Locale.getDefault().getLanguage().equals(new Locale("tr").getLanguage())
|| Locale.getDefault().getLanguage().equals(new Locale("az").getLanguage());
}

@AfterClass
public static void restoreLocale() {
if (restoreLocale != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
}

public void testMalformedRequestDispatchedNoAuthn() throws Exception {
assumeTrue(
"This test doesn't work correctly under turkish-like locale, because it uses String#toUpper() for asserted error messages",
isTurkishLocale() == false
);
final AtomicReference<Throwable> dispatchThrowableReference = new AtomicReference<>();
final AtomicInteger authnInvocationCount = new AtomicInteger();
final AtomicInteger badDispatchInvocationCount = new AtomicInteger();
Expand Down Expand Up @@ -574,8 +578,8 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("This is not a valid HTTP line"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
var writeFuture = testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand All @@ -590,8 +594,8 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("GET /this/is/a/valid/but/too/long/initial/line HTTP/1.1"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
var writeFuture = testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand All @@ -606,10 +610,10 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("GET /url HTTP/1.1"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
ByteBufUtil.copy(AsciiString.of("Host"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
var writeFuture = testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand All @@ -624,10 +628,10 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("GET /url HTTP/1.1"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
ByteBufUtil.copy(AsciiString.of("Host: this.looks.like.a.good.url.but.is.longer.than.permitted"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
var writeFuture = testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand All @@ -642,10 +646,11 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("GET /url HTTP/1.1"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.copy(AsciiString.of("Host: invalid host value"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
ByteBufUtil.copy(AsciiString.of("Host: invalid header value"), buf);
buf.writeByte(0x01);
buf.writeByte(HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
var writeFuture = testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand All @@ -660,9 +665,9 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
EmbeddedChannel ch = new EmbeddedChannel(handler);
ByteBuf buf = ch.alloc().buffer();
ByteBufUtil.copy(AsciiString.of("GET /url HTTP/1.1"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
ByteBufUtil.copy(AsciiString.of("Host: localhost"), buf);
ByteBufUtil.writeShortBE(buf, HttpConstants.LF);
buf.writeByte(HttpConstants.LF);
testThreadPool.generic().submit(() -> {
ch.writeInbound(buf);
ch.flushInbound();
Expand Down