@@ -5913,7 +5913,7 @@ func TestDestroyUnmappedIgroup_Succeeds(t *testing.T) {
5913
5913
assert .NoError (t , err )
5914
5914
}
5915
5915
5916
- func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport (t * testing.T ) {
5916
+ func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport_ISCSI (t * testing.T ) {
5917
5917
ctx := context .Background ()
5918
5918
mockCtrl := gomock .NewController (t )
5919
5919
mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
@@ -5941,7 +5941,7 @@ func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport(t *testing.T
5941
5941
assert .NotEqual (t , - 1 , volume .Config .AccessInfo .IscsiAccessInfo .IscsiLunNumber )
5942
5942
}
5943
5943
5944
- func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups (t * testing.T ) {
5944
+ func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups_ISCSI (t * testing.T ) {
5945
5945
ctx := context .Background ()
5946
5946
mockCtrl := gomock .NewController (t )
5947
5947
mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
@@ -5970,7 +5970,7 @@ func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups(t *testing.T)
5970
5970
assert .NotEqual (t , - 1 , volume .Config .AccessInfo .IscsiAccessInfo .IscsiLunNumber )
5971
5971
}
5972
5972
5973
- func TestEnableSANPublishEnforcement_Succeeds (t * testing.T ) {
5973
+ func TestEnableSANPublishEnforcement_Succeeds_ISCSI (t * testing.T ) {
5974
5974
ctx := context .Background ()
5975
5975
mockCtrl := gomock .NewController (t )
5976
5976
mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
@@ -5999,6 +5999,92 @@ func TestEnableSANPublishEnforcement_Succeeds(t *testing.T) {
5999
5999
assert .Equal (t , int32 (- 1 ), volume .Config .AccessInfo .IscsiAccessInfo .IscsiLunNumber )
6000
6000
}
6001
6001
6002
+ func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport_FCP (t * testing.T ) {
6003
+ ctx := context .Background ()
6004
+ mockCtrl := gomock .NewController (t )
6005
+ mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
6006
+
6007
+ volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6008
+ internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6009
+ lunPath := fmt .Sprintf ("/vol/myBucket/storagePrefix_vol1_%s" , internalVolName )
6010
+ volume := & storage.Volume {
6011
+ Config : & storage.VolumeConfig {
6012
+ Name : volName ,
6013
+ InternalName : internalVolName ,
6014
+ AccessInfo : tridentmodels.VolumeAccessInfo {
6015
+ PublishEnforcement : false ,
6016
+ FCPAccessInfo : tridentmodels.FCPAccessInfo {
6017
+ FCPLunNumber : 1 ,
6018
+ },
6019
+ },
6020
+ ImportNotManaged : true ,
6021
+ },
6022
+ }
6023
+
6024
+ err := EnableSANPublishEnforcement (ctx , mockAPI , volume .Config , lunPath )
6025
+ assert .NoError (t , err )
6026
+ assert .False (t , volume .Config .AccessInfo .PublishEnforcement )
6027
+ assert .NotEqual (t , - 1 , volume .Config .AccessInfo .FCPAccessInfo .FCPLunNumber )
6028
+ }
6029
+
6030
+ func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups_FCP (t * testing.T ) {
6031
+ ctx := context .Background ()
6032
+ mockCtrl := gomock .NewController (t )
6033
+ mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
6034
+
6035
+ volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6036
+ internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6037
+ lunPath := fmt .Sprintf ("/vol/myBucket/storagePrefix_vol1_%s" , internalVolName )
6038
+ volume := & storage.Volume {
6039
+ Config : & storage.VolumeConfig {
6040
+ Name : volName ,
6041
+ InternalName : internalVolName ,
6042
+ AccessInfo : tridentmodels.VolumeAccessInfo {
6043
+ PublishEnforcement : false ,
6044
+ FCPAccessInfo : tridentmodels.FCPAccessInfo {
6045
+ FCPLunNumber : 1 ,
6046
+ },
6047
+ },
6048
+ ImportNotManaged : false ,
6049
+ },
6050
+ }
6051
+ mockAPI .EXPECT ().LunListIgroupsMapped (ctx , gomock .Any ()).Return (nil , fmt .Errorf ("ontap api error" ))
6052
+
6053
+ err := EnableSANPublishEnforcement (ctx , mockAPI , volume .Config , lunPath )
6054
+ assert .Error (t , err )
6055
+ assert .False (t , volume .Config .AccessInfo .PublishEnforcement )
6056
+ assert .NotEqual (t , - 1 , volume .Config .AccessInfo .FCPAccessInfo .FCPLunNumber )
6057
+ }
6058
+
6059
+ func TestEnableSANPublishEnforcement_Succeeds_FCP (t * testing.T ) {
6060
+ ctx := context .Background ()
6061
+ mockCtrl := gomock .NewController (t )
6062
+ mockAPI := mockapi .NewMockOntapAPI (mockCtrl )
6063
+
6064
+ volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6065
+ internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6066
+ lunPath := fmt .Sprintf ("/vol/myBucket/storagePrefix_vol1_%s" , internalVolName )
6067
+ volume := & storage.Volume {
6068
+ Config : & storage.VolumeConfig {
6069
+ Name : volName ,
6070
+ InternalName : internalVolName ,
6071
+ AccessInfo : tridentmodels.VolumeAccessInfo {
6072
+ PublishEnforcement : false ,
6073
+ FCPAccessInfo : tridentmodels.FCPAccessInfo {
6074
+ FCPLunNumber : 1 ,
6075
+ },
6076
+ },
6077
+ ImportNotManaged : false ,
6078
+ },
6079
+ }
6080
+ mockAPI .EXPECT ().LunListIgroupsMapped (ctx , gomock .Any ()).Return (nil , nil )
6081
+
6082
+ err := EnableSANPublishEnforcement (ctx , mockAPI , volume .Config , lunPath )
6083
+ assert .NoError (t , err )
6084
+ assert .True (t , volume .Config .AccessInfo .PublishEnforcement )
6085
+ assert .Equal (t , int32 (- 1 ), volume .Config .AccessInfo .FCPAccessInfo .FCPLunNumber )
6086
+ }
6087
+
6002
6088
func TestGetNodeSpecificIgroup (t * testing.T ) {
6003
6089
tests := map [string ]struct {
6004
6090
node , uuid string
0 commit comments