Daniel Erez has uploaded a new change for review.

Change subject: core: validate IQN on update iSCSI connection
......................................................................

core: validate IQN on update iSCSI connection

* Add a canDo validation to UpdateStorageServerConnectionCommand
  for empty IQN (similar to AddStorageServerConnectionCommand).
* Updated unit tests accordingly.

Change-Id: I437d93f90f6199238cc7cbe9c264c5bf72cca71c
Bug-Url: https://bugzilla.redhat.com/1005284
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
2 files changed, 20 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/22880/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
index 638bf9e..55c8f63 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
@@ -67,6 +67,11 @@
             return 
failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE);
         }
 
+        if (newConnectionDetails.getstorage_type() == StorageType.ISCSI
+                && StringUtils.isEmpty(newConnectionDetails.getiqn())) {
+            return 
failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN);
+        }
+
         if (checkIsConnectionFieldEmpty(newConnectionDetails)) {
             return false;
         }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
index bb635ca..7f94f69 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
@@ -204,7 +204,7 @@
     @Test
     public void updateChangeConnectionType() {
         StorageServerConnections iscsiConnection =
-                createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", 
"user1", "mypassword123");
+                createISCSIConnection("10.35.16.25", StorageType.ISCSI, 
"iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123");
         parameters.setStorageServerConnection(iscsiConnection);
         
when(storageConnDao.get(iscsiConnection.getid())).thenReturn(oldNFSConnection);
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
@@ -248,6 +248,16 @@
         parameters.setStorageServerConnection(newPosixConnection);
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
                 VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE);
+    }
+
+    @Test
+    public void updateISCSIConnectionEmptyIqn() {
+        StorageServerConnections newISCSIConnection =
+                createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", 
"user1", "mypassword123");
+        parameters.setStorageServerConnection(newISCSIConnection);
+        parameters.setVdsId(Guid.Empty);
+        CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
+                VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_IQN);
     }
 
     @Test
@@ -328,7 +338,7 @@
 
     @Test
     public void updateConnectionOfDomainsAndLunDisks() {
-        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", 
"mypassword123");
+        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, 
"iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123");
         List<LUNs> luns = new ArrayList<>();
         LUNs lun1 = new LUNs();
         lun1.setLUN_id("3600144f09dbd05000000517e730b1212");
@@ -393,7 +403,7 @@
 
     @Test
     public void updateConnectionOfLunDisks() {
-        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", 
"mypassword123");
+        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, 
"iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123");
         List<LUNs> luns = new ArrayList<>();
         LUNs lun1 = new LUNs();
         lun1.setLUN_id("3600144f09dbd05000000517e730b1212");
@@ -437,7 +447,7 @@
 
     @Test
     public void updateConnectionOfDomains() {
-        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", 
"mypassword123");
+        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, 
"iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123");
         List<LUNs> luns = new ArrayList<>();
         LUNs lun1 = new LUNs();
         lun1.setLUN_id("3600144f09dbd05000000517e730b1212");
@@ -469,7 +479,7 @@
 
     @Test
     public void updateConnectionOfUnattachedBlockDomain() {
-        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", 
"mypassword123");
+        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, 
"iqn.2013-04.myhat.com:aaa-target1", "user1", "mypassword123");
         List<LUNs> luns = new ArrayList<>();
         LUNs lun1 = new LUNs();
         lun1.setLUN_id("3600144f09dbd05000000517e730b1212");


-- 
To view, visit http://gerrit.ovirt.org/22880
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I437d93f90f6199238cc7cbe9c264c5bf72cca71c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <de...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to