Skip to content

Commit 501c9f6

Browse files
committed
Spotless
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
1 parent 371200e commit 501c9f6

File tree

6 files changed

+64
-57
lines changed

6 files changed

+64
-57
lines changed

src/integrationTest/java/org/opensearch/security/privileges/int_tests/DataStreamAuthorizationReadOnlyIntTests.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,10 @@ public void search_indexPattern_minus() throws Exception {
390390
// OpenSearch does not handle the expression ds_a*,ds_b*,-ds_b2,-ds_b3 in a way that excludes the data streams. See
391391
// search_indexPattern_minus_backingIndices for an alternative.
392392
assertThat(
393-
httpResponse,
394-
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1, ds_b2, ds_b3).at("hits.hits[*]._index")
395-
.reducedBy(user.reference(READ))
396-
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
393+
httpResponse,
394+
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1, ds_b2, ds_b3).at("hits.hits[*]._index")
395+
.reducedBy(user.reference(READ))
396+
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
397397
);
398398
}
399399
}
@@ -402,12 +402,12 @@ public void search_indexPattern_minus() throws Exception {
402402
public void search_indexPattern_minus_backingIndices() throws Exception {
403403
try (TestRestClient restClient = cluster.getRestClient(user)) {
404404
TestRestClient.HttpResponse httpResponse = restClient.get("ds_a*,ds_b*,-.ds-ds_b2*,-.ds-ds_b3*/_search?size=1000");
405-
assertThat(
406-
httpResponse,
407-
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1).at("hits.hits[*]._index")
408-
.reducedBy(user.reference(READ))
409-
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
410-
);
405+
assertThat(
406+
httpResponse,
407+
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1).at("hits.hits[*]._index")
408+
.reducedBy(user.reference(READ))
409+
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
410+
);
411411
}
412412
}
413413

@@ -418,12 +418,12 @@ public void search_indexPattern_nonExistingIndex_ignoreUnavailable() throws Exce
418418
"ds_a*,ds_b*,xxx_non_existing/_search?size=1000&ignore_unavailable=true"
419419
);
420420

421-
assertThat(
422-
httpResponse,
423-
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1, ds_b2, ds_b3).at("hits.hits[*]._index")
424-
.reducedBy(user.reference(READ))
425-
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
426-
);
421+
assertThat(
422+
httpResponse,
423+
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1, ds_b2, ds_b3).at("hits.hits[*]._index")
424+
.reducedBy(user.reference(READ))
425+
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
426+
);
427427

428428
}
429429
}
@@ -484,7 +484,9 @@ public void search_termsAggregation_index() throws Exception {
484484

485485
assertThat(
486486
httpResponse,
487-
containsExactly(ALL_INDICES_EXCEPT_SYSTEM_INDICES).at("aggregations.indices.buckets[*].key").reducedBy(user.reference(READ)).whenEmpty(isOk())
487+
containsExactly(ALL_INDICES_EXCEPT_SYSTEM_INDICES).at("aggregations.indices.buckets[*].key")
488+
.reducedBy(user.reference(READ))
489+
.whenEmpty(isOk())
488490
);
489491

490492
}
@@ -812,12 +814,12 @@ public void field_caps_indexPattern_minus() throws Exception {
812814
public void field_caps_indexPattern_minus_backingIndices() throws Exception {
813815
try (TestRestClient restClient = cluster.getRestClient(user)) {
814816
TestRestClient.HttpResponse httpResponse = restClient.get("ds_a*,ds_b*,-.ds-ds_b2*,-.ds-ds_b3*/_field_caps?fields=*");
815-
assertThat(
816-
httpResponse,
817-
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1).at("indices")
818-
.reducedBy(user.reference(READ))
819-
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
820-
);
817+
assertThat(
818+
httpResponse,
819+
containsExactly(ds_a1, ds_a2, ds_a3, ds_b1).at("indices")
820+
.reducedBy(user.reference(READ))
821+
.whenEmpty(clusterConfig.allowsEmptyResultSets ? isOk() : isForbidden())
822+
);
821823
}
822824
}
823825

