Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix integ tests when security is not installed #278

Merged
merged 1 commit into from
Oct 22, 2020
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 @@ -635,8 +635,8 @@ abstract class AlertingRestTestCase : ODFERestTestCase() {

fun getHeader(): BasicHeader {
return when (isHttps()) {
true -> BasicHeader("dummy", ESRestTestCase.randomAlphaOfLength(20))
false -> BasicHeader(ConfigConstants.AUTHORIZATION, ESRestTestCase.randomAlphaOfLength(20))
false -> BasicHeader("dummy", ESRestTestCase.randomAlphaOfLength(20))
true -> BasicHeader(ConfigConstants.AUTHORIZATION, ESRestTestCase.randomAlphaOfLength(20))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class SecureDestinationRestApiIT : AlertingRestTestCase() {
val adminResponse = getDestinations(client(), inputMap, getHeader())
val expected = when (isHttps()) {
true -> 1 // when test is run with security - get the correct filtered results.
false -> 0 // when test is run without security and filterby is enabled - fails to
// resolve user and filters by empty list, to get zero results.
false -> 1 // when test is run without security and filterby is enabled - filtering
// does not work without security, so filtering is ignored and gets a result
Comment on lines +83 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the value is the same, I want to have it commented/formatted this way to explain whats going on.

}
assertEquals(expected, adminResponse.size)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
val adminDocsFound = adminHits["total"]?.get("value")
val expected = when (isHttps()) {
true -> 1 // when test is run with security - get the correct filtered results.
false -> 0 // when test is run without security and filterby is enabled - fails to
// resolve user and filters by empty list, to get zero results.
false -> 1 // when test is run without security and filterby is enabled - filtering
// does not work without security, so filtering is ignored and gets a result
Comment on lines +78 to +79
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the value is the same, I want to have it commented/formatted this way to explain whats going on.

}
assertEquals("Monitor not found during search", expected, adminDocsFound)

Expand Down Expand Up @@ -131,8 +131,8 @@ class SecureMonitorRestApiIT : AlertingRestTestCase() {
val adminResponseMap = getAlerts(client(), inputMap, getHeader()).asMap()
val expected = when (isHttps()) {
true -> 4 // when test is run with security - get the correct filtered results.
false -> 0 // when test is run without security and filterby is enabled - fails to
// resolve user and filters by empty list, to get zero results.
false -> 4 // when test is run without security and filterby is enabled - filtering
// does not work without security, so filtering is ignored and gets a result
Comment on lines +134 to +135
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the value is the same, I want to have it commented/formatted this way to explain whats going on.

}
assertEquals(expected, adminResponseMap["totalAlerts"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ fun XContentBuilder.optionalUserField(name: String, user: User?): XContentBuilde
}

fun addFilter(user: User, searchSourceBuilder: SearchSourceBuilder, fieldName: String) {
val filterBckendRoles = QueryBuilders.termsQuery(fieldName, user.backendRoles)
val filterBackendRoles = QueryBuilders.termsQuery(fieldName, user.backendRoles)
val queryBuilder = searchSourceBuilder.query() as BoolQueryBuilder
searchSourceBuilder.query(queryBuilder.filter(filterBckendRoles))
searchSourceBuilder.query(queryBuilder.filter(filterBackendRoles))
}

/**
Expand Down