Skip to content

Commit d80fcd1

Browse files
committed
limited security test workflows to run only security tests; moved security tests into security package
Signed-off-by: Petar Dzepina <[email protected]>
1 parent 3838886 commit d80fcd1

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

.github/workflows/docker-security-test-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
if [ $security -gt 0 ]
7474
then
7575
echo "Security plugin is available"
76-
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dsecurity=true -Dhttps=true -Duser=admin -Dpassword=admin
76+
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dsecurity=true -Dhttps=true -Duser=admin -Dpassword=admin -Dtests.class=“*SecurityBehaviorIT"
7777
else
7878
echo "Security plugin is NOT available skipping this run as tests without security have already been run"
7979
fi

.github/workflows/security-test-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/checkout@v2
2525
- name: Run integration tests
2626
run: |
27-
./gradlew integTest -Dsecurity=true -Dhttps=true
27+
./gradlew integTest -Dsecurity=true -Dhttps=true -Dtests.class=“*SecurityBehaviorIT"
2828
- name: Upload failed logs
2929
uses: actions/upload-artifact@v2
3030
if: failure()

src/test/kotlin/org/opensearch/indexmanagement/SecurityRestTestCase.kt

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
/*
2+
* Copyright OpenSearch Contributors
23
* SPDX-License-Identifier: Apache-2.0
3-
*
4-
* The OpenSearch Contributors require contributions made to
5-
* this file be licensed under the Apache-2.0 license or a
6-
* compatible open source license.
7-
*
8-
* Modifications Copyright OpenSearch Contributors. See
9-
* GitHub history for details.
104
*/
115

126
package org.opensearch.indexmanagement
@@ -224,7 +218,8 @@ abstract class SecurityRestTestCase : IndexManagementRestTestCase() {
224218
return entityAsMap(executeRequest(request, RestStatus.OK, client))
225219
}
226220

227-
protected fun getExistingManagedIndexConfig(index: String) = IndexStateManagementRestTestCaseExt.getExistingManagedIndexConfigExt(index)
221+
protected fun getExistingManagedIndexConfig(index: String) =
222+
IndexStateManagementRestTestCaseExt.getExistingManagedIndexConfigExt(index)
228223

