@Test
void shouldThrowExceptionIfUsernameLengthExitsAllowedBounds() {

  StringBuilder usernameBuilder = new StringBuilder();
  String usernamePart =
      "𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𢴈𢵌𢵧𢺳𣲷𤓓𤶸𤷪𥄫𦉘𦟌𦧲𦧺𧨾𨅝𨈇𨋢𨳊𨳍𨳒𩶘𠜎𠜱𠝹";
  for (int i = 0; i < 65535 / usernamePart.length(); i++) {
    usernameBuilder.append(usernamePart);
  }
  String password = "tset1234";
  Assertions.assertThatThrownBy(
          () ->
              AuthMetadataCodec.encodeSimpleMetadata(
                  ByteBufAllocator.DEFAULT,
                  usernameBuilder.toString().toCharArray(),
                  password.toCharArray()))
      .hasMessage(
          "Username should be shorter than or equal to 65535 bytes length in UTF-8 encoding");
}