Exemplo n.º 1
0
def test_dsidm_service_create(topology_st):
    """ Test dsidm service create option

    :id: 338efbc6-51e1-11ec-a83a-3497f624ea11
    :setup: Standalone instance
    :steps:
         1. Run dsidm service create
         2. Check that a message is provided on creation
         3. Check that created service exists
    :expectedresults:
         1. Success
         2. Success
         3. Success
    """

    standalone = topology_st.standalone
    service_name = 'new_service'
    output = f'Successfully created {service_name}'

    args = FakeArgs()
    args.cn = service_name
    args.description = service_name

    log.info('Test dsidm service create')
    create(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st, check_value=output)

    log.info('Check that service is present')
    services = ServiceAccounts(standalone, DEFAULT_SUFFIX)
    new_service = services.get(service_name)
    assert new_service.exists()

    log.info('Clean up for next test')
    new_service.delete()
Exemplo n.º 2
0
def test_dsidm_service_delete(topology_st, create_test_service):
    """ Test dsidm service delete option

    :id: 3b382a96-51e1-11ec-a1c2-3497f624ea11
    :setup: Standalone instance
    :steps:
         1. Run dsidm service delete on created service
         2. Check that a message is provided on deletion
         3. Check that service does not exist
    :expectedresults:
         1. Success
         2. Success
         3. Success
    """

    standalone = topology_st.standalone
    services = ServiceAccounts(standalone, DEFAULT_SUFFIX)
    test_service = services.get('test_service')
    output = f'Successfully deleted {test_service.dn}'

    args = FakeArgs()
    args.dn = test_service.dn

    log.info('Test dsidm service delete')
    delete(standalone,
           DEFAULT_SUFFIX,
           topology_st.logcap.log,
           args,
           warn=False)
    check_value_in_log_and_reset(topology_st, check_value=output)

    log.info('Check that service does not exist')
    assert not test_service.exists()
Exemplo n.º 3
0
def test_clear_days(topology):
    args = FakeArgs()

    rootdn_cli.clear_all_days(topology.standalone, None, topology.logcap.log,
                              args)
    assert topology.logcap.contains("day-based policy was cleared")
    topology.logcap.flush()
Exemplo n.º 4
0
def run_healthcheck_and_flush_log(topology, instance, searched_code, json, searched_code2=None):
    args = FakeArgs()
    args.instance = instance.serverid
    args.verbose = instance.verbose
    args.list_errors = False
    args.list_checks = False
    args.check = ['replication', 'backends:userroot:cl_trimming']
    args.dry_run = False

    if json:
        log.info('Use healthcheck with --json option')
        args.json = json
        health_check_run(instance, topology.logcap.log, args)
        assert topology.logcap.contains(searched_code)
        log.info('Healthcheck returned searched code: %s' % searched_code)

        if searched_code2 is not None:
            assert topology.logcap.contains(searched_code2)
            log.info('Healthcheck returned searched code: %s' % searched_code2)
    else:
        log.info('Use healthcheck without --json option')
        args.json = json
        health_check_run(instance, topology.logcap.log, args)
        assert topology.logcap.contains(searched_code)
        log.info('Healthcheck returned searched code: %s' % searched_code)

        if searched_code2 is not None:
            assert topology.logcap.contains(searched_code2)
            log.info('Healthcheck returned searched code: %s' % searched_code2)

    log.info('Clear the log')
    topology.logcap.flush()
