summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-04-18 14:58:57 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-06-03 11:28:05 +0200
commit71779f6982b9fb343857f9f90e73f93638fc8830 (patch)
tree720491be26c297692d464421ef8ae129f4434dbb
parent080edc7074587e778989d4b5ffad1d8cff768b09 (diff)
downloadsssd-71779f6982b9fb343857f9f90e73f93638fc8830.tar.gz
sssd-71779f6982b9fb343857f9f90e73f93638fc8830.tar.xz
sssd-71779f6982b9fb343857f9f90e73f93638fc8830.zip
TESTS: Create a default sss_names_ctx in create_dom_test_ctx
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 <pbrezina@redhat.com> (cherry picked from commit e4b4b669e0c1ef5ec3be04768edf2565a7bac5a1) Conflicts: src/tests/common.h
-rw-r--r--src/tests/common.h1
-rw-r--r--src/tests/common_dom.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/tests/common.h b/src/tests/common.h
index 7cdecb92a..0b1916837 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 42bf358a3..1e7de8f22 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<domain>[^\\\\]+)\\\\(?P<name>.+$))|" \
+ "((?P<name>[^@]+)@(?P<domain>.+$))|" \
+ "(^(?P<name>[^@\\\\]+)$))",
+ "%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: