Bug 37945 - 90_ucsschool.106_valid_hostname.test fails on s4-only-master
90_ucsschool.106_valid_hostname.test fails on s4-only-master
Status: RESOLVED FIXED
Product: UCS@school
Classification: Unclassified
Component: ucs-test
UCS@school 4.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: Ammar Najjar
:
Depends on: 36034 37802
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-05 12:22 CET by Ammar Najjar
Modified: 2015-03-16 09:41 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2015-03-05 15:47:07 CET
From the log file:
---[cut]---
Usage: create_ou [options] <ou_name> [<educational_dc_name> [<administrative_dc_name>]]
 create school container for UCS@school

Arguments:
  <ou_name>		        name of ou that shall be created or verified
  <educational_dc_name>	hostname of the educational DC for specified OU
						(if dc_name is not specified "dc<ou_name>-01" will be
						used as the default for the domaincontroller name)
  <administrative_dc_name>  hostname of the administrative DC for the specified OU

create_ou: error: no such option: -b
---[cut]---

There were also the errors:
create_ou: error: no such option: -e
and
create_ou: error: no such option: -n

It looks like the OU name, the given edu_dc_name or the admin_dc_name starts incorrectly with a dash character.
Comment 2 Ammar Najjar univentionstaff 2015-03-06 08:39:59 CET
(In reply to Sönke Schwardt-Krummrich from comment #1)
> It looks like the OU name, the given edu_dc_name or the admin_dc_name starts
> incorrectly with a dash character.

The test script includes testing such cases, where they should fail.
The bug here is that it was possible to create a school with a dc_name containing an underscore in the middle, e.g:
### FAIL ###
Creating a school(jnjvcugq9h) cli with dc_name=yf1z_brk was unexpectedly successful
###      ###
Comment 3 Ammar Najjar univentionstaff 2015-03-11 11:41:28 CET
In /usr/share/ucs-school-import/scripts/create_ou line 151 function is_valid_ou_name:

def is_valid_hostname(name): 
    """ check if given hostname is valid """
    return bool(re.match('^[a-zA-Z0-9](([a-zA-Z0-9-_]*)([a-zA-Z0-9]$))?$', name))

This includes the "_" in the middle of a host name to be valid, while it is not.
Removing the "_" from the regex make the test script pass.
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2015-03-12 11:38:12 CET
Please add an exception for the CLI variant of create_ou in the test script. 
The CLI variant does also accept underscores in hostnames for compatibility reasons. The UMC and the python variant do not accept underscores.
Comment 5 Ammar Najjar univentionstaff 2015-03-16 09:41:26 CET
(In reply to Sönke Schwardt-Krummrich from comment #4)
> Please add an exception for the CLI variant of create_ou in the test script. 
> The CLI variant does also accept underscores in hostnames for compatibility
> reasons. The UMC and the python variant do not accept underscores.

Done.