Exemplo n.º 5
0
def test_when_ip_is_denied_its_not_allowed(topology):
    args = FakeArgs()

    args.value = "127.0.0.4"
    rootdn_cli.allow_ip(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("{} added to rootdn-allow-ip".format(
        args.value))
    topology.logcap.flush()

    args.value = None
    rootdn_cli.display_ips(topology.standalone, None, topology.logcap.log,
                           args)
    assert topology.logcap.contains("rootdn-allow-ip: 127.0.0.4")
    topology.logcap.flush()

    args.value = "127.0.0.4"
    rootdn_cli.deny_ip(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("{} added to rootdn-deny-ip".format(
        args.value))
    topology.logcap.flush()

    args.value = None
    rootdn_cli.display_ips(topology.standalone, None, topology.logcap.log,
                           args)
    assert topology.logcap.contains("rootdn-deny-ip: 127.0.0.4")
    assert not topology.logcap.contains("rootdn-allow-ip: 127.0.0.4")
    topology.logcap.flush()
Exemplo n.º 6
0
def test_get_allbackends_when_not_set(topology):
    args = FakeArgs()

    memberof_cli.display_allbackends(topology.standalone, None,
                                     topology.logcap.log, args)
    assert topology.logcap.contains("memberOfAllBackends is not set")
    topology.logcap.flush()
Exemplo n.º 7
0
def test_healthcheck_non_replicated_suffixes(topology_m2):
    """Check if backend lint function unexpectedly throws exception

    :id: f922edf8-c527-4802-9f42-0b75bf97098a
    :setup: 2 MMR topology
    :steps:
        1. Create a new suffix: cn=changelog
        2. Call healthcheck (there should not be any exceptions raised)
    :expectedresults:
        1. Success
        2. Success
    """

    inst = topology_m2.ms['master1']

    # Create second suffix
    backends = Backends(inst)
    backends.create(properties={'nsslapd-suffix': "cn=changelog",
                                'name': 'changelog'})

    # Call healthcheck
    args = FakeArgs()
    args.instance = inst.serverid
    args.verbose = inst.verbose
    args.list_errors = False
    args.list_checks = False
    args.check = ['backends']
    args.dry_run = False
    args.json = False

    health_check_run(inst, topology_m2.logcap.log, args)
Exemplo n.º 8
0
def test_get_skipnested_when_not_set(topology):
    args = FakeArgs()

    memberof_cli.display_skipnested(topology.standalone, None,
                                    topology.logcap.log, args)
    assert topology.logcap.contains("memberOfSkipNested is not set")
    topology.logcap.flush()
Exemplo n.º 9
0
def test_dsidm_user_delete(topology_st, create_test_user):
    """ Test dsidm user delete option

    :id: 3704dc3a-9787-4f74-aaa8-45f38e4a6a52
    :setup: Standalone instance
    :steps:
         1. Run dsidm user delete on created user
         2. Check that a message is provided on deletion
         3. Check that user does not exist
    :expectedresults:
         1. Success
         2. Success
         3. Success
    """

    standalone = topology_st.standalone
    users = nsUserAccounts(standalone, DEFAULT_SUFFIX)
    test_user = users.get('test_user_1000')
    output = 'Successfully deleted {}'.format(test_user.dn)

    args = FakeArgs()
    args.dn = test_user.dn

    log.info('Test dsidm user delete')
    delete(standalone,
           DEFAULT_SUFFIX,
           topology_st.logcap.log,
           args,
           warn=False)
    check_value_in_log_and_reset(topology_st, check_value=output)

    log.info('Check that user does not exist')
    assert not test_user.exists()
Exemplo n.º 10
0
def test_when_host_is_denied_its_not_allowed(topology):
    args = FakeArgs()

    args.value = "example4.com"
    rootdn_cli.allow_host(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("{} added to rootdn-allow-host".format(
        args.value))
    topology.logcap.flush()

    args.value = None
    rootdn_cli.display_hosts(topology.standalone, None, topology.logcap.log,
                             args)
    assert topology.logcap.contains("rootdn-allow-host: example4.com")
    topology.logcap.flush()

    args.value = "example4.com"
    rootdn_cli.deny_host(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("{} added to rootdn-deny-host".format(
        args.value))
    topology.logcap.flush()

    args.value = None
    rootdn_cli.display_hosts(topology.standalone, None, topology.logcap.log,
                             args)
    assert topology.logcap.contains("rootdn-deny-host: example4.com")
    assert not topology.logcap.contains("rootdn-allow-host: example4.com")
    topology.logcap.flush()
Exemplo n.º 11
0
def test_dsidm_config_ldap(topology_st, set_log_file):
    """ Test dsidm creation of ldap.conf content

    :id: 29ffcc91-9104-4c90-bcdf-0f6a4082322c
    :setup: Standalone instance
    :steps:
         1. Create instance
         2. Run dsidm client_config ldap.conf
    :expectedresults:
         1. Success
         2. Success
    """

    standalone = topology_st.standalone
    args = FakeArgs()

    ldap_content_list = [
        'OpenLDAP client configuration',
        'Generated by 389 Directory Server - dsidm',
        'BASE    ' + DEFAULT_SUFFIX, 'URI     ' + standalone.ldapuri,
        'DEREF   never', 'TLS_CACERTDIR /etc/openldap/certs'
    ]

    log.info('Create ldap.conf content')
    ldap_conf(standalone, DEFAULT_SUFFIX, log, args)

    log.info('Check if config creation was successful')
    check_value_in_log_and_reset(ldap_content_list)
Exemplo n.º 12
0
def run_healthcheck_and_flush_log(topology,
                                  instance,
                                  searched_code=None,
                                  json=False,
                                  searched_code2=None,
                                  list_checks=False,
                                  list_errors=False,
                                  check=None,
                                  searched_list=None):
    args = FakeArgs()
    args.instance = instance.serverid
    args.verbose = instance.verbose
    args.list_errors = list_errors
    args.list_checks = list_checks
    args.check = check
    args.dry_run = False
    args.json = json

    log.info('Use healthcheck with --json == {} option'.format(json))
    health_check_run(instance, topology.logcap.log, args)

    if searched_list is not None:
        for item in searched_list:
            assert topology.logcap.contains(item)
            log.info('Healthcheck returned searched item: %s' % item)
    else:
        assert topology.logcap.contains(searched_code)
        log.info('Healthcheck returned searched code: %s' % searched_code)

    if searched_code2 is not None:
        assert topology.logcap.contains(searched_code2)
        log.info('Healthcheck returned searched code: %s' % searched_code2)

    log.info('Clear the log')
    topology.logcap.flush()
Exemplo n.º 13
0
def test_remove_membership_attr_with_value_that_doesnt_exist(topology):
    args = FakeArgs()

    args.value = "whatever"
    referint_cli.remove_membership_attr(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains('No value "{0}" found'.format(args.value))
    topology.logcap.flush()
Exemplo n.º 14
0
def test_plugin_cli(topology):
    args = FakeArgs()

    plugin_list(topology.standalone, None, topology.logcap.log, None)
    for p in plugins:
        assert(topology.logcap.contains(p))
    topology.logcap.flush()

    # print(topology.logcap.outputs)
    # Need to delete something, then re-add it.
    args.selector = 'USN'
    plugin_get(topology.standalone, None, topology.logcap.log, args)
    assert(topology.logcap.contains('USN'))
    topology.logcap.flush()

    args.dn = 'cn=USN,cn=plugins,cn=config'
    plugin_get_dn(topology.standalone, None, topology.logcap.log, args)
    assert(topology.logcap.contains('USN'))
    topology.logcap.flush()

    plugin_disable(topology.standalone, None, topology.logcap.log, args, warn=False)
    assert(topology.logcap.contains('Disabled'))
    topology.logcap.flush()

    plugin_enable(topology.standalone, None, topology.logcap.log, args)
    assert(topology.logcap.contains('Enabled'))
    topology.logcap.flush()
Exemplo n.º 15
0
def test_args(dn):
    args = FakeArgs()
    args.suffix = False
    args.json = False
    args.verbose = False
    args.DN = [dn]
    return args
Exemplo n.º 16
0
def test_basic(topology_st):
    BACKUP_DIR = os.path.join(topology_st.standalone.ds_paths.backup_dir,
                              "basic_backup")
    topology_st.logcap = LogCapture()
    args = FakeArgs()

    users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
    user = users.create_test_user()
    user.replace("description", "backup_test")

    # Clean the backup dir first
    if os.path.exists(BACKUP_DIR):
        shutil.rmtree(BACKUP_DIR)

    # Create the backup
    args.archive = BACKUP_DIR
    args.db_type = None
    backup_create(topology_st.standalone, None, topology_st.logcap.log, args)
    assert os.listdir(BACKUP_DIR)

    # Restore the backup
    args.archive = topology_st.standalone.ds_paths.backup_dir
    args.db_type = None
    backup_restore(topology_st.standalone, None, topology_st.logcap.log, args)
    assert user.present("description", "backup_test")

    # No error has happened! Done!
    # Clean up
    if os.path.exists(BACKUP_DIR):
        shutil.rmtree(BACKUP_DIR)
def test_dsidm_organizational_unit_delete(topology_st, create_test_ou):
    """ Test dsidm organizationalunit delete

    :id: 5d35a5ee-85c2-4b83-9101-938ba7732ccd
    :customerscenario: True
    :setup: Standalone instance
    :steps:
         1. Run dsidm organizationalunit delete
         2. Check the ou is deleted
    :expectedresults:
         1. Success
         2. Entry is deleted
    """

    standalone = topology_st.standalone
    ous = OrganizationalUnits(standalone, DEFAULT_SUFFIX)
    test_ou = ous.get('toDelete')
    delete_value = 'Successfully deleted {}'.format(test_ou.dn)

    args = FakeArgs()
    args.dn = test_ou.dn

    log.info('Test dsidm organizationalunit delete')
    delete(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args, warn=False)
    check_value_in_log_and_reset(topology_st, check_value=delete_value)

    log.info('Check the entry is deleted')
    assert not test_ou.exists()
Exemplo n.º 18
0
def test_remove_all_excludescope(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "a=b" in plugin.get_excludescope():
        plugin.add_excludescope("a=b")
    if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
        plugin.add_excludescope("ou=people,dc=example,dc=com")

    args = FakeArgs()

    args.value = None
    memberof_cli.display_excludescope(topology.standalone, None,
                                      topology.logcap.log, args)
    assert topology.logcap.contains(": a=b")
    assert topology.logcap.contains(": ou=people,dc=example,dc=com")
    topology.logcap.flush()

    args.value = None
    memberof_cli.remove_all_excludescope(topology.standalone, None,
                                         topology.logcap.log, args)
    assert topology.logcap.contains(
        "successfully removed all memberOfEntryScopeExcludeSubtree values")
    topology.logcap.flush()

    args.value = None
    memberof_cli.display_excludescope(topology.standalone, None,
                                      topology.logcap.log, args)
    assert not topology.logcap.contains(": a=b")
    assert not topology.logcap.contains(": ou=people,dc=example,dc=com")
    topology.logcap.flush()
Exemplo n.º 19
0
def test_dsctl_dbverify(topology_st, set_log_file):
    """Test dbverify tool, that was ported from legacy tools to dsctl

    :id: 1b22b363-a6e5-4922-ad42-ae80446d69fe
    :setup: Standalone instance
    :steps:
         1. Create DS instance
         2. Run dbverify
         3. Check if dbverify was successful
    :expectedresults:
         1. Success
         2. Success
         3. Success
    """

    standalone = topology_st.standalone
    message = 'dbverify successful'

    args = FakeArgs()
    args.backend = DEFAULT_BENAME

    log.info('Run dbverify')
    standalone.stop()
    dbtasks_verify(standalone, log, args)

    log.info('Check dbverify was successful')
    with open(LOG_FILE, 'r+') as f:
        file_content = f.read()
        assert message in file_content
Exemplo n.º 20
0
def test_dsidm_config_sssd(topology_st, set_log_file):
    """ Test dsidm creation of sssd.conf content

    :id: 77812ba6-b133-40f4-91a7-13309618f24d
    :setup: Standalone instance
    :steps:
         1. Run dsidm client_config sssd.conf
         2. Enable MemberOfPlugin
         3. Run dsidm client_config sssd.conf with allowed group
    :expectedresults:
         1. Success
         2. Success
         3. Success
    """

    standalone = topology_st.standalone

    sssd_content_list = [
        'Generated by 389 Directory Server - dsidm', 'id_provider = ldap',
        'auth_provider = ldap', 'access_provider = ldap',
        'chpass_provider = ldap', 'ldap_search_base = ' + DEFAULT_SUFFIX,
        'ldap_uri = ' + standalone.ldapuri, 'ldap_user_member_of = memberof',
        'ignore_group_members = False', '[sssd]',
        'services = nss, pam, ssh, sudo', 'config_file_version = 2',
        'domains = ldap', '[nss]', 'homedir_substring = /home'
    ]

    schema = 'ldap_schema = rfc2307'
    args = FakeArgs()
    args.allowed_group = None

    log.info('Create sssd.conf content')
    sssd_conf(standalone, DEFAULT_SUFFIX, log, args)

    log.info('Check if config creation was successful')
    check_value_in_log_and_reset(sssd_content_list, check_value=schema)

    log.info('Now we test allowed_group argument')
    log.info('Enable MemberOf plugin')
    plugin = MemberOfPlugin(standalone)
    plugin.enable()
    standalone.restart()

    log.info('Create test group')
    groups = Groups(standalone, DEFAULT_SUFFIX)
    test_group = groups.create(properties={
        "cn": "new_group",
        "description": "testgroup"
    })

    log.info('Create sssd.conf content with allowed group')
    filter_msg = [
        'ldap_access_filter = (memberOf={})'.format(test_group.dn),
        'ldap_schema = rfc2307bis'
    ]
    args.allowed_group = test_group.rdn
    sssd_conf(standalone, DEFAULT_SUFFIX, log, args)

    log.info('Check if config creation was successful')
    check_value_in_log_and_reset(sssd_content_list, filter_msg)
Exemplo n.º 21
0
def test_add_excludescope_with_legal_value(topology):
    args = FakeArgs()

    args.value = "ou=people,dc=example,dc=com"
    memberof_cli.add_excludescope(topology.standalone, None,
                                  topology.logcap.log, args)
    assert topology.logcap.contains(
        "successfully added memberOfEntryScopeExcludeSubtree value")
    topology.logcap.flush()

    args.value = None
    memberof_cli.display_excludescope(topology.standalone, None,
                                      topology.logcap.log, args)
    assert topology.logcap.contains(": ou=people,dc=example,dc=com")
    topology.logcap.flush()

    args.value = "a=b"
    memberof_cli.add_excludescope(topology.standalone, None,
                                  topology.logcap.log, args)
    assert topology.logcap.contains(
        "successfully added memberOfEntryScopeExcludeSubtree value")
    topology.logcap.flush()

    args.value = None
    memberof_cli.display_excludescope(topology.standalone, None,
                                      topology.logcap.log, args)
    assert topology.logcap.contains(": ou=people,dc=example,dc=com")
    assert topology.logcap.contains(": a=b")
    topology.logcap.flush()
Exemplo n.º 22
0
def test_usandsconf_dbgen_cos_indirect(topology_st, set_log_file_and_ldif):
    """Test ldifgen (formerly dbgen) tool to create a COS definition

        :id: ab4b799e-e801-432a-a61d-badad2628201
        :setup: Standalone instance
        :steps:
             1. Create DS instance
             2. Run ldifgen to generate ldif with indirect COS definition
             3. Import generated ldif to database
             4. Check it was properly imported
        :expectedresults:
             1. Success
             2. Success
             3. Success
             4. Success
        """

    LDAP_RESULT = 'adding new entry "cn=My_Postal_Def_indirect,ou=cos indirect definitions,dc=example,dc=com"'

    standalone = topology_st.standalone

    args = FakeArgs()
    args.type = 'indirect'
    args.NAME = 'My_Postal_Def_indirect'
    args.parent = 'ou=cos indirect definitions,dc=example,dc=com'
    args.create_parent = True
    args.cos_specifier = 'businessCategory'
    args.cos_attr = ['postalcode', 'telephonenumber']
    args.cos_template = None
    args.ldif_file = ldif_file

    content_list = [
        'Generating LDIF with the following options:',
        'NAME={}'.format(args.NAME), 'type={}'.format(args.type),
        'parent={}'.format(args.parent), 'create-parent={}'.format(
            args.create_parent), 'cos-specifier={}'.format(args.cos_specifier),
        'cos-attr={}'.format(args.cos_attr),
        'ldif-file={}'.format(args.ldif_file), 'Writing LDIF',
        'Successfully created LDIF file: {}'.format(args.ldif_file)
    ]

    log.info('Run ldifgen to create COS definition ldif')
    dbgen_create_cos_def(standalone, log, args)

    log.info('Check if file exists')
    assert os.path.exists(ldif_file)

    check_value_in_log_and_reset(content_list)

    # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
    run_ldapmodify_from_file(standalone, ldif_file, LDAP_RESULT)

    log.info('Check that COS definition is imported')
    cos_def = CosIndirectDefinitions(standalone, args.parent)
    assert cos_def.exists(args.NAME)
    new_cos = cos_def.get(args.NAME)
    assert new_cos.present('cosIndirectSpecifier', args.cos_specifier)
    assert new_cos.present('cosAttribute', args.cos_attr[0])
    assert new_cos.present('cosAttribute', args.cos_attr[1])
Exemplo n.º 23
0
def test_set_groupattr_with_illegal_value(topology):
    args = FakeArgs()

    args.value = "whatever"
    memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log,
                               args)
    assert topology.logcap.contains("Illegal value")
    topology.logcap.flush()
Exemplo n.º 24
0
def test_set_attr_with_illegal_value(topology):
    args = FakeArgs()

    args.value = "whatever"
    memberof_cli.manage_attr(topology.standalone, None, topology.logcap.log,
                             args)
    assert topology.logcap.contains("Failed to set")
    topology.logcap.flush()
Exemplo n.º 25
0
def test_add_excludescope_with_illegal_value(topology):
    args = FakeArgs()

    args.value = "whatever"
    memberof_cli.add_excludescope(topology.standalone, None,
                                  topology.logcap.log, args)
    assert topology.logcap.contains("Error: Invalid DN")
    topology.logcap.flush()
Exemplo n.º 26
0
def test_get_entryscope_when_not_set(topology):
    args = FakeArgs()

    args.value = None
    memberof_cli.display_scope(topology.standalone, None, topology.logcap.log,
                               args)
    assert topology.logcap.contains("memberOfEntryScope is not set")
    topology.logcap.flush()
Exemplo n.º 27
0
def test_remove_excludescope_with_non_existing_value(topology):
    args = FakeArgs()

    args.value = "whatever"
    memberof_cli.remove_excludescope(topology.standalone, None,
                                     topology.logcap.log, args)
    assert topology.logcap.contains('No value "{0}" found'.format(args.value))
    topology.logcap.flush()
Exemplo n.º 28
0
def test_dsidm_user_list(topology_st, create_test_user):
    """ Test dsidm user list option

    :id: a7400ac2-b629-4507-bc05-c6402a5b437b
    :setup: Standalone instance
    :steps:
         1. Run dsidm user list option without json
         2. Check the output content is correct
         3. Run dsidm user list option with json
         4. Check the json content is correct
         5. Delete the user
         6. Check the user is not in the list with json
         7. Check the user is not in the list without json
    :expectedresults:
         1. Success
         2. Success
         3. Success
         4. Success
         5. Success
         6. Success
         7. Success
    """

    standalone = topology_st.standalone
    args = FakeArgs()
    args.json = False
    user_value = 'test_user_1000'
    json_list = ['type', 'list', 'items']

    log.info('Empty the log file to prevent false data to check about user')
    topology_st.logcap.flush()

    log.info('Test dsidm user list without json')
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st, check_value=user_value)

    log.info('Test dsidm user list with json')
    args.json = True
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st,
                                 content_list=json_list,
                                 check_value=user_value)

    log.info('Delete the user')
    users = nsUserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
    testuser = users.get(user_value)
    testuser.delete()

    log.info('Test empty dsidm user list with json')
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st,
                                 content_list=json_list,
                                 check_value_not=user_value)

    log.info('Test empty dsidm user list without json')
    args.json = False
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st, check_value_not=user_value)
Exemplo n.º 29
0
def test_dsidm_service_list(topology_st, create_test_service):
    """ Test dsidm service list option

    :id: 218aa060-51e1-11ec-8a70-3497f624ea11
    :setup: Standalone instance
    :steps:
         1. Run dsidm service list option without json
         2. Check the output content is correct
         3. Run dsidm service list option with json
         4. Check the json content is correct
         5. Delete the service
         6. Check the service is not in the list with json
         7. Check the service is not in the list without json
    :expectedresults:
         1. Success
         2. Success
         3. Success
         4. Success
         5. Success
         6. Success
         7. Success
    """

    standalone = topology_st.standalone
    args = FakeArgs()
    args.json = False
    service_value = 'test_service'
    json_list = ['type', 'list', 'items']

    log.info('Empty the log file to prevent false data to check about service')
    topology_st.logcap.flush()

    log.info('Test dsidm service list without json')
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st, check_value=service_value)

    log.info('Test dsidm service list with json')
    args.json = True
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st,
                                 content_list=json_list,
                                 check_value=service_value)

    log.info('Delete the service')
    services = ServiceAccounts(topology_st.standalone, DEFAULT_SUFFIX)
    testservice = services.get(service_value)
    testservice.delete()

    log.info('Test empty dsidm service list with json')
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st,
                                 content_list=json_list,
                                 check_value_not=service_value)

    log.info('Test empty dsidm service list without json')
    args.json = False
    list(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args)
    check_value_in_log_and_reset(topology_st, check_value_not=service_value)
