|
25 | 25 |
|
26 | 26 | import java.io.IOException; |
27 | 27 | import java.util.List; |
28 | | -import java.util.Map; |
29 | 28 | import java.util.function.Supplier; |
30 | 29 |
|
31 | | -import static org.hamcrest.Matchers.contains; |
32 | 30 | import static org.hamcrest.Matchers.equalTo; |
33 | | -import static org.hamcrest.Matchers.instanceOf; |
| 31 | +import static org.hamcrest.Matchers.hasItem; |
34 | 32 | import static org.hamcrest.Matchers.is; |
35 | 33 | import static org.hamcrest.Matchers.not; |
36 | 34 | import static org.hamcrest.Matchers.nullValue; |
@@ -104,15 +102,17 @@ public void testRoleMappingsAppliedOnUpgrade() throws IOException { |
104 | 102 | // the nodes have all been upgraded. Check they re-processed the role mappings in the settings file on |
105 | 103 | // upgrade |
106 | 104 | Request clusterStateRequest = new Request("GET", "/_cluster/state/metadata"); |
107 | | - List<Object> roleMappings = new XContentTestUtils.JsonMapView(entityAsMap(client().performRequest(clusterStateRequest))).get( |
108 | | - "metadata.role_mappings.role_mappings" |
| 105 | + List<Object> clusterStateRoleMappings = new XContentTestUtils.JsonMapView( |
| 106 | + entityAsMap(client().performRequest(clusterStateRequest)) |
| 107 | + ).get("metadata.role_mappings.role_mappings"); |
| 108 | + assertThat(clusterStateRoleMappings, is(not(nullValue()))); |
| 109 | + assertThat(clusterStateRoleMappings.size(), equalTo(1)); |
| 110 | + |
| 111 | + assertThat( |
| 112 | + entityAsMap(client().performRequest(new Request("GET", "/_security/role_mapping"))).keySet(), |
| 113 | + // TODO change this to `contains` once the clean-up migration work is merged |
| 114 | + hasItem("everyone_kibana-read-only-operator-mapping") |
109 | 115 | ); |
110 | | - assertThat(roleMappings, is(not(nullValue()))); |
111 | | - assertThat(roleMappings.size(), equalTo(1)); |
112 | | - assertThat(roleMappings, is(instanceOf(Map.class))); |
113 | | - @SuppressWarnings("unchecked") |
114 | | - Map<String, Object> roleMapping = (Map<String, Object>) roleMappings; |
115 | | - assertThat(roleMapping.keySet(), contains("everyone_kibana-read-only-operator-mapping")); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
0 commit comments