summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/__init__.py6
-rw-r--r--source4/scripting/python/samba/tests/__init__.py12
2 files changed, 16 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index c5827b96e0..3ecb758595 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -233,10 +233,12 @@ def check_all_substituted(text):
def valid_netbios_name(name):
"""Check whether a name is valid as a NetBIOS name. """
- # FIXME: There are probably more constraints here.
- # crh has a paragraph on this in his book (1.4.1.1)
+ # See crh's book (1.4.1.1)
if len(name) > 15:
return False
+ for x in name:
+ if not x.isalnum() and not x in " !#$%&'()-.@^_{}~":
+ return False
return True
version = glue.version
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index b342b93c49..524c3a3b91 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -96,3 +96,15 @@ class RpcInterfaceTestCase(unittest.TestCase):
def get_credentials(self):
return cmdline_credentials
+
+
+class ValidNetbiosNameTests(unittest.TestCase):
+
+ def test_valid(self):
+ self.assertTrue(valid_netbios_name("FOO"))
+
+ def test_too_long(self):
+ self.assertFalse(valid_netbios_name("FOO"*10))
+
+ def test_invalid_characters(self):
+ self.assertFalse(valid_netbios_name("()BLA"))