Update authenticate to allow unknown fields (#37713)

AuthenticateResponse did not allow unknown fields. This commit fixes the
test and ConstructingObjectParser such that it does now allow unknown
fields.

Relates #36938
This commit is contained in:
Michael Basnight 2019-01-23 22:14:01 -06:00 committed by GitHub
parent 944972a249
commit 04c64147bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -53,11 +53,11 @@ public final class AuthenticateResponse {
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<AuthenticateResponse, Void> PARSER = new ConstructingObjectParser<>(
"client_security_authenticate_response",
"client_security_authenticate_response", true,
a -> new AuthenticateResponse(new User((String) a[0], ((List<String>) a[1]), (Map<String, Object>) a[2],
(String) a[3], (String) a[4]), (Boolean) a[5], (RealmInfo) a[6], (RealmInfo) a[7]));
static {
final ConstructingObjectParser<RealmInfo, Void> realmInfoParser = new ConstructingObjectParser<>("realm_info",
final ConstructingObjectParser<RealmInfo, Void> realmInfoParser = new ConstructingObjectParser<>("realm_info", true,
a -> new RealmInfo((String) a[0], (String) a[1]));
realmInfoParser.declareString(constructorArg(), REALM_NAME);
realmInfoParser.declareString(constructorArg(), REALM_TYPE);

View File

@ -42,7 +42,9 @@ public class AuthenticateResponseTests extends ESTestCase {
this::createTestInstance,
this::toXContent,
AuthenticateResponse::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
//metadata is a series of kv pairs, so we dont want to add random fields here for test equality
.randomFieldsExcludeFilter(f -> f.startsWith("metadata"))
.test();
}