@@ -1113,9 +1113,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
11131113 })
11141114
11151115 It ("should return appropriate values (no optional values added)" , func () {
1116- snapshots , err := r .ListSnapshots (
1117- context .Background (),
1118- & csi.ListSnapshotsRequest {})
1116+
1117+ req := & csi.ListSnapshotsRequest {}
1118+
1119+ if sc .Secrets != nil {
1120+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1121+ }
1122+
1123+ snapshots , err := r .ListSnapshots (context .Background (), req )
11191124 Expect (err ).NotTo (HaveOccurred ())
11201125 Expect (snapshots ).NotTo (BeNil ())
11211126
@@ -1145,9 +1150,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
11451150 r .MustCreateSnapshotFromVolumeRequest (context .Background (), volReq , "listSnapshots-snapshot-unrelated2" )
11461151
11471152 By ("listing snapshots" )
1148- snapshots , err := r .ListSnapshots (
1149- context .Background (),
1150- & csi.ListSnapshotsRequest {SnapshotId : snapshotTarget .GetSnapshot ().GetSnapshotId ()})
1153+
1154+ req := & csi.ListSnapshotsRequest {SnapshotId : snapshotTarget .GetSnapshot ().GetSnapshotId ()}
1155+
1156+ if sc .Secrets != nil {
1157+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1158+ }
1159+
1160+ snapshots , err := r .ListSnapshots (context .Background (), req )
11511161 Expect (err ).NotTo (HaveOccurred ())
11521162 Expect (snapshots ).NotTo (BeNil ())
11531163 Expect (snapshots .GetEntries ()).To (HaveLen (1 ))
@@ -1157,9 +1167,13 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
11571167
11581168 It ("should return empty when the specified snapshot id does not exist" , func () {
11591169
1160- snapshots , err := r .ListSnapshots (
1161- context .Background (),
1162- & csi.ListSnapshotsRequest {SnapshotId : "none-exist-id" })
1170+ req := & csi.ListSnapshotsRequest {SnapshotId : "none-exist-id" }
1171+
1172+ if sc .Secrets != nil {
1173+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1174+ }
1175+
1176+ snapshots , err := r .ListSnapshots (context .Background (), req )
11631177 Expect (err ).NotTo (HaveOccurred ())
11641178 Expect (snapshots ).NotTo (BeNil ())
11651179 Expect (snapshots .GetEntries ()).To (BeEmpty ())
@@ -1187,9 +1201,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
11871201 r .MustCreateSnapshotFromVolumeRequest (context .Background (), volReq , "listSnapshots-snapshot-unrelated2" )
11881202
11891203 By ("listing snapshots" )
1190- snapshots , err := r .ListSnapshots (
1191- context .Background (),
1192- & csi.ListSnapshotsRequest {SourceVolumeId : snapshotTarget .GetSnapshot ().GetSourceVolumeId ()})
1204+
1205+ req := & csi.ListSnapshotsRequest {SourceVolumeId : snapshotTarget .GetSnapshot ().GetSourceVolumeId ()}
1206+
1207+ if sc .Secrets != nil {
1208+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1209+ }
1210+
1211+ snapshots , err := r .ListSnapshots (context .Background (), req )
11931212 Expect (err ).NotTo (HaveOccurred ())
11941213 Expect (snapshots ).NotTo (BeNil ())
11951214 Expect (snapshots .GetEntries ()).To (HaveLen (1 ))
@@ -1200,19 +1219,28 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
12001219
12011220 It ("should return empty when the specified source volume id does not exist" , func () {
12021221
1203- snapshots , err := r .ListSnapshots (
1204- context .Background (),
1205- & csi.ListSnapshotsRequest {SourceVolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID ()})
1222+ req := & csi.ListSnapshotsRequest {SourceVolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID ()}
1223+
1224+ if sc .Secrets != nil {
1225+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1226+ }
1227+
1228+ snapshots , err := r .ListSnapshots (context .Background (), req )
12061229 Expect (err ).NotTo (HaveOccurred ())
12071230 Expect (snapshots ).NotTo (BeNil ())
12081231 Expect (snapshots .GetEntries ()).To (BeEmpty ())
12091232 })
12101233
12111234 It ("check the presence of new snapshots in the snapshot list" , func () {
12121235 // List Snapshots before creating new snapshots.
1213- snapshots , err := r .ListSnapshots (
1214- context .Background (),
1215- & csi.ListSnapshotsRequest {})
1236+
1237+ req := & csi.ListSnapshotsRequest {}
1238+
1239+ if sc .Secrets != nil {
1240+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1241+ }
1242+
1243+ snapshots , err := r .ListSnapshots (context .Background (), req )
12161244 Expect (err ).NotTo (HaveOccurred ())
12171245 Expect (snapshots ).NotTo (BeNil ())
12181246
@@ -1223,21 +1251,21 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
12231251 snapshot , _ := r .MustCreateSnapshotFromVolumeRequest (context .Background (), volReq , "listSnapshots-snapshot-3" )
12241252 verifySnapshotInfo (snapshot .GetSnapshot ())
12251253
1226- snapshots , err = r .ListSnapshots (
1227- context .Background (),
1228- & csi.ListSnapshotsRequest {})
1254+ snapshots , err = r .ListSnapshots (context .Background (), req )
12291255 Expect (err ).NotTo (HaveOccurred ())
12301256 Expect (snapshots ).NotTo (BeNil ())
12311257 Expect (snapshots .GetEntries ()).To (HaveLen (totalSnapshots + 1 ))
12321258
12331259 By ("deleting the snapshot" )
1234- _ , err = r .DeleteSnapshot (context .Background (), & csi.DeleteSnapshotRequest {SnapshotId : snapshot .Snapshot .SnapshotId })
1260+ dreq := & csi.DeleteSnapshotRequest {SnapshotId : snapshot .Snapshot .SnapshotId }
1261+ if sc .Secrets != nil {
1262+ dreq .Secrets = sc .Secrets .DeleteSnapshotSecret
1263+ }
1264+ _ , err = r .DeleteSnapshot (context .Background (), dreq )
12351265 Expect (err ).NotTo (HaveOccurred ())
12361266
12371267 By ("checking if deleted snapshot is omitted" )
1238- snapshots , err = r .ListSnapshots (
1239- context .Background (),
1240- & csi.ListSnapshotsRequest {})
1268+ snapshots , err = r .ListSnapshots (context .Background (), req )
12411269 Expect (err ).NotTo (HaveOccurred ())
12421270 Expect (snapshots ).NotTo (BeNil ())
12431271 Expect (snapshots .GetEntries ()).To (HaveLen (totalSnapshots ))
@@ -1253,10 +1281,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
12531281 // is used to verify that all the snapshots have been listed.
12541282 currentTotalSnapshots := 0
12551283
1284+ req := & csi.ListSnapshotsRequest {}
1285+
1286+ if sc .Secrets != nil {
1287+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1288+ }
1289+
12561290 // Get the number of existing volumes.
1257- snapshots , err := r .ListSnapshots (
1258- context .Background (),
1259- & csi.ListSnapshotsRequest {})
1291+ snapshots , err := r .ListSnapshots (context .Background (), req )
12601292 Expect (err ).NotTo (HaveOccurred ())
12611293 Expect (snapshots ).NotTo (BeNil ())
12621294
@@ -1280,11 +1312,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
12801312 }
12811313
12821314 // Request list snapshots with max entries maxEntries.
1283- snapshots , err = r .ListSnapshots (
1284- context .Background (),
1285- & csi.ListSnapshotsRequest {
1286- MaxEntries : int32 (maxEntries ),
1287- })
1315+
1316+ req = & csi.ListSnapshotsRequest {MaxEntries : int32 (maxEntries )}
1317+
1318+ if sc .Secrets != nil {
1319+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1320+ }
1321+
1322+ snapshots , err = r .ListSnapshots (context .Background (), req )
12881323 Expect (err ).NotTo (HaveOccurred ())
12891324 Expect (snapshots ).NotTo (BeNil ())
12901325
@@ -1293,11 +1328,14 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *TestContext
12931328 Expect (snapshots .GetEntries ()).To (HaveLen (maxEntries ))
12941329
12951330 // Request list snapshots with starting_token and no max entries.
1296- snapshots , err = r .ListSnapshots (
1297- context .Background (),
1298- & csi.ListSnapshotsRequest {
1299- StartingToken : nextToken ,
1300- })
1331+
1332+ req = & csi.ListSnapshotsRequest {StartingToken : nextToken }
1333+
1334+ if sc .Secrets != nil {
1335+ req .Secrets = sc .Secrets .ListSnapshotsSecret
1336+ }
1337+
1338+ snapshots , err = r .ListSnapshots (context .Background (), req )
13011339 Expect (err ).NotTo (HaveOccurred ())
13021340 Expect (snapshots ).NotTo (BeNil ())
13031341
0 commit comments