From e4b4b669e0c1ef5ec3be04768edf2565a7bac5a1 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 18 Apr 2014 14:58:57 +0200 Subject: 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 --- src/tests/common.h | 1 + src/tests/common_dom.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/tests/common.h b/src/tests/common.h index 54da18f6a..2e71b2295 100644 --- a/src/tests/common.h +++ b/src/tests/common.h @@ -62,6 +62,7 @@ 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; diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c index 514eaac77..d3a7781c3 100644 --- a/src/tests/common_dom.c +++ b/src/tests/common_dom.c @@ -104,6 +104,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: -- cgit