>From ae989d7793117078fa63e67c68eaade71ca38ad6 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 18 Apr 2014 14:58:57 +0200 Subject: [PATCH 1/3] TESTS: Create a default sss_names_ctx in create_dom_test_ctx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This would allow to call create_dom_test_ctx from tests that expect to be able to parse input with a regular expression just like a responder would do with an input from a client. Reviewed-by: Pavel Březina (cherry picked from commit e4b4b669e0c1ef5ec3be04768edf2565a7bac5a1) Conflicts: src/tests/common.h --- src/tests/common.h | 2 ++ src/tests/common_dom.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/tests/common.h b/src/tests/common.h index ba3b3a7490ec5bd0e75c5f2f66c39542ca0c37ee..0b19168379b398e68b7acf9921d6d52f21fc55ec 100644 --- a/src/tests/common.h +++ b/src/tests/common.h @@ -62,6 +62,8 @@ struct sss_test_ctx { struct confdb_ctx *confdb; struct tevent_context *ev; struct sss_domain_info *dom; + struct sss_names_ctx *nctx; + char *confdb_path; bool done; int error; diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c index c0b44456c819501b500ed87ffb3a6e089ef3b2dd..ea09d9f3be3def7c306eb96f4bed16d2e7fc927d 100644 --- a/src/tests/common_dom.c +++ b/src/tests/common_dom.c @@ -105,6 +105,18 @@ create_dom_test_ctx(TALLOC_CTX *mem_ctx, } test_ctx->sysdb = test_ctx->dom->sysdb; + /* Init with an AD-style regex to be able to test flat name */ + ret = sss_names_init_from_args(test_ctx, + "(((?P[^\\\\]+)\\\\(?P.+$))|" \ + "((?P[^@]+)@(?P.+$))|" \ + "(^(?P[^@\\\\]+)$))", + "%1$s@%2$s", &test_ctx->nctx); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, "cannot create names context\n"); + goto fail; + } + test_ctx->dom->names = test_ctx->nctx; + return test_ctx; fail: -- 1.9.0