Onboard Argus (ACL): fix edge cases (#314)
* fix empty acl update/create, update CIDR validator * fix sigsegv in test, acl description * Split field mapping, better handle edge cases * Update stackit/internal/services/argus/instance/resource.go Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> --------- Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com>
This commit is contained in:
parent
056c000acc
commit
394d5bf8d6
5 changed files with 99 additions and 24 deletions
|
|
@ -25,7 +25,7 @@ func TestMapFields(t *testing.T) {
|
|||
&argus.GetInstanceResponse{
|
||||
Id: utils.Ptr("iid"),
|
||||
},
|
||||
nil,
|
||||
&argus.ListACLResponse{},
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
@ -139,14 +139,17 @@ func TestMapFields(t *testing.T) {
|
|||
t.Run(tt.description, func(t *testing.T) {
|
||||
state := &Model{
|
||||
ProjectId: tt.expected.ProjectId,
|
||||
ACL: types.SetNull(types.StringType),
|
||||
}
|
||||
err := mapFields(context.Background(), tt.instanceResp, tt.listACLResp, state)
|
||||
if !tt.isValid && err == nil {
|
||||
err := mapFields(context.Background(), tt.instanceResp, state)
|
||||
aclErr := mapACLField(tt.listACLResp, state)
|
||||
if !tt.isValid && err == nil && aclErr == nil {
|
||||
t.Fatalf("Should have failed")
|
||||
}
|
||||
if tt.isValid && err != nil {
|
||||
if tt.isValid && (err != nil || aclErr != nil) {
|
||||
t.Fatalf("Should not have failed: %v", err)
|
||||
}
|
||||
|
||||
if tt.isValid {
|
||||
diff := cmp.Diff(state, &tt.expected)
|
||||
if diff != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue