@@ -5339,6 +5339,70 @@ func TestOntapNasStorageDriverVolumeImport_NameTemplateLabelLengthExceeding(t *t
53395339 assert .Error (t , result )
53405340}
53415341
5342+ func TestOntapNasStorageDriverVolumeImport_EmptyPolicy (t * testing.T ) {
5343+ mockAPI , driver := newMockOntapNASDriver (t )
5344+ volConfig := & storage.VolumeConfig {
5345+ Size : "1g" ,
5346+ Encryption : "false" ,
5347+ FileSystem : "nfs" ,
5348+ InternalName : "vol2" ,
5349+ PeerVolumeHandle : "SVM1:vol1" ,
5350+ ImportNotManaged : false ,
5351+ UnixPermissions : DefaultUnixPermissions ,
5352+ }
5353+ flexVol := & api.Volume {
5354+ Name : "flexvol" ,
5355+ Comment : "flexvol" ,
5356+ Size : "1" ,
5357+ JunctionPath : "/nfs/vol1" ,
5358+ }
5359+
5360+ tests := []struct {
5361+ name string
5362+ autoExportPolicy bool
5363+ importNotManaged bool
5364+ emptyPolicyShouldBeSet bool
5365+ }{
5366+ {name : "autoExportPolicyFalse" , autoExportPolicy : false , importNotManaged : false , emptyPolicyShouldBeSet : false },
5367+ {name : "setEmptyPolicy" , autoExportPolicy : true , importNotManaged : false , emptyPolicyShouldBeSet : true },
5368+ {name : "importNotManaged" , autoExportPolicy : true , importNotManaged : true , emptyPolicyShouldBeSet : false },
5369+ }
5370+
5371+ for _ , test := range tests {
5372+ t .Run (test .name , func (t * testing.T ) {
5373+ driver .Config .NASType = sa .NFS
5374+ driver .Config .SecurityStyle = "mixed"
5375+ driver .Config .AutoExportPolicy = test .autoExportPolicy
5376+
5377+ volConfig .ImportNotManaged = test .importNotManaged
5378+ volConfig .ExportPolicy = ""
5379+
5380+ mockAPI .EXPECT ().SVMName ().AnyTimes ().Return ("SVM1" )
5381+ mockAPI .EXPECT ().VolumeInfo (ctx , "vol1" ).Return (flexVol , nil )
5382+
5383+ if ! test .importNotManaged {
5384+ mockAPI .EXPECT ().VolumeRename (ctx , "vol1" , "vol2" ).Return (nil )
5385+ mockAPI .EXPECT ().VolumeModifyUnixPermissions (ctx , "vol2" ,
5386+ "vol1" , DefaultUnixPermissions ).Return (nil )
5387+ }
5388+
5389+ if test .emptyPolicyShouldBeSet {
5390+ mockAPI .EXPECT ().ExportPolicyExists (ctx , "test_empty" ).Return (true , nil )
5391+ mockAPI .EXPECT ().VolumeModifyExportPolicy (ctx , "vol2" , "test_empty" ).
5392+ Return (nil )
5393+ }
5394+
5395+ result := driver .Import (ctx , volConfig , "vol1" )
5396+ assert .Nil (t , result )
5397+ if test .emptyPolicyShouldBeSet {
5398+ assert .Equal (t , volConfig .ExportPolicy , "test_empty" )
5399+ } else {
5400+ assert .Equal (t , volConfig .ExportPolicy , "" )
5401+ }
5402+ })
5403+ }
5404+ }
5405+
53425406func TestOntapNasStorageDriverVolumePublish_NASType_None (t * testing.T ) {
53435407 mockAPI , driver := newMockOntapNASDriver (t )
53445408 volConfig := & storage.VolumeConfig {
0 commit comments