229224
protected fun createPolicyJson(
230225
policyString: String,
@@ -356,7 +351,8 @@ abstract class SecurityRestTestCase : IndexManagementRestTestCase() {
356351
client: RestClient
357352
) = TransformRestTestCaseExt.getTransformExt(transformId, header, client)
358353

359-
protected fun getTransformMetadata(metadataId: String) = TransformRestTestCaseExt.getTransformMetadataExt(metadataId)
354+
protected fun getTransformMetadata(metadataId: String) =
355+
TransformRestTestCaseExt.getTransformMetadataExt(metadataId)
360356

361357
protected fun checkTransformExplain(transformId: String, userClient: RestClient, expectedStatus: RestStatus): Response {
362358
val request = Request(RestRequest.Method.GET.name, IndexManagementPlugin.TRANSFORM_BASE_URI + "/$transformId/_explain")

src/test/kotlin/org/opensearch/indexmanagement/ExplainSecurityBehaviorIT.kt renamed to src/test/kotlin/org/opensearch/indexmanagement/security/ExplainSecurityBehaviorIT.kt

+13-6
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,29 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.opensearch.indexmanagement
6+
package org.opensearch.indexmanagement.security
77

88
import org.junit.After
99
import org.junit.Before
1010
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest
1111
import org.opensearch.client.ResponseException
1212
import org.opensearch.client.RestClient
1313
import org.opensearch.commons.rest.SecureRestClientBuilder
14-
import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX
14+
import org.opensearch.indexmanagement.BULK_WRITE_INDEX
15+
import org.opensearch.indexmanagement.CREATE_INDEX
16+
import org.opensearch.indexmanagement.GET_INDEX_MAPPING
17+
import org.opensearch.indexmanagement.IndexManagementPlugin
18+
import org.opensearch.indexmanagement.MANAGED_INDEX
19+
import org.opensearch.indexmanagement.PUT_INDEX_MAPPING
20+
import org.opensearch.indexmanagement.SEARCH_INDEX
21+
import org.opensearch.indexmanagement.SecurityRestTestCase
22+
import org.opensearch.indexmanagement.WRITE_INDEX
1523
import org.opensearch.indexmanagement.indexstatemanagement.action.AliasAction
1624
import org.opensearch.indexmanagement.indexstatemanagement.model.Policy
1725
import org.opensearch.indexmanagement.indexstatemanagement.model.State
1826
import org.opensearch.indexmanagement.indexstatemanagement.randomErrorNotification
1927
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.explain.ExplainAction
2028
import org.opensearch.rest.RestStatus
21-
import org.opensearch.test.OpenSearchTestCase
2229
import org.opensearch.test.junit.annotations.TestLogging
2330
import java.time.Instant
2431
import java.time.temporal.ChronoUnit
@@ -65,13 +72,13 @@ class ExplainSecurityBehaviorIT : SecurityRestTestCase() {
6572
deleteUser(ismUser)
6673
deleteRole(HELPDESK_ROLE)
6774

68-
deleteIndexByName("$INDEX_MANAGEMENT_INDEX")
75+
deleteIndexByName("${IndexManagementPlugin.INDEX_MANAGEMENT_INDEX}")
6976
}
7077

7178
fun `test managed index explain indices permission check`() {
7279

73-
val notPermittedIndexPrefix = OpenSearchTestCase.randomAlphaOfLength(10).lowercase(Locale.getDefault())
74-
val policyId = OpenSearchTestCase.randomAlphaOfLength(10)
80+
val notPermittedIndexPrefix = randomAlphaOfLength(10).lowercase(Locale.getDefault())
81+
val policyId = randomAlphaOfLength(10)
7582

7683
val permittedindices = mutableListOf<String>()
7784
val notPermittedindices = mutableListOf<String>()

src/test/kotlin/org/opensearch/indexmanagement/RollupSecurityBehaviorIT.kt renamed to src/test/kotlin/org/opensearch/indexmanagement/security/RollupSecurityBehaviorIT.kt

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
/*
2+
* Copyright OpenSearch Contributors
23
* SPDX-License-Identifier: Apache-2.0
3-
*
4-
* The OpenSearch Contributors require contributions made to
5-
* this file be licensed under the Apache-2.0 license or a
6-
* compatible open source license.
7-
*
8-
* Modifications Copyright OpenSearch Contributors. See
9-
* GitHub history for details.
104
*/
115

12-
package org.opensearch.indexmanagement
6+
package org.opensearch.indexmanagement.security
137

148
import org.junit.After
159
import org.junit.Before
1610
import org.opensearch.client.RestClient
1711
import org.opensearch.commons.rest.SecureRestClientBuilder
12+
import org.opensearch.indexmanagement.BULK_WRITE_INDEX
13+
import org.opensearch.indexmanagement.CREATE_INDEX
14+
import org.opensearch.indexmanagement.DELETE_ROLLUP
15+
import org.opensearch.indexmanagement.EXPLAIN_ROLLUP
16+
import org.opensearch.indexmanagement.GET_INDEX_MAPPING
17+
import org.opensearch.indexmanagement.GET_ROLLUP
18+
import org.opensearch.indexmanagement.INDEX_ROLLUP
19+
import org.opensearch.indexmanagement.MANAGED_INDEX
20+
import org.opensearch.indexmanagement.PUT_INDEX_MAPPING
21+
import org.opensearch.indexmanagement.SEARCH_INDEX
22+
import org.opensearch.indexmanagement.SecurityRestTestCase
23+
import org.opensearch.indexmanagement.UPDATE_ROLLUP
24+
import org.opensearch.indexmanagement.WRITE_INDEX
1825
import org.opensearch.indexmanagement.common.model.dimension.DateHistogram
1926
import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings
2027
import org.opensearch.indexmanagement.rollup.model.Rollup
@@ -26,6 +33,7 @@ import org.opensearch.indexmanagement.rollup.model.metric.Min
2633
import org.opensearch.indexmanagement.rollup.model.metric.Sum
2734
import org.opensearch.indexmanagement.rollup.model.metric.ValueCount
2835
import org.opensearch.indexmanagement.rollup.randomRollup
36+
import org.opensearch.indexmanagement.waitFor
2937
import org.opensearch.jobscheduler.spi.schedule.IntervalSchedule
3038
import org.opensearch.rest.RestStatus
3139
import org.opensearch.test.junit.annotations.TestLogging

src/test/kotlin/org/opensearch/indexmanagement/SecurityBehaviorIT.kt renamed to src/test/kotlin/org/opensearch/indexmanagement/security/SecurityBehaviorIT.kt

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
/*
2+
* Copyright OpenSearch Contributors
23
* SPDX-License-Identifier: Apache-2.0
3-
*
4-
* The OpenSearch Contributors require contributions made to
5-
* this file be licensed under the Apache-2.0 license or a
6-
* compatible open source license.
7-
*
8-
* Modifications Copyright OpenSearch Contributors. See
9-
* GitHub history for details.
104
*/
115

12-
package org.opensearch.indexmanagement
6+
package org.opensearch.indexmanagement.security
137

148
import org.junit.After
159
import org.junit.Before
1610
import org.opensearch.client.RestClient
1711
import org.opensearch.commons.rest.SecureRestClientBuilder
12+
import org.opensearch.indexmanagement.BULK_WRITE_INDEX
13+
import org.opensearch.indexmanagement.CREATE_INDEX
14+
import org.opensearch.indexmanagement.EXPLAIN_INDEX
15+
import org.opensearch.indexmanagement.GET_INDEX_MAPPING
16+
import org.opensearch.indexmanagement.GET_POLICIES
17+
import org.opensearch.indexmanagement.GET_POLICY
18+
import org.opensearch.indexmanagement.MANAGED_INDEX
19+
import org.opensearch.indexmanagement.PUT_INDEX_MAPPING
20+
import org.opensearch.indexmanagement.SEARCH_INDEX
21+
import org.opensearch.indexmanagement.SecurityRestTestCase
22+
import org.opensearch.indexmanagement.WRITE_INDEX
23+
import org.opensearch.indexmanagement.WRITE_POLICY
1824
import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings
25+
import org.opensearch.indexmanagement.makeRequest
26+
import org.opensearch.indexmanagement.waitFor
1927
import org.opensearch.rest.RestStatus
2028
import org.opensearch.test.junit.annotations.TestLogging
2129

0 commit comments

Comments
 (0)