Skip to content

Commit 764b826

Browse files
committed
Fixes
Signed-off-by: Nils Bandener <[email protected]>
1 parent daec12d commit 764b826

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,15 @@ public PrivilegesEvaluator(
199199
SecurityDynamicConfiguration<?> rolesConfiguration = configurationRepository.getConfiguration(CType.ROLES);
200200

201201
if (rolesConfiguration != null) {
202-
FlattenedActionGroups flattenedActionGroups = actionGroupsConfiguration != null
203-
? new FlattenedActionGroups(
204-
(SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
205-
actionGroupsConfiguration.deepClone()
206-
)
202+
@SuppressWarnings("unchecked")
203+
SecurityDynamicConfiguration<ActionGroupsV7> actionGroupsWithStatics = actionGroupsConfiguration != null
204+
? (SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
205+
actionGroupsConfiguration.deepClone()
207206
)
208-
: FlattenedActionGroups.EMPTY;
207+
: (SecurityDynamicConfiguration<ActionGroupsV7>) DynamicConfigFactory.addStatics(
208+
SecurityDynamicConfiguration.empty()
209+
);
210+
FlattenedActionGroups flattenedActionGroups = new FlattenedActionGroups(actionGroupsWithStatics);
209211
ActionPrivileges actionPrivileges = new ActionPrivileges(
210212
DynamicConfigFactory.addStatics(rolesConfiguration.deepClone()),
211213
flattenedActionGroups,

src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java

-13
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,6 @@ public static <T> SecurityDynamicConfiguration<T> fromYaml(String yaml, CType ct
172172
return result;
173173
}
174174

175-
/**
176-
* For testing only
177-
*/
178-
public static <T> SecurityDynamicConfiguration<T> fromMap(Map<String, Object> map, CType ctype) throws JsonProcessingException {
179-
Class<?> implementationClass = ctype.getImplementationClass().get(2);
180-
SecurityDynamicConfiguration<T> result = DefaultObjectMapper.objectMapper.convertValue(
181-
map,
182-
DefaultObjectMapper.getTypeFactory().constructParametricType(SecurityDynamicConfiguration.class, implementationClass)
183-
);
184-
result.ctype = ctype;
185-
return result;
186-
}
187-
188175
// for Jackson
189176
private SecurityDynamicConfiguration() {
190177
super();

src/test/java/org/opensearch/security/privileges/ActionPrivilegesTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,16 @@ SecurityDynamicConfiguration<RoleV7> toRolesConfig(ActionSpec actionSpec) {
515515
try {
516516
return SecurityDynamicConfiguration.fromMap(
517517
ImmutableMap.of(
518-
"test_role", //
518+
"test_role",
519519
ImmutableMap.of(
520-
//
521520
"index_permissions",
522521
Arrays.asList(
523-
//
524522
ImmutableMap.of("index_patterns", this.givenIndexPrivs, "allowed_actions", actionSpec.givenPrivs)
525-
)//
523+
)
526524
)
527525
),
528-
CType.ROLES
526+
CType.ROLES,
527+
2
529528
);
530529
} catch (JsonProcessingException e) {
531530
throw new RuntimeException(e);

src/test/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluatorTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public void setup(
125125
Arrays.asList("*")
126126
)
127127
),
128-
CType.ROLES
128+
CType.ROLES,
129+
2
129130
);
130131

131132
this.actionPrivileges = new ActionPrivileges(rolesConfig, FlattenedActionGroups.EMPTY, () -> indexMetadata);

0 commit comments

Comments
 (0)