feat(waf): Onboard Managed Rule Set#1594
Conversation
754f80e to
2cb3a8e
Compare
Merging this branch changes the coverage (1 decrease, 2 increase)
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
SerseusWasTaken
left a comment
There was a problem hiding this comment.
The acc test fails for me with:
TF_ACC=1 go test -timeout=20m -v stackit/internal/services/albwaf/albwaf_acc_test.go
=== RUN TestAccManagedRuleSet
albwaf_acc_test.go:43: Step 1/4 error: Check failed: Check 2/5 error: stackit_alb_waf_managed_rule_set.managed_rule_set: Attribute 'region' expected "EU01", got "eu01"
panic.go:694: Error running post-test destroy, there may be dangling resources: getting resp: 400 Bad Request, status code 400, Body: {"code":3,"message":"one or more fields are invalid","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest.FieldViolation","field":"region","description":"Expected region t
o be \"eu01\", but got \"EU01\"."}]}
--- FAIL: TestAccManagedRuleSet (1.44s)
FAIL
FAIL command-line-arguments 2.171s
FAIL
But i know some other tests don't run for me but which do for others, so maybe this is some weird issue with my machine again 🤔
| if errors.As(err, &oapiErr) && oapiErr.StatusCode == http.StatusNotFound { | ||
| resp.State.RemoveResource(ctx) | ||
| return | ||
| } |
There was a problem hiding this comment.
We should add a explicit error message here that the resource was not found, otherwise we get a This is a bug in the provider, which should be reported in the provider's own issue tracker. message which is not the case
| } | ||
|
|
||
| func (r *managedRuleSetResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { | ||
| resp.Schema = schema.Schema{ |
There was a problem hiding this comment.
It looks like the datasource and resource have the same schema, so we could define a map which defines all descriptions of the field once and use it in both files, like the git instance does for example. What do you think?
| if createResp.Name == nil { | ||
| core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating ALB WAF Managed Rule Set", "Got empty Managed Rule Set name") | ||
| return | ||
| } |
There was a problem hiding this comment.
Are we under the assumption here that no rule set was actually created when we get a empty name as a response? Since it might be that we actually do create a resource but return an error here nonetheless.
Description
relates to STACKITTPR-716
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)