generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 3
/
log_streaming_access_bridge_test.go
263 lines (251 loc) · 11 KB
/
log_streaming_access_bridge_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
package acc_tests
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
"testing"
)
const (
logStreamDependencies = `
resource "pfptmeta_notification_channel" "pagerduty" {
name = "pagerduty-channel"
description = "pagerduty channel description"
pagerduty_config {
api_key = "api-key"
}
}
`
logStreamAccessBridgeCasbStep1 = `
resource "pfptmeta_log_streaming_access_bridge" "casb_log_stream" {
name = "CASB log stream"
description = "log stream description"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["traffic", "webfilter"]
proofpoint_casb_config {
region = "EU"
tenant_id = "tenant_70e4b2a567a24159ad6b495ba56b3620"
}
}
`
logStreamAccessBridgeCasbStep2 = `
resource "pfptmeta_log_streaming_access_bridge" "casb_log_stream" {
name = "CASB log stream1"
description = "log stream description1"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["webfilter", "traffic"]
proofpoint_casb_config {
region = "US"
tenant_id = "tenant_70e4b2a567a24159ad6b495ba56b3621"
}
}
`
logStreamAccessBridgeQRadar = `
resource "pfptmeta_log_streaming_access_bridge" "qradar_http_log_stream" {
name = "QRadar HTTP log stream"
description = "log stream description"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["api", "traffic", "security", "metaproxy", "webfilter"]
qradar_http_config {
certificate = <<-EOT
-----BEGIN CERTIFICATE-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlRuRnThUjU8/prwYxbty
WPT9pURI3lbsKMiB6Fn/VHOKE13p4D8xgOCADpdRagdT6n4etr9atzDKUSvpMtR3
CP5noNc97WiNCggBjVWhs7szEe8ugyqF23XwpHQ6uV1LKH50m92MbOWfCtjU9p/x
qhNpQQ1AZhqNy5Gevap5k8XzRmjSldNAFZMY7Yv3Gi+nyCwGwpVtBUwhuLzgNFK/
yDtw2WcWmUU7NuC8Q6MWvPebxVtCfVp/iQU6q60yyt6aGOBkhAX0LpKAEhKidixY
nP9PNVBvxgu3XZ4P36gZV6+ummKdBVnc3NqwBLu5+CcdRdusmHPHd5pHf4/38Z3/
6qU2a/fPvWzceVTEgZ47QjFMTCTmCwNt29cvi7zZeQzjtwQgn4ipN9NibRH/Ax/q
TbIzHfrJ1xa2RteWSdFjwtxi9C20HUkjXSeI4YlzQMH0fPX6KCE7aVePTOnB69I/
a9/q96DiXZajwlpq3wFctrs1oXqBp5DVrCIj8hU2wNgB7LtQ1mCtsYz//heai0K9
PhE4X6hiE0YmeAZjR0uHl8M/5aW9xCoJ72+12kKpWAa0SFRWLy6FejNYCYpkupVJ
yecLk/4L1W0l6jQQZnWErXZYe0PNFcmwGXy1Rep83kfBRNKRy5tvocalLlwXLdUk
AIU+2GKjyT3iMuzZxxFxPFMCAwEAAQ==
-----END CERTIFICATE-----
EOT
url = "http://qradar.url:1234"
}
}
`
logStreamAccessBridgeS3 = `
resource "pfptmeta_log_streaming_access_bridge" "s3_log_stream" {
name = "S3 log stream"
description = "log stream description"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["api", "traffic", "security", "metaproxy", "webfilter"]
s3_config {
bucket = "mybucket"
compress = true
prefix = "mybucketstream"
}
}
`
logStreamAccessBridgeSplunk = `
resource "pfptmeta_log_streaming_access_bridge" "splunk_http_log_stream" {
name = "Splunk HTTP log stream"
description = "log stream description"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["api", "traffic", "security", "metaproxy", "webfilter"]
splunk_http_config {
certificate = <<-EOT
-----BEGIN CERTIFICATE-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlRuRnThUjU8/prwYxbty
WPT9pURI3lbsKMiB6Fn/VHOKE13p4D8xgOCADpdRagdT6n4etr9atzDKUSvpMtR3
CP5noNc97WiNCggBjVWhs7szEe8ugyqF23XwpHQ6uV1LKH50m92MbOWfCtjU9p/x
qhNpQQ1AZhqNy5Gevap5k8XzRmjSldNAFZMY7Yv3Gi+nyCwGwpVtBUwhuLzgNFK/
yDtw2WcWmUU7NuC8Q6MWvPebxVtCfVp/iQU6q60yyt6aGOBkhAX0LpKAEhKidixY
nP9PNVBvxgu3XZ4P36gZV6+ummKdBVnc3NqwBLu5+CcdRdusmHPHd5pHf4/38Z3/
6qU2a/fPvWzceVTEgZ47QjFMTCTmCwNt29cvi7zZeQzjtwQgn4ipN9NibRH/Ax/q
TbIzHfrJ1xa2RteWSdFjwtxi9C20HUkjXSeI4YlzQMH0fPX6KCE7aVePTOnB69I/
a9/q96DiXZajwlpq3wFctrs1oXqBp5DVrCIj8hU2wNgB7LtQ1mCtsYz//heai0K9
PhE4X6hiE0YmeAZjR0uHl8M/5aW9xCoJ72+12kKpWAa0SFRWLy6FejNYCYpkupVJ
yecLk/4L1W0l6jQQZnWErXZYe0PNFcmwGXy1Rep83kfBRNKRy5tvocalLlwXLdUk
AIU+2GKjyT3iMuzZxxFxPFMCAwEAAQ==
-----END CERTIFICATE-----
EOT
publicly_accessible = false
token = "token"
url = "https://splunk.url"
}
}
`
logStreamAccessBridgeSyslog = `
resource "pfptmeta_log_streaming_access_bridge" "syslog_log_stream" {
name = "Syslog log stream"
description = "log stream description"
notification_channels = [pfptmeta_notification_channel.pagerduty.id]
export_logs = ["api", "traffic", "security", "metaproxy", "webfilter"]
syslog_config {
host = "syslog.hostname.com"
port = 518
proto = "tcp"
}
}`
logStreamAccessBridgeDataSource = `
data "pfptmeta_log_streaming_access_bridge" "log_stream" {
id = pfptmeta_log_streaming_access_bridge.casb_log_stream.id
}`
)
func TestAccResourceLogStreamAccessBridge(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: validateResourceDestroyed("pfptmeta_log_streaming_access_bridge", "v1/access_bridges"),
Steps: []resource.TestStep{
{
Config: logStreamDependencies +
logStreamAccessBridgeCasbStep1 +
logStreamAccessBridgeQRadar +
logStreamAccessBridgeS3 +
logStreamAccessBridgeSplunk +
logStreamAccessBridgeSyslog,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "id", regexp.MustCompile("^ab-.+$")),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "name", "CASB log stream"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "description", "log stream description"),
resource.TestCheckResourceAttrPair(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "notification_channels.0",
"pfptmeta_notification_channel.pagerduty", "id"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "export_logs.0", "traffic"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "export_logs.1", "webfilter"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream",
"proofpoint_casb_config.0.region", "EU"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream",
"proofpoint_casb_config.0.tenant_id", "tenant_70e4b2a567a24159ad6b495ba56b3620"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.qradar_http_log_stream",
"qradar_http_config.0.url", "http://qradar.url:1234"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.s3_log_stream",
"s3_config.0.bucket", "mybucket"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.s3_log_stream",
"s3_config.0.compress", "true"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.s3_log_stream",
"s3_config.0.prefix", "mybucketstream"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.splunk_http_log_stream",
"splunk_http_config.0.publicly_accessible", "false"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.splunk_http_log_stream",
"splunk_http_config.0.token", "token"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.splunk_http_log_stream",
"splunk_http_config.0.url", "https://splunk.url"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.syslog_log_stream",
"syslog_config.0.host", "syslog.hostname.com"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.syslog_log_stream",
"syslog_config.0.port", "518"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.syslog_log_stream",
"syslog_config.0.proto", "tcp"),
),
},
{
Config: logStreamDependencies + logStreamAccessBridgeCasbStep2,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "id", regexp.MustCompile("^ab-.+$")),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "name", "CASB log stream1"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "description", "log stream description1"),
resource.TestCheckResourceAttrPair(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "notification_channels.0",
"pfptmeta_notification_channel.pagerduty", "id"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "export_logs.0", "webfilter"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream", "export_logs.1", "traffic"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream",
"proofpoint_casb_config.0.region", "US"),
resource.TestCheckResourceAttr(
"pfptmeta_log_streaming_access_bridge.casb_log_stream",
"proofpoint_casb_config.0.tenant_id", "tenant_70e4b2a567a24159ad6b495ba56b3621"),
),
},
},
})
}
func TestAccDataSourceLogStreamAccessBridge(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: validateResourceDestroyed("pfptmeta_log_streaming_access_bridge", "v1/access_bridges"),
Steps: []resource.TestStep{
{
Config: logStreamDependencies + logStreamAccessBridgeCasbStep1 + logStreamAccessBridgeDataSource,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "id", regexp.MustCompile("^ab-.+$")),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "name", "CASB log stream"),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "description", "log stream description"),
resource.TestCheckResourceAttrPair(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "notification_channels.0",
"pfptmeta_notification_channel.pagerduty", "id"),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "export_logs.0", "traffic"),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream", "export_logs.1", "webfilter"),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream",
"proofpoint_casb_config.0.region", "EU"),
resource.TestCheckResourceAttr(
"data.pfptmeta_log_streaming_access_bridge.log_stream",
"proofpoint_casb_config.0.tenant_id", "tenant_70e4b2a567a24159ad6b495ba56b3620"),
),
},
},
})
}