Skip to content

Commit 54769a2

Browse files
author
impart-security
committed
Update terraform provider
1 parent 827af1a commit 54769a2

22 files changed

+3350
-31
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [0.8.1] - 2024-08-06
4+
5+
### Changed
6+
7+
- Added assertions to impart_rule_test_case resource
8+
39
## [0.8.0] - 2024-07-24
410

511
### Changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.0
1+
0.8.1

docs/resources/rule_test_case.md

+56
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,35 @@ resource "impart_rule_test_case" "example" {
3535
}
3636
}
3737
]
38+
39+
assertions = [
40+
{
41+
message_indexes = [0]
42+
assertion_type = "output"
43+
condition = "contains" #contains|not_contains
44+
expected = "test"
45+
},
46+
{
47+
message_indexes = [0]
48+
assertion_type = "block"
49+
location = "req" # req|res
50+
expected = "true"
51+
},
52+
{
53+
message_indexes = [0]
54+
assertion_type = "status_code"
55+
location = "req" # req|res
56+
condition = "one_of" # equal|not_equal|greater_than|less_than|one_of
57+
expected = "201,200"
58+
},
59+
{
60+
message_indexes = [0]
61+
assertion_type = "tags"
62+
location = "req" # req|res
63+
condition = "contains" # contains|not_contains
64+
expected = "tagname"
65+
}
66+
]
3867
}
3968
```
4069

@@ -48,6 +77,7 @@ resource "impart_rule_test_case" "example" {
4877

4978
### Optional
5079

80+
- `assertions` (Attributes List) The assertions of the test case. (see [below for nested schema](#nestedatt--assertions))
5181
- `description` (String) The description of the test case.
5282

5383
### Read-Only
@@ -100,3 +130,29 @@ Optional:
100130
- `header_keys` (List of String) The HTTP response header keys.
101131
- `header_values` (List of String) The HTTP response header values.
102132
- `truncated_body` (Boolean) Indicates whether the response body was truncated.
133+
134+
135+
136+
<a id="nestedatt--assertions"></a>
137+
### Nested Schema for `assertions`
138+
139+
Required:
140+
141+
- `assertion_type` (String) The assertion type of the request.
142+
- `expected` (String) The expected value of the assertion.
143+
It is a string value, and the format it must satisfy depends on the assertion type:
144+
**output**: A string.
145+
**tags**: A string.
146+
**status_code**: An integer value (e.g., "200") or comma-separated list of integers for one_of condition (e.g., "200,404,500").
147+
**block**: A boolean value represented as "true" or "false".
148+
- `message_indexes` (List of Number) The indexes of the messages in the test case the assertion applies to.
149+
150+
Optional:
151+
152+
- `condition` (String) The condition of the assertion.
153+
Accepted values per assertion type:
154+
**output**: contains, not_contains.
155+
**tags**: contains, not_contains.
156+
**status_code**: equal, not_equal, greater_than, less_than, one_of.
157+
**block**: N/A
158+
- `location` (String) The location of the assertion. Allowed values: req, res. Not applicable for assertion type output.

examples/resources/impart_rule_test_case/resource.tf

+29
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,33 @@ resource "impart_rule_test_case" "example" {
2020
}
2121
}
2222
]
23+
24+
assertions = [
25+
{
26+
message_indexes = [0]
27+
assertion_type = "output"
28+
condition = "contains" #contains|not_contains
29+
expected = "test"
30+
},
31+
{
32+
message_indexes = [0]
33+
assertion_type = "block"
34+
location = "req" # req|res
35+
expected = "true"
36+
},
37+
{
38+
message_indexes = [0]
39+
assertion_type = "status_code"
40+
location = "req" # req|res
41+
condition = "one_of" # equal|not_equal|greater_than|less_than|one_of
42+
expected = "201,200"
43+
},
44+
{
45+
message_indexes = [0]
46+
assertion_type = "tags"
47+
location = "req" # req|res
48+
condition = "contains" # contains|not_contains
49+
expected = "tagname"
50+
}
51+
]
2352
}

go.mod

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ go 1.22
55
require (
66
github.com/hashicorp/terraform-plugin-docs v0.19.4
77
github.com/hashicorp/terraform-plugin-framework v1.10.0
8+
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
89
github.com/hashicorp/terraform-plugin-go v0.23.0
910
github.com/hashicorp/terraform-plugin-log v0.9.0
1011
github.com/hashicorp/terraform-plugin-testing v1.9.0
1112
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
12-
golang.org/x/oauth2 v0.21.0
13+
golang.org/x/oauth2 v0.22.0
1314
)
1415

1516
require (
@@ -38,14 +39,14 @@ require (
3839
github.com/hashicorp/go-hclog v1.6.3 // indirect
3940
github.com/hashicorp/go-multierror v1.1.1 // indirect
4041
github.com/hashicorp/go-plugin v1.6.1 // indirect
42+
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
4143
github.com/hashicorp/go-uuid v1.0.3 // indirect
4244
github.com/hashicorp/go-version v1.7.0 // indirect
43-
github.com/hashicorp/hc-install v0.7.0 // indirect
45+
github.com/hashicorp/hc-install v0.8.0 // indirect
4446
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
4547
github.com/hashicorp/logutils v1.0.0 // indirect
4648
github.com/hashicorp/terraform-exec v0.21.0 // indirect
4749
github.com/hashicorp/terraform-json v0.22.1 // indirect
48-
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 // indirect
4950
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
5051
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
5152
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
@@ -74,14 +75,14 @@ require (
7475
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
7576
golang.org/x/crypto v0.25.0 // indirect
7677
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
77-
golang.org/x/mod v0.19.0 // indirect
78+
golang.org/x/mod v0.20.0 // indirect
7879
golang.org/x/net v0.27.0 // indirect
79-
golang.org/x/sync v0.7.0 // indirect
80-
golang.org/x/sys v0.22.0 // indirect
80+
golang.org/x/sync v0.8.0 // indirect
81+
golang.org/x/sys v0.23.0 // indirect
8182
golang.org/x/text v0.16.0 // indirect
8283
golang.org/x/tools v0.23.0 // indirect
8384
google.golang.org/appengine v1.6.8 // indirect
84-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect
85+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
8586
google.golang.org/grpc v1.65.0 // indirect
8687
google.golang.org/protobuf v1.34.2 // indirect
8788
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

+14-12
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
8383
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
8484
github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
8585
github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
86+
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
87+
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
8688
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
8789
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
8890
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
8991
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
9092
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
91-
github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk=
92-
github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA=
93+
github.com/hashicorp/hc-install v0.8.0 h1:LdpZeXkZYMQhoKPCecJHlKvUkQFixN/nvyR1CdfOLjI=
94+
github.com/hashicorp/hc-install v0.8.0/go.mod h1:+MwJYjDfCruSD/udvBmRB22Nlkwwkwf5sAB6uTIhSaU=
9395
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
9496
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
9597
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
@@ -220,22 +222,22 @@ golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/
220222
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM=
221223
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
222224
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
223-
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
224-
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
225+
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
226+
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
225227
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
226228
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
227229
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
228230
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
229231
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
230232
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
231233
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
232-
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
233-
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
234+
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
235+
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
234236
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
235237
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
236238
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
237-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
238-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
239+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
240+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
239241
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
240242
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
241243
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -249,8 +251,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
249251
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
250252
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
251253
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
252-
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
253-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
254+
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
255+
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
254256
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
255257
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
256258
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -272,8 +274,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
272274
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
273275
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
274276
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
275-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo=
276-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
277+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q=
278+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
277279
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
278280
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
279281
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=

0 commit comments

Comments
 (0)