9
9
"testing"
10
10
"time"
11
11
12
+ "github.com/gotidy/ptr"
12
13
"github.com/stretchr/testify/assert"
13
14
"github.com/stretchr/testify/suite"
14
15
@@ -21,13 +22,13 @@ import (
21
22
"github.com/ekristen/aws-nuke/v3/pkg/awsmod"
22
23
)
23
24
24
- type TestS3BucketObjectLockSuite struct {
25
+ type TestS3BucketSuite struct {
25
26
suite.Suite
26
27
bucket string
27
28
svc * s3.S3
28
29
}
29
30
30
- func (suite * TestS3BucketObjectLockSuite ) SetupSuite () {
31
+ func (suite * TestS3BucketSuite ) SetupSuite () {
31
32
var err error
32
33
33
34
suite .bucket = fmt .Sprintf ("aws-nuke-testing-bucket-%d" , time .Now ().UnixNano ())
@@ -89,7 +90,7 @@ func (suite *TestS3BucketObjectLockSuite) SetupSuite() {
89
90
}
90
91
}
91
92
92
- func (suite * TestS3BucketObjectLockSuite ) TearDownSuite () {
93
+ func (suite * TestS3BucketSuite ) TearDownSuite () {
93
94
iterator := newS3DeleteVersionListIterator (suite .svc , & s3.ListObjectVersionsInput {
94
95
Bucket : & suite .bucket ,
95
96
}, true )
@@ -118,6 +119,10 @@ func (suite *TestS3BucketObjectLockSuite) TearDownSuite() {
118
119
}
119
120
}
120
121
122
+ type TestS3BucketObjectLockSuite struct {
123
+ TestS3BucketSuite
124
+ }
125
+
121
126
func (suite * TestS3BucketObjectLockSuite ) TestS3BucketObjectLock () {
122
127
// Verify the object lock configuration
123
128
result , err := suite .svc .GetObjectLockConfiguration (& s3.GetObjectLockConfigurationInput {
@@ -144,11 +149,16 @@ func (suite *TestS3BucketObjectLockSuite) TestS3BucketRemove() {
144
149
assert .Error (suite .T (), err )
145
150
}
146
151
147
- func (suite * TestS3BucketObjectLockSuite ) TestS3BucketRemoveWithBypass () {
152
+ type TestS3BucketBypassGovernanceSuite struct {
153
+ TestS3BucketSuite
154
+ }
155
+
156
+ func (suite * TestS3BucketBypassGovernanceSuite ) TestS3BucketRemoveWithBypass () {
148
157
// Create the S3Bucket object
149
158
bucket := & S3Bucket {
150
- svc : suite .svc ,
151
- name : suite .bucket ,
159
+ svc : suite .svc ,
160
+ name : suite .bucket ,
161
+ ObjectLock : ptr .String ("Enabled" ),
152
162
settings : & libsettings.Setting {
153
163
"BypassGovernanceRetention" : true ,
154
164
},
@@ -161,3 +171,7 @@ func (suite *TestS3BucketObjectLockSuite) TestS3BucketRemoveWithBypass() {
161
171
func TestS3BucketObjectLock (t * testing.T ) {
162
172
suite .Run (t , new (TestS3BucketObjectLockSuite ))
163
173
}
174
+
175
+ func TestS3BucketBypassGovernance (t * testing.T ) {
176
+ suite .Run (t , new (TestS3BucketBypassGovernanceSuite ))
177
+ }
0 commit comments