Fixes a test bug for the DeprecationRestHandler where an empty string
could be randomly produced as a header to test against, which is rejected by header validation as an invalid header.
This commit is contained in:
parent
d55bd707a3
commit
86c3bdb8a5
|
@ -78,8 +78,15 @@ public class DeprecationRestHandlerTests extends ESTestCase {
|
|||
ASCIIHeaderGenerator generator = new ASCIIHeaderGenerator();
|
||||
String value = generator.ofCodeUnitsLength(random(), 1, 50);
|
||||
|
||||
assertTrue(DeprecationRestHandler.validHeaderValue(value));
|
||||
assertSame(value, DeprecationRestHandler.requireValidHeader(value));
|
||||
if (value.trim().length() == 0) {
|
||||
// empty text, not a valid header
|
||||
assertFalse(DeprecationRestHandler.validHeaderValue(value));
|
||||
Exception e = expectThrows(IllegalArgumentException.class, () -> DeprecationRestHandler.requireValidHeader(value));
|
||||
assertEquals("header value must contain only US ASCII text", e.getMessage());
|
||||
} else {
|
||||
assertTrue(DeprecationRestHandler.validHeaderValue(value));
|
||||
assertSame(value, DeprecationRestHandler.requireValidHeader(value));
|
||||
}
|
||||
}
|
||||
|
||||
public void testInvalidHeaderValue() {
|
||||
|
|
Loading…
Reference in New Issue