Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix security integration tests for 2.0 #407

Merged
merged 1 commit into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,17 @@ abstract class AlertingRestTestCase : ODFERestTestCase() {
client.makeRequest("POST", "$ALERTING_BASE_URI/_execute", params, monitor.toHttpEntityWithUser())

protected fun indexDoc(index: String, id: String, doc: String, refresh: Boolean = true): Response {
return indexDoc(client(), index, id, doc, refresh)
}

protected fun indexDocWithAdminClient(index: String, id: String, doc: String, refresh: Boolean = true): Response {
return indexDoc(adminClient(), index, id, doc, refresh)
}

private fun indexDoc(client: RestClient, index: String, id: String, doc: String, refresh: Boolean = true): Response {
val requestBody = StringEntity(doc, APPLICATION_JSON)
val params = if (refresh) mapOf("refresh" to "true") else mapOf()
val response = client().makeRequest("PUT", "$index/_doc/$id", params, requestBody)
val response = client.makeRequest("PUT", "$index/_doc/$id", params, requestBody)
assertTrue(
"Unable to index doc: '${doc.take(15)}...' to index: '$index'",
listOf(RestStatus.OK, RestStatus.CREATED).contains(response.restStatus())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class DestinationMigrationUtilServiceIT : AlertingRestTestCase() {
val emailGroupDoc = "{\"email_group\" : ${emailGroup.toJsonString()}}"
val emailAccountId = UUID.randomUUID().toString()
val emailGroupId = UUID.randomUUID().toString()
indexDoc(SCHEDULED_JOBS_INDEX, emailAccountId, emailAccountDoc)
indexDoc(SCHEDULED_JOBS_INDEX, emailGroupId, emailGroupDoc)
indexDocWithAdminClient(SCHEDULED_JOBS_INDEX, emailAccountId, emailAccountDoc)
indexDocWithAdminClient(SCHEDULED_JOBS_INDEX, emailGroupId, emailGroupDoc)

val recipient = Recipient(Recipient.RecipientType.EMAIL, null, "[email protected]")
val email = Email(emailAccountId, listOf(recipient))
Expand Down Expand Up @@ -75,7 +75,7 @@ class DestinationMigrationUtilServiceIT : AlertingRestTestCase() {
"destination" : ${destination.toJsonString()}
}
""".trimIndent()
indexDoc(SCHEDULED_JOBS_INDEX, destination.id, dest)
indexDocWithAdminClient(SCHEDULED_JOBS_INDEX, destination.id, dest)
ids.add(destination.id)
}

Expand Down