Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When adding iSCSI target disk during installation, the iSCSI Initiator name and the Target IP is validated to enable/disable the "Start Discovery" button on the page. Currently, the validation of iSCSI Initiator Name is based on the existence of dots only (".") and this can be more efficiently done by using a regular expression. Signed-off-by: Sujith Pandel <sujithpshankar@gmail.com> Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/python | ||
# vim:set fileencoding=utf-8 | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Author(s): Sujith Pandel <sujithpshankar@gmail.com> | ||
# Ajith Pandel <ajithpandel@gmail.com> | ||
# | ||
import unittest | ||
|
||
from regexcheck import regex_match | ||
from pyanaconda.regexes import ISCSI_IQN_NAME_REGEX, ISCSI_EUI_NAME_REGEX | ||
|
||
class iSCSIiqnnameRegexTestCase(unittest.TestCase): | ||
def iqnname_test(self): | ||
good_tests = [ | ||
'iqn.2014-15.com.example', | ||
'iqn.2014-15.com.example:iscsi', | ||
'iqn.2014-15.c-om.example:iscsi', | ||
'iqn.2014-15.c.om.example:iscsi', | ||
'iqn.2014-15.com.example:...', | ||
'iqn.2014-15.com.example:iscsi_@nything_except_colon_after_colon!' | ||
] | ||
|
||
bad_tests = [ | ||
'iqn', | ||
'iqn.', | ||
'iqn.2014-15', | ||
'iqn.2014-15.', | ||
'iqn.2014-15..', | ||
'iqn.2014-15.com.example.', | ||
'iqn.2014-15.com.example...', | ||
'iqn.2014-15.com.example:', | ||
'iqn.2014-15.-com.example', | ||
'iqn.2014-15.com-.example', | ||
'iqn.2014-15.-.example', | ||
'iqn.2014-15.com.example-:iscsi', | ||
'abciqn.2014-15.com.example:iscsi', | ||
'iqn.2014-15.-.example:iscsi', | ||
'iqn.2014-15.com&com.example:iscsi', | ||
'iqn.2014-15.com.example:iscsi:doublecolon', | ||
'iqn.2014-15..om.example:iscsi', | ||
] | ||
|
||
if not regex_match(ISCSI_IQN_NAME_REGEX, good_tests, bad_tests): | ||
self.fail() | ||
|
||
class iSCSIeuinameRegexTestCase(unittest.TestCase): | ||
def euiname_test(self): | ||
good_tests = [ | ||
'eui.ABCDEF0123456789', | ||
'eui.abcdef0123456789', | ||
'eui.0123456789ABCDEF' | ||
] | ||
|
||
bad_tests = [ | ||
'eui', | ||
'eui.', | ||
'eui.2014-', | ||
'eui.exampleeui789abc' | ||
'eui.AAAABBBBCCC2345', | ||
'eui.AAAABBBBCCCCD4567' | ||
] | ||
|
||
if not regex_match(ISCSI_EUI_NAME_REGEX, good_tests, bad_tests): | ||
self.fail() |
20b78a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://tools.ietf.org/html/rfc3720#section-3.2.6.3.1
iqn name as iqn.2001-04.com.example:storage:diskarrays-sn-a8675309 is completely valid.
But ISCSI_IQN_NAME_REGEX = re.compile(r'^iqn.\d{4}-\d{2}((?<!-).(?!-)[a-zA-Z0-9-]+){1,63}(?<!-)(?<!.)(:[^:]+)?$') identify this name invalid.
20b78a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create an issue, please, @SEUNICK
20b78a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see https://bugzilla.redhat.com/show_bug.cgi?id=1750865
20b78a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://bugzilla.redhat.com/show_bug.cgi?id=1750865
This bugzila also reported by me, but no response for a long time, so I reported here.