src/integrationTest/java/org/opensearch/security/privileges/int_tests/IndexAuthorizationReadOnlyIntTests.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ public class IndexAuthorizationReadOnlyIntTests {
311311
.on(".system_index_plugin")
312312
)//
313313
.reference(READ, limitedTo(index_c1, alias_c1, system_index_plugin, alias_with_system_index))//
314-
.reference(READ_NEXT_GEN, limitedTo(index_c1, alias_c1, system_index_plugin))//
315-
.reference(GET_ALIAS, limitedTo(index_c1, alias_c1, system_index_plugin, alias_with_system_index));
314+
.reference(READ_NEXT_GEN, limitedTo(index_c1, alias_c1, system_index_plugin))//
315+
.reference(GET_ALIAS, limitedTo(index_c1, alias_c1, system_index_plugin, alias_with_system_index));
316316
/**
317317
* This user has no privileges for indices that are used in this test. But they have privileges for other indices.
318318
* This allows them to use actions like _search and receive empty result sets.
@@ -1626,34 +1626,34 @@ public void getAlias_indexPattern_includeHidden() throws Exception {
16261626
if (user == UNLIMITED_USER) {
16271627
if (clusterConfig == ClusterConfig.LEGACY_PRIVILEGES_EVALUATION) {
16281628
assertThat(
1629-
httpResponse,
1630-
containsExactly(
1631-
index_a1,
1632-
index_a2,
1633-
index_a3,
1634-
index_b1,
1635-
index_b2,
1636-
index_b3,
1637-
index_c1,
1638-
index_hidden,
1639-
index_hidden_dot,
1640-
system_index_plugin
1641-
).at("$.keys()")
1629+
httpResponse,
1630+
containsExactly(
1631+
index_a1,
1632+
index_a2,
1633+
index_a3,
1634+
index_b1,
1635+
index_b2,
1636+
index_b3,
1637+
index_c1,
1638+
index_hidden,
1639+
index_hidden_dot,
1640+
system_index_plugin
1641+
).at("$.keys()")
16421642
);
16431643
} else {
16441644
assertThat(
1645-
httpResponse,
1646-
containsExactly(
1647-
index_a1,
1648-
index_a2,
1649-
index_a3,
1650-
index_b1,
1651-
index_b2,
1652-
index_b3,
1653-
index_c1,
1654-
index_hidden,
1655-
index_hidden_dot
1656-
).at("$.keys()")
1645+
httpResponse,
1646+
containsExactly(
1647+
index_a1,
1648+
index_a2,
1649+
index_a3,
1650+
index_b1,
1651+
index_b2,
1652+
index_b3,
1653+
index_c1,
1654+
index_hidden,
1655+
index_hidden_dot
1656+
).at("$.keys()")
16571657
);
16581658
}
16591659
} else if (!user.reference(GET_ALIAS).isEmpty()) {

src/integrationTest/java/org/opensearch/security/privileges/int_tests/MiscPrivilegesIntTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class MiscPrivilegesIntTests {
5454
);
5555

5656
private String TEST_RENDER_SEARCH_TEMPLATE_QUERY =
57-
"""
58-
{"params":{"status":["pending","published"]},"source":"{\\"query\\": {\\"terms\\": {\\"status\\": [\\"{{#status}}\\",\\"{{.}}\\",\\"{{/status}}\\"]}}}"}""";
57+
"""
58+
{"params":{"status":["pending","published"]},"source":"{\\"query\\": {\\"terms\\": {\\"status\\": [\\"{{#status}}\\",\\"{{.}}\\",\\"{{/status}}\\"]}}}"}""";
5959

6060
final static TestIndex R = TestIndex.name("r").build();
6161
/**

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,17 @@ public void evaluateAsync(
8383
// if it reached this evaluator, it is safe to assume that the request if of DocRequest type
8484
DocRequest req = (DocRequest) request;
8585

86-
resourceAccessHandler.hasPermission(req.id(), req.type(), action, ActionListener.wrap(
86+
resourceAccessHandler.hasPermission(
87+
req.id(),
88+
req.type(),
89+
action,
90+
ActionListener.wrap(
8791
hasAccess -> pResponseListener.onResponse(
88-
hasAccess ? PrivilegesEvaluatorResponse.ok() : PrivilegesEvaluatorResponse.insufficient(action)
92+
hasAccess ? PrivilegesEvaluatorResponse.ok() : PrivilegesEvaluatorResponse.insufficient(action)
8993
),
9094
pResponseListener::onFailure
91-
));
95+
)
96+
);
9297
}
9398

9499
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ public PrivilegesEvaluatorResponse evaluate(PrivilegesEvaluationContext context)
373373
}
374374

375375
if (GetAllPitsAction.NAME.equals(action0)) {
376-
// We preserve old behavior here: The "indices:data/read/point_in_time/readall" is allowed when I have privileges on any actions.
376+
// We preserve old behavior here: The "indices:data/read/point_in_time/readall" is allowed when I have privileges on any
377+
// actions.
377378
// This is okay, as the action name includes "readall" anyway. In the new privilege evaluation, this is a cluster privilege.
378379
return actionPrivileges.hasIndexPrivilegeForAnyIndex(context, Set.of(action0));
379380
}

src/main/java/org/opensearch/security/resources/ResourceAccessHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.opensearch.security.auth.UserSubjectImpl;
3030
import org.opensearch.security.configuration.AdminDNs;
3131
import org.opensearch.security.privileges.PrivilegesConfiguration;
32-
import org.opensearch.security.privileges.PrivilegesEvaluationContext;
3332
import org.opensearch.security.resources.sharing.Recipient;
3433
import org.opensearch.security.resources.sharing.ResourceSharing;
3534
import org.opensearch.security.resources.sharing.ShareWith;

0 commit comments

Comments
 (0)