>From 8ae906b5d47c441b1b0fbe408c87ca2ab7e3bd5b Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 18 Apr 2014 14:58:57 +0200 Subject: [PATCH 2/4] 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 | 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 7cdecb92a937ff8899ab98c1c1fe8b8dfc7ca1a0..0b19168379b398e68b7acf9921d6d52f21fc55ec 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 42bf358a3e13e9102fde0134762a76038dc3fcff..1e7de8f229eed54fb48beabd749d575c35debe0c 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