[SSSD] [PATCH] sysdb: sysdb_search_group_by_name should work like sysdb_search_user_by_name
Sumit Bose
sbose at redhat.com
Wed Sep 17 10:53:54 UTC 2014
On Wed, Sep 17, 2014 at 12:27:24PM +0200, Jakub Hrozek wrote:
> On Tue, Sep 16, 2014 at 05:58:36PM +0200, Sumit Bose wrote:
> > Hi,
> >
> > I came across this when trying to resolve the SID of a group with the
> > group's name.
> >
> > bye,
> > Sumit
>
> ACK. The code also reads much nicer now, thank you.
>
> Is it OK to squash in the attached test?
Of couse it is, but please do it in a separate patch to not forget who
wrote the tests :-)
Some of the error messages odd, can you fix them before pushing?
bye,
Sumit
> From c9d35c190f03db4db943d5d6e9c56cc60cfcdb87 Mon Sep 17 00:00:00 2001
> From: Jakub Hrozek <jhrozek at redhat.com>
> Date: Wed, 17 Sep 2014 12:12:29 +0200
> Subject: [PATCH] TESTS: Add a case-insensitive sysdb test
>
> ---
> src/tests/sysdb-tests.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
> index 5ab8b66144c33ca94242cd0cb75eb46581e17412..2a1393002bec180be9369d6696d4486c45f1f08e 100644
> --- a/src/tests/sysdb-tests.c
> +++ b/src/tests/sysdb-tests.c
> @@ -4972,6 +4972,7 @@ START_TEST(test_sysdb_subdomain_group_ops)
> struct sss_domain_info *subdomain = NULL;
> struct ldb_message *msg = NULL;
> struct ldb_dn *check_dn = NULL;
> + struct sysdb_attrs *group_attrs;
>
> ret = setup_sysdb_tests(&test_ctx);
> fail_if(ret != EOK, "Could not set up the test");
> @@ -4989,20 +4990,36 @@ START_TEST(test_sysdb_subdomain_group_ops)
> fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
> ret, strerror(ret));
>
> + group_attrs = sysdb_new_attrs(test_ctx);
> + fail_unless(group_attrs != NULL, "sysdb_new_attrs failed");
> +
> + ret = sysdb_attrs_add_string(group_attrs, SYSDB_NAME_ALIAS, "subdomgroup");
> + fail_unless(ret == EOK, "sysdb_store_user failed.");
^^^^^^^^^^^^^^^^ copy-n-paste issue.
> +
> ret = sysdb_store_group(subdomain,
> - "subdomgroup", 12345, NULL, -1, 0);
> + "subDomGroup", 12345, group_attrs, -1, 0);
> fail_unless(ret == EOK, "sysdb_store_domgroup failed.");
^^^ old name of the call
>
> check_dn = ldb_dn_new(test_ctx, test_ctx->sysdb->ldb,
> - "name=subdomgroup,cn=groups,cn=test.sub,cn=sysdb");
> + "name=subDomGroup,cn=groups,cn=test.sub,cn=sysdb");
> fail_unless(check_dn != NULL);
>
> - ret = sysdb_search_group_by_name(test_ctx, subdomain, "subdomgroup", NULL,
> + ret = sysdb_search_group_by_name(test_ctx, subdomain, "subDomGroup", NULL,
> &msg);
> fail_unless(ret == EOK, "sysdb_search_domgroup_by_name failed with [%d][%s].",
^^^ old name of the call
> ret, strerror(ret));
> fail_unless(ldb_dn_compare(msg->dn, check_dn) == 0,
> - "Unexpedted DN returned");
> + "Unexpected DN returned");
> +
> + /* subdomains are case insensitive, so it should be possible to search
> + the group with a lowercase name version, too */
> + ret = sysdb_search_group_by_name(test_ctx, subdomain, "subdomgroup", NULL,
> + &msg);
> + fail_unless(ret == EOK, "case-insensitive group search failed with [%d][%s].",
> + ret, strerror(ret));
> + fail_unless(ldb_dn_compare(msg->dn, check_dn) == 0,
> + "Unexpected DN returned");
> +
>
> ret = sysdb_search_group_by_gid(test_ctx, subdomain, 12345, NULL, &msg);
> fail_unless(ret == EOK, "sysdb_search_domgroup_by_gid failed with [%d][%s].",
^^^ old name of the call
> @@ -5010,7 +5027,7 @@ START_TEST(test_sysdb_subdomain_group_ops)
> fail_unless(ldb_dn_compare(msg->dn, check_dn) == 0,
> "Unexpedted DN returned");
>
> - ret = sysdb_delete_group(subdomain, "subdomgroup", 12345);
> + ret = sysdb_delete_group(subdomain, "subDomGroup", 12345);
> fail_unless(ret == EOK, "sysdb_delete_domgroup failed with [%d][%s].",
^^^ old name of the call
> ret, strerror(ret));
>
> --
> 1.9.3
>
> _______________________________________________
> sssd-devel mailing list
> sssd-devel at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
More information about the sssd-devel
mailing list