#51186 Issue 50928 - Unable to create a suffix with countryName either via dscreate or the admin console
Closed 3 years ago by spichugi. Opened 3 years ago by aadhikari.
aadhikari/389-ds-base test-countryname  into  master

@@ -1400,6 +1400,85 @@ 

      assert not dscreate_long_instance.exists()

  

  

+ @pytest.fixture(scope="module", params=('c=uk', 'cn=test_user', 'dc=example,dc=com', 'o=south', 'ou=sales', 'wrong=some_value'))

+ def dscreate_test_rdn_value(request):

+     template_file = "/tmp/dssetup.inf"

+     template_text = f"""[general]

+ config_version = 2

+ # This invalid hostname ...

+ full_machine_name = localhost.localdomain

+ # Means we absolutely require this.

+ strict_host_checking = False

+ # In tests, we can be run in containers, NEVER trust

+ # that systemd is there, or functional in any capacity

+ systemd = False

+ 

+ [slapd]

+ instance_name = test_different_rdn

+ root_dn = cn=directory manager

+ root_password = someLongPassword_123

+ # We do not have access to high ports in containers,

+ # so default to something higher.

+ port = 38999

+ secure_port = 63699

+ 

+ [backend-userroot]

+ create_suffix_entry = True

+ suffix = {request.param}

+ """

+ 

+     with open(template_file, "w") as template_fd:

+         template_fd.write(template_text)

+ 

+     # Unset PYTHONPATH to avoid mixing old CLI tools and new lib389

+     tmp_env = os.environ

+     if "PYTHONPATH" in tmp_env:

+         del tmp_env["PYTHONPATH"]

+ 

+     def fin():

+         os.remove(template_file)

+         if request.param != "wrong=some_value":

+             try:

+                 subprocess.check_call(['dsctl', 'test_different_rdn', 'remove', '--do-it'])

+             except subprocess.CalledProcessError as e:

+                 log.fatal(f"Failed to remove test instance  Error ({e.returncode}) {e.output}")

+         else:

+             log.info("Wrong RDN is passed, instance not created")

+     request.addfinalizer(fin)

+     return template_file, tmp_env, request.param,

+ 

+ 

+ @pytest.mark.skipif(not get_user_is_root() or ds_is_older('1.4.0.0'),

+                     reason="This test is only required with new admin cli, and requires root.")

+ @pytest.mark.bz1807419

+ @pytest.mark.ds50928

+ def test_dscreate_with_different_rdn(dscreate_test_rdn_value):

+     """Test that dscreate works with different RDN attributes as suffix

+ 

+     :id: 77ed6300-6a2f-4e79-a862-1f1105f1e3ef

+     :setup: None

+     :steps:

+         1. Create template file for dscreate with different RDN attributes as suffix

+         2. Create instance using template file

+         3. Create instance with 'wrong=some_value' as suffix's RDN attribute

+     :expectedresults:

+         1. Should succeeds

+         2. Should succeeds

+         3. Should fail

+     """

+     try:

+         subprocess.check_call([ 

+             'dscreate',

+             'from-file',

+             dscreate_test_rdn_value[0]

+         ], env=dscreate_test_rdn_value[1])

+     except subprocess.CalledProcessError as e:

+         log.fatal(f"dscreate failed!  Error ({e.returncode}) {e.output}")

+         if  dscreate_test_rdn_value[2] != "wrong=some_value":

+             assert False

+         else:

+             assert True

+ 

  

  if __name__ == '__main__':

      # Run isolated

Description: Added a test case to create a suffix with countryName via dscreate

Relates: https://pagure.io/389-ds-base/issue/50928

Reviewed by: vashirov

rebased onto 552a1d7eb6df6b74b3da51f85034d58dc07ba29a

3 years ago

Maybe we should add checks for all the supported RDN attributes for suffixes:

  • c
  • cn
  • dc
  • o
  • ou

@mreynolds yes indeed I will add those and a negative scenario to test anything outside this is handled correctly. Thanks :)

rebased onto c34fa49c9a013bf6cc1cc6c069876ff21de41a41

3 years ago

rebased onto a5ffd1f84be306234f0733d98f57e6473d5b433a

3 years ago

I think you can move the common code for setup and removal of the instance to the fixture and parametrize both positive and negative test cases.

rebased onto 7f76ee96ef1dc1ebf80484124c5a58b70d9b92c3

3 years ago

rebased onto e3f87fdb1b58dff8562c3a8505db2a8ef688fcb7

3 years ago

rebased onto af6b44f9e048feeb5f6fc49dcb09d90bc396d62a

3 years ago

rebased onto bf84cd8b8d62100c42fbd380d8fee49dc1422eba

3 years ago

rebased onto dcddffc9785a2327fdbee6db8137f32bebc2333b

3 years ago

rebased onto 5dc1ce91a5f4f4d99a38a96a800be4bcbfc142f9

3 years ago

rebased onto c48f4d9

3 years ago

Pull-Request has been merged by vashirov

3 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4239

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata