Skip to content

Commit

Permalink
Fix FileSettingsRoleMappingUpgradeIT assertions (elastic#115422)
Browse files Browse the repository at this point in the history
Fixes some faulty assertions in an upgrade test. Test failures only
manifest on the 8.16 branch since 9.x does not qualify for these upgrade
tests, and the change is not backported to 8.17 yet (unrelated CI
failures).

I validated this works by running it locally from the 8.16 branch.

Resolves: elastic#115410
Resolves: elastic#115411
  • Loading branch information
n1v0lg committed Oct 23, 2024
1 parent 376fa8d commit 905d3b0
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
Expand Down Expand Up @@ -104,15 +102,17 @@ public void testRoleMappingsAppliedOnUpgrade() throws IOException {
// the nodes have all been upgraded. Check they re-processed the role mappings in the settings file on
// upgrade
Request clusterStateRequest = new Request("GET", "/_cluster/state/metadata");
List<Object> roleMappings = new XContentTestUtils.JsonMapView(entityAsMap(client().performRequest(clusterStateRequest))).get(
"metadata.role_mappings.role_mappings"
List<Object> clusterStateRoleMappings = new XContentTestUtils.JsonMapView(
entityAsMap(client().performRequest(clusterStateRequest))
).get("metadata.role_mappings.role_mappings");
assertThat(clusterStateRoleMappings, is(not(nullValue())));
assertThat(clusterStateRoleMappings.size(), equalTo(1));

assertThat(
entityAsMap(client().performRequest(new Request("GET", "/_security/role_mapping"))).keySet(),
// TODO change this to `contains` once the clean-up migration work is merged
hasItem("everyone_kibana-read-only-operator-mapping")
);
assertThat(roleMappings, is(not(nullValue())));
assertThat(roleMappings.size(), equalTo(1));
assertThat(roleMappings, is(instanceOf(Map.class)));
@SuppressWarnings("unchecked")
Map<String, Object> roleMapping = (Map<String, Object>) roleMappings;
assertThat(roleMapping.keySet(), contains("everyone_kibana-read-only-operator-mapping"));
}
}
}

0 comments on commit 905d3b0

Please sign in to comment.