mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-15 01:53:51 -06:00
providers/aws: test S3 policy unmarshaled JSON
This commit is contained in:
parent
9c764a3253
commit
4b17554993
@ -1,8 +1,10 @@
|
|||||||
package aws
|
package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -195,8 +197,17 @@ func testAccCheckAWSS3BucketPolicy(n string, policy string) resource.TestCheckFu
|
|||||||
return fmt.Errorf("bad policy, found nil, expected: %s", policy)
|
return fmt.Errorf("bad policy, found nil, expected: %s", policy)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if *v != policy {
|
expected := make(map[string]interface{})
|
||||||
return fmt.Errorf("bad policy, expected: %s, got %#v", policy, *v)
|
if err := json.Unmarshal([]byte(policy), &expected); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
actual := make(map[string]interface{})
|
||||||
|
if err := json.Unmarshal([]byte(*v), &actual); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
|
return fmt.Errorf("bad policy, expected: %#v, got %#v", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user