Exemplo n.º 30
0
def test_usandsconf_dbgen_nested_ldif(topology_st, set_log_file_and_ldif):
    """Test ldifgen (formerly dbgen) tool to create nested ldif

        :id: 9c281c28-4169-45e0-8c07-c5502d9a7581
        :setup: Standalone instance
        :steps:
             1. Create DS instance
             2. Run ldifgen to generate nested ldif
             3. Import generated ldif to database
             4. Check it was properly imported
        :expectedresults:
             1. Success
             2. Success
             3. Success
             4. Success
        """

    standalone = topology_st.standalone

    args = FakeArgs()
    args.suffix = DEFAULT_SUFFIX
    args.node_limit = "100"
    args.num_users = "600"
    args.ldif_file = ldif_file

    content_list = [
        'Generating LDIF with the following options:', 'suffix={}'.format(
            args.suffix), 'node-limit={}'.format(args.node_limit),
        'num-users={}'.format(args.num_users),
        'ldif-file={}'.format(args.ldif_file), 'Writing LDIF',
        'Successfully created nested LDIF file ({}) containing 6 nodes/subtrees'
        .format(args.ldif_file)
    ]

    log.info('Run ldifgen to create nested ldif')
    dbgen_create_nested(standalone, log, args)

    log.info('Check if file exists')
    assert os.path.exists(ldif_file)

    check_value_in_log_and_reset(content_list)

    log.info('Get number of accounts before import')
    accounts = Accounts(standalone, DEFAULT_SUFFIX)
    count_account = len(accounts.filter('(uid=*)'))
    count_ou = len(accounts.filter('(ou=*)'))

    # Groups, COS, Roles and modification ldifs are designed to be used by ldapmodify, not ldif2db
    # ldapmodify will complain about already existing suffix which causes subprocess to return exit code != 0
    with pytest.raises(subprocess.CalledProcessError):
        run_ldapmodify_from_file(standalone, ldif_file)

    standalone.restart()

    log.info('Check that accounts are imported')
    assert len(accounts.filter('(uid=*)')) > count_account
    assert len(accounts.filter('(ou=*)')) > count_ou