Skip to content

Commit 0f16228

Browse files
Copilotdimuontobio
authored
Refactor all Kibana connector acceptance tests to use ConfigDirectory pattern (#1484)
* Initial plan * Refactor AI connector tests into table-driven test Co-authored-by: dimuon <[email protected]> * Fix regex pattern for secret field in bedrock update checks Co-authored-by: dimuon <[email protected]> * Restructure test to use ConfigDirectory pattern with testdata files Co-authored-by: dimuon <[email protected]> * Refactor all connector acceptance tests to use ConfigDirectory pattern Co-authored-by: tobio <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dimuon <[email protected]> Co-authored-by: tobio <[email protected]>
1 parent ef7bf07 commit 0f16228

File tree

13 files changed

+371
-315
lines changed

13 files changed

+371
-315
lines changed

internal/kibana/connectors/acc_test.go

Lines changed: 136 additions & 315 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = var.connector_name
8+
config = jsonencode({
9+
apiUrl = "https://bedrock-runtime.us-east-1.amazonaws.com"
10+
defaultModel = "anthropic.claude-v2"
11+
})
12+
secrets = jsonencode({
13+
accessKey = "test-access-key"
14+
secret = "test-secret-key"
15+
})
16+
connector_type_id = ".bedrock"
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = "Updated ${var.connector_name}"
8+
config = jsonencode({
9+
apiUrl = "https://bedrock-runtime.us-west-2.amazonaws.com"
10+
defaultModel = "anthropic.claude-3-5-sonnet-20240620-v1:0"
11+
})
12+
secrets = jsonencode({
13+
accessKey = "updated-access-key"
14+
secret = "updated-secret-key"
15+
})
16+
connector_type_id = ".bedrock"
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = var.connector_name
8+
config = jsonencode({
9+
apiProvider = "OpenAI"
10+
apiUrl = "https://api.openai.com/v1"
11+
defaultModel = "gpt-4"
12+
})
13+
secrets = jsonencode({
14+
apiKey = "test-api-key"
15+
})
16+
connector_type_id = ".gen-ai"
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = "Updated ${var.connector_name}"
8+
config = jsonencode({
9+
apiProvider = "OpenAI"
10+
apiUrl = "https://api.openai.com/v1"
11+
defaultModel = "gpt-4o"
12+
})
13+
secrets = jsonencode({
14+
apiKey = "updated-api-key"
15+
})
16+
connector_type_id = ".gen-ai"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = var.connector_name
8+
config = jsonencode({
9+
createIncidentJson = "{}"
10+
createIncidentResponseKey = "key"
11+
createIncidentUrl = "https://www.elastic.co/"
12+
getIncidentResponseExternalTitleKey = "title"
13+
getIncidentUrl = "https://www.elastic.co/"
14+
updateIncidentJson = "{}"
15+
updateIncidentUrl = "https://www.elastic.co/"
16+
viewIncidentUrl = "https://www.elastic.co/"
17+
})
18+
secrets = jsonencode({
19+
user = "user1"
20+
password = "password1"
21+
})
22+
connector_type_id = ".cases-webhook"
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
resource "elasticstack_kibana_action_connector" "test" {
7+
name = "Updated ${var.connector_name}"
8+
config = jsonencode({
9+
createIncidentJson = "{}"
10+
createIncidentResponseKey = "key"
11+
createIncidentUrl = "https://www.elastic.co/"
12+
getIncidentResponseExternalTitleKey = "title"
13+
getIncidentUrl = "https://www.elastic.co/"
14+
updateIncidentJson = "{}"
15+
updateIncidentUrl = "https://elasticsearch.com/"
16+
viewIncidentUrl = "https://www.elastic.co/"
17+
createIncidentMethod = "put"
18+
})
19+
secrets = jsonencode({
20+
user = "user2"
21+
password = "password2"
22+
})
23+
connector_type_id = ".cases-webhook"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
variable "connector_id" {
7+
description = "Connector ID"
8+
type = string
9+
}
10+
11+
resource "elasticstack_kibana_action_connector" "test" {
12+
name = var.connector_name
13+
connector_id = var.connector_id
14+
config = jsonencode({
15+
createIncidentJson = "{}"
16+
createIncidentResponseKey = "key"
17+
createIncidentUrl = "https://www.elastic.co/"
18+
getIncidentResponseExternalTitleKey = "title"
19+
getIncidentUrl = "https://www.elastic.co/"
20+
updateIncidentJson = "{}"
21+
updateIncidentUrl = "https://www.elastic.co/"
22+
viewIncidentUrl = "https://www.elastic.co/"
23+
})
24+
secrets = jsonencode({
25+
user = "user1"
26+
password = "password1"
27+
})
28+
connector_type_id = ".cases-webhook"
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
variable "connector_id" {
7+
description = "Connector ID"
8+
type = string
9+
}
10+
11+
resource "elasticstack_kibana_action_connector" "test" {
12+
name = "Updated ${var.connector_name}"
13+
connector_id = var.connector_id
14+
config = jsonencode({
15+
createIncidentJson = "{}"
16+
createIncidentResponseKey = "key"
17+
createIncidentUrl = "https://www.elastic.co/"
18+
getIncidentResponseExternalTitleKey = "title"
19+
getIncidentUrl = "https://www.elastic.co/"
20+
updateIncidentJson = "{}"
21+
updateIncidentUrl = "https://elasticsearch.com/"
22+
viewIncidentUrl = "https://www.elastic.co/"
23+
createIncidentMethod = "put"
24+
})
25+
secrets = jsonencode({
26+
user = "user2"
27+
password = "password2"
28+
})
29+
connector_type_id = ".cases-webhook"
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "connector_name" {
2+
description = "The connector name"
3+
type = string
4+
}
5+
6+
provider "elasticstack" {
7+
elasticsearch {}
8+
kibana {}
9+
}
10+
11+
resource "elasticstack_kibana_action_connector" "test" {
12+
name = var.connector_name
13+
connector_type_id = ".slack"
14+
secrets = jsonencode({
15+
webhookUrl = "https://example.com/webhook"
16+
})
17+
}

0 commit comments

Comments
 (0)