Skip to content

Commit

Permalink
Switches to using the policy name keyword to support special characters
Browse files Browse the repository at this point in the history
Signed-off-by: Drew Baugher <[email protected]>
  • Loading branch information
dbbaughe committed Feb 16, 2022
1 parent 6d11226 commit 4335001
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TransportGetPoliciesAction @Inject constructor(
QueryBuilders
.queryStringQuery(params.queryString)
.defaultOperator(Operator.AND)
.field("policy.policy_id")
.field("policy.policy_id.keyword")
)

val searchSourceBuilder = SearchSourceBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,42 @@ class IndexStateManagementRestApiIT : IndexStateManagementRestTestCase() {

assertEquals(expectedMessage.toString(), actualMessage.toString())
}

fun `test get policies with hyphen`() {
val randomPolicy = randomPolicy(id = "testing-hyphens-01")
createPolicy(randomPolicy, policyId = randomPolicy.id, refresh = true)
val policy = getPolicy(randomPolicy.id)

val response = client().makeRequest(RestRequest.Method.GET.toString(), "$POLICY_BASE_URI?queryString=*testing-hyphens*")

val actualMessage = response.asMap()
val expectedMessage = mapOf(
"total_policies" to 1,
"policies" to listOf(
mapOf(
_SEQ_NO to policy.seqNo,
_ID to policy.id,
_PRIMARY_TERM to policy.primaryTerm,
Policy.POLICY_TYPE to mapOf(
"schema_version" to policy.schemaVersion,
"policy_id" to policy.id,
"last_updated_time" to policy.lastUpdatedTime.toEpochMilli(),
"default_state" to policy.defaultState,
"ism_template" to null,
"description" to policy.description,
"error_notification" to policy.errorNotification,
"states" to policy.states.map {
mapOf(
"name" to it.name,
"transitions" to it.transitions,
"actions" to it.actions
)
}
)
)
)
)

assertEquals(expectedMessage.toString(), actualMessage.toString())
}
}

0 comments on commit 4335001

Please sign in to comment.