db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose/*
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SSSD
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose certmap - Tests for SSSD's certificate mapping library
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose Authors:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose Sumit Bose <sbose@redhat.com>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose Copyright (C) 2017 Red Hat
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose This program is free software; you can redistribute it and/or modify
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose it under the terms of the GNU General Public License as published by
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose the Free Software Foundation; either version 3 of the License, or
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose (at your option) any later version.
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose This program is distributed in the hope that it will be useful,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose GNU General Public License for more details.
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose You should have received a copy of the GNU General Public License
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose*/
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include <stdarg.h>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include <stddef.h>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include <setjmp.h>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include <cmocka.h>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include <popt.h>
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "lib/certmap/sss_certmap.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "lib/certmap/sss_certmap_int.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "util/crypto/sss_crypto.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "tests/cmocka/common_mock.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "tests/common.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#ifdef HAVE_NSS
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#include "util/crypto/nss/nss_util.h"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#endif
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose#ifdef HAVE_LIBCRYPTO
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose#include <openssl/crypto.h>
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose#endif
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestruct priv_sss_debug {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int level;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosevoid ext_debug(void *private, const char *file, long line, const char *function,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const char *format, ...)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose va_list ap;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct priv_sss_debug *data = private;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int level = SSSDBG_OP_FAILURE;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose if (data != NULL) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose level = data->level;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose if (DEBUG_IS_SET(level)) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose va_start(ap, format);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_vdebug_fn(file, line, function, level, APPEND_LINE_FEED,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose format, ap);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose va_end(ap);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_init(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic struct sss_certmap_ctx *setup_prio(const int *l)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose size_t c;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (c = 0; c < 10; c++) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, l[c], NULL, NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose return ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_add_rule(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int i;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct priority_list *p;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct priority_list *last;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose size_t c;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const int tests_a[][10] = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {1, 3, 5 ,7, 9, 0, 2, 4, 6, 8},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 2, 4, 6, 8, 1, 3, 5, 7, 9},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const int tests_b[][10] = {{0, 0, 0, 0, 1, 1, 1, 2, 2, 2},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {2, 2, 2, 1, 1, 1, 0, 0, 0, 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 1, 2, 0, 1, 2, 0, 1, 2, 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 2, 1, 0, 2, 1, 0, 2, 1, 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 1, 2, 0, 2, 1, 0, 0, 1, 2},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (c = 0; tests_a[c][0] != 0 || tests_a[c][9] != 0; c++) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx = setup_prio(tests_a[0]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i = 0;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (p = ctx->prio_list; p != NULL; p = p->next) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(p->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->rule_list->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(p->rule_list->prev);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(p->rule_list->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i++;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i = 9;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (last = ctx->prio_list; last->next != NULL; last = last->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (p = last; p != NULL; p = p->prev) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->rule_list->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i--;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (c = 0; tests_b[c][0] != 0 || tests_b[c][9] != 0; c++) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx = setup_prio(tests_b[0]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i = 0;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (p = ctx->prio_list; p != NULL; p = p->next) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(p->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i, p->rule_list->priority);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(p->rule_list->prev);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(p->rule_list->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_ptr_equal(p->rule_list, p->rule_list->next->prev);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(p->rule_list->next->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_ptr_equal(p->rule_list->next,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose p->rule_list->next->next->prev);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose if (i == 0) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(p->rule_list->next->next->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_ptr_equal(p->rule_list->next->next,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose p->rule_list->next->next->next->prev);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(p->rule_list->next->next->next->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose } else {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(p->rule_list->next->next->next);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose i++;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_add_matching_rule(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "fsdf", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "FDSF:fsdf", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, ESRCH);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<rgerge>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "KRB5:<rgerge>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<ISSUER>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SUBJECT>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<KU>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<KU>ddqwdq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<KU>digitalSignature,dddq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>dwqwqw", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>.", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>.1.2.3", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>1.2.3.", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<EKU>1.a.3", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:fwfwef>", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:rfc822Name", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose /* invalid base64 input */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:ediPartyName>...", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose /* invalid OID input */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:.>dqq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:.1>dqq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:1.>dqq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<SAN:11>dqq", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EINVAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "<ISSUER>a", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "&&<ISSUER>a", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "KRB5:||<ISSUER>a", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_or);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "KRB5:<ISSUER>a<SUBJECT>b", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("b",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1000,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>a<SUBJECT>b<ISSUER>c<SUBJECT>d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("b",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("c",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 99,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>a<SUBJECT>b"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<KU>dataEncipherment,cRLSign<ISSUER>c"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<SUBJECT>d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("b",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("c",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->ku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(SSS_KU_CRL_SIGN|SSS_KU_DATA_ENCIPHERMENT,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->ku->ku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 98,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>a<SUBJECT>b"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<KU>dataEncipherment,cRLSign<ISSUER>c"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<EKU>clientAuth,emailProtection"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<SUBJECT>d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->subject);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("d",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("b",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->subject->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->issuer);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("c",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->issuer->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->ku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(SSS_KU_CRL_SIGN|SSS_KU_DATA_ENCIPHERMENT,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->ku->ku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->eku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.2",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.4",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list[2]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 97,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<EKU>clientAuth,1.2.3,emailProtection",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->eku);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.2",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.4",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.2.3",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list[3]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose ret = sss_certmap_add_rule(ctx, 96,
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose "KRB5:<EKU>1.2.3",
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose NULL, NULL);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_int_equal(ret, 0);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_non_null(ctx->prio_list);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_non_null(ctx->prio_list->rule_list);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose relation_and);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->eku);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_true(string_in_list("1.2.3",
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose discard_const(
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list),
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose true));
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose assert_null(
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->eku->eku_oid_list[1]);
f5a8cd60c6f377af1954b58f007d16cf3f6dc846Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose /* SAN tests */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 89, "KRB5:<SAN>abc", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->san);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->san->san_opt,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SAN_PRINCIPAL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(ctx->prio_list->rule_list->parsed_match_rule->san->val,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "abc");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 88, "KRB5:<SAN:dnsName>def", NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->san);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->san->san_opt,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SAN_DNS_NAME);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(ctx->prio_list->rule_list->parsed_match_rule->san->val,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "def");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 87, "KRB5:<SAN:x400Address>aGlq",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->san);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->san->san_opt,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SAN_X400_ADDRESS);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->san->bin_val_len,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose 3);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_memory_equal(
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->san->bin_val,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "hij", 3);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 86, "KRB5:<SAN:1.2.3.4>klm",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->r,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose relation_and);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_match_rule->san);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ctx->prio_list->rule_list->parsed_match_rule->san->san_opt,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SAN_STRING_OTHER_NAME);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(ctx->prio_list->rule_list->parsed_match_rule->san->val,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "klm");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("1.2.3.4",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_match_rule->san->str_other_name_oid);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_check_ad_attr_name(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose char *res;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "dsddqwdas");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "dsddq=wdas");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "CN=abc");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "O=xyz");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose res = check_ad_attr_name(NULL, "ST=def");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(res, "S=def");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(res);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Boseconst uint8_t test_cert_der[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x82, 0x04, 0x09, 0x30, 0x82, 0x02, 0xf1, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x09,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x34, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09, 0x49, 0x50, 0x41, 0x2e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x44, 0x45, 0x56, 0x45, 0x4c, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x15,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x35, 0x30, 0x34, 0x32, 0x38, 0x31,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x32, 0x31, 0x31, 0x31, 0x5a, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x34, 0x32, 0x38, 0x31, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x32, 0x31, 0x31, 0x31, 0x5a, 0x30, 0x32, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0c, 0x09, 0x49, 0x50, 0x41, 0x2e, 0x44, 0x45, 0x56, 0x45, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x69, 0x70, 0x61, 0x2d, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x2e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x69, 0x70, 0x61, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb2, 0x32, 0x92, 0xab, 0x47, 0xb8,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0c, 0x13, 0x54, 0x4a, 0x1f, 0x1e, 0x29, 0x06, 0xff, 0xd0, 0x50, 0xcb, 0xf7, 0x5f, 0x79, 0x91,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x65, 0xb1, 0x39, 0x01, 0x83, 0x6a, 0xad, 0x9e, 0x77, 0x3b, 0xf3, 0x0d, 0xd7, 0xb9, 0xf6, 0xdc,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x9e, 0x4a, 0x49, 0xa7, 0xd0, 0x66, 0x72, 0xcc, 0xbf, 0x77, 0xd6, 0xde, 0xa9, 0xfe, 0x67, 0x96,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xcc, 0x49, 0xf1, 0x37, 0x23, 0x2e, 0xc4, 0x50, 0xf4, 0xeb, 0xba, 0x62, 0xd4, 0x23, 0x4d, 0xf3,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x37, 0x38, 0x82, 0xee, 0x3b, 0x3f, 0x2c, 0xd0, 0x80, 0x9b, 0x17, 0xaa, 0x9b, 0xeb, 0xa6, 0xdd,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xf6, 0x15, 0xff, 0x06, 0xb2, 0xce, 0xff, 0xdf, 0x8a, 0x9e, 0x95, 0x85, 0x49, 0x1f, 0x84, 0xfd,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x81, 0x26, 0xce, 0x06, 0x32, 0x0d, 0x36, 0xca, 0x7c, 0x15, 0x81, 0x68, 0x6b, 0x8f, 0x3e, 0xb3,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xa2, 0xfc, 0xae, 0xaf, 0xc2, 0x44, 0x58, 0x15, 0x95, 0x40, 0xfc, 0x56, 0x19, 0x91, 0x80, 0xed,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x42, 0x11, 0x66, 0x04, 0xef, 0x3c, 0xe0, 0x76, 0x33, 0x4b, 0x83, 0xfa, 0x7e, 0xb4, 0x47, 0xdc,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xfb, 0xed, 0x46, 0xa5, 0x8d, 0x0a, 0x66, 0x87, 0xa5, 0xef, 0x7b, 0x74, 0x62, 0xac, 0xbe, 0x73,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x36, 0xc9, 0xb4, 0xfe, 0x20, 0xc4, 0x81, 0xf3, 0xfe, 0x78, 0x19, 0xa8, 0xd0, 0xaf, 0x7f, 0x81,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x72, 0x24, 0x61, 0xd9, 0x76, 0x93, 0xe3, 0x0b, 0xd2, 0x4f, 0x19, 0x17, 0x33, 0x57, 0xd4, 0x82,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xb0, 0xf1, 0xa8, 0x03, 0xf6, 0x01, 0x99, 0xa9, 0xb8, 0x8c, 0x83, 0xc9, 0xba, 0x19, 0x87, 0xea,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xd6, 0x3b, 0x06, 0xeb, 0x4c, 0xf7, 0xf1, 0xe5, 0x28, 0xa9, 0x10, 0xb6, 0x46, 0xde, 0xe1, 0xe1,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3f, 0xc1, 0xcc, 0x72, 0xbe, 0x2a, 0x43, 0xc6, 0xf6, 0xd0, 0xb5, 0xa0, 0xc4, 0x24, 0x6e, 0x4f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xbd, 0xec, 0x22, 0x8a, 0x07, 0x11, 0x3d, 0xf9, 0xd3, 0x15, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x82, 0x01, 0x26, 0x30, 0x82, 0x01, 0x22, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x16, 0x80, 0x14, 0xf2, 0x9d, 0x42, 0x4e, 0x0f, 0xc4, 0x48, 0x25, 0x58, 0x2f, 0x1c, 0xce,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0f, 0xa1, 0x3f, 0x22, 0xc8, 0x55, 0xc8, 0x91, 0x30, 0x3b, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x05, 0x07, 0x01, 0x01, 0x04, 0x2f, 0x30, 0x2d, 0x30, 0x2b, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x05, 0x07, 0x30, 0x01, 0x86, 0x1f, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x69, 0x70, 0x61,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2d, 0x63, 0x61, 0x2e, 0x69, 0x70, 0x61, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x2f, 0x63, 0x61,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2f, 0x6f, 0x63, 0x73, 0x70, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x04, 0x03, 0x02, 0x04, 0xf0, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x05, 0x07, 0x03, 0x02, 0x30, 0x74, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x6d, 0x30, 0x6b, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x69, 0xa0, 0x31, 0xa0, 0x2f, 0x86, 0x2d, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x69, 0x70,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x61, 0x2d, 0x63, 0x61, 0x2e, 0x69, 0x70, 0x61, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x2f, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x70, 0x61, 0x2f, 0x63, 0x72, 0x6c, 0x2f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x43, 0x52, 0x4c,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2e, 0x62, 0x69, 0x6e, 0xa2, 0x34, 0xa4, 0x32, 0x30, 0x30, 0x31, 0x0e, 0x30, 0x0c, 0x06, 0x03,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x55, 0x04, 0x0a, 0x0c, 0x05, 0x69, 0x70, 0x61, 0x63, 0x61, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x55, 0x04, 0x03, 0x0c, 0x15, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0e, 0x04, 0x16, 0x04, 0x14, 0x2d, 0x2b, 0x3f, 0xcb, 0xf5, 0xb2, 0xff, 0x32, 0x2c, 0xa8, 0xc2,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x1c, 0xdd, 0xbd, 0x8c, 0x80, 0x1e, 0xdd, 0x31, 0x82, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x9a, 0x47, 0x2e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x50, 0xa7, 0x4d, 0x1d, 0x53, 0x0f, 0xc9, 0x71, 0x42, 0x0c, 0xe5, 0xda, 0x7d, 0x49, 0x64, 0xe7,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xab, 0xc8, 0xdf, 0xdf, 0x02, 0xc1, 0x87, 0xd1, 0x5b, 0xde, 0xda, 0x6f, 0x2b, 0xe4, 0xf0, 0xbe,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xba, 0x09, 0xdf, 0x02, 0x85, 0x0b, 0x8a, 0xe6, 0x9b, 0x06, 0x7d, 0x69, 0x38, 0x6c, 0x72, 0xff,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x4c, 0x7b, 0x2a, 0x0d, 0x3f, 0x23, 0x2f, 0x16, 0x46, 0xff, 0x05, 0x93, 0xb0, 0xea, 0x24, 0x28,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xd7, 0x12, 0xa1, 0x57, 0xb8, 0x59, 0x19, 0x25, 0xf3, 0x43, 0x0a, 0xd3, 0xfd, 0x0f, 0x37, 0x8d,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xb8, 0xca, 0x15, 0xe7, 0x48, 0x8a, 0xa0, 0xc7, 0xc7, 0x4b, 0x7f, 0x01, 0x3c, 0x58, 0xd7, 0x37,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xe5, 0xff, 0x7d, 0x2b, 0x01, 0xac, 0x0d, 0x9f, 0x51, 0x6a, 0xe5, 0x40, 0x24, 0xe6, 0x5e, 0x55,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0d, 0xf7, 0xb8, 0x2f, 0x42, 0xac, 0x6d, 0xe5, 0x29, 0x6b, 0xc6, 0x0b, 0xa4, 0xbf, 0x19, 0xbd,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x39, 0x27, 0xee, 0xfe, 0xc5, 0xb3, 0xdb, 0x62, 0xd4, 0xbe, 0xd2, 0x47, 0xba, 0x96, 0x30, 0x5a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xfd, 0x62, 0x00, 0xb8, 0x27, 0x5d, 0x2f, 0x3a, 0x94, 0x0b, 0x95, 0x35, 0x85, 0x40, 0x2c, 0xbc,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x67, 0xdf, 0x8a, 0xf9, 0xf1, 0x7b, 0x19, 0x96, 0x3e, 0x42, 0x48, 0x13, 0x23, 0x04, 0x95, 0xa9,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6b, 0x11, 0x33, 0x81, 0x47, 0x5a, 0x83, 0x72, 0xf6, 0x20, 0xfa, 0x8e, 0x41, 0x7b, 0x8f, 0x77,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x47, 0x7c, 0xc7, 0x5d, 0x46, 0xf4, 0x4f, 0xfd, 0x81, 0x0a, 0xae, 0x39, 0x27, 0xb6, 0x6a, 0x26,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x63, 0xb1, 0xd3, 0xbf, 0x55, 0x83, 0x82, 0x9b, 0x36, 0x6c, 0x33, 0x64, 0x0f, 0x50, 0xc0, 0x55,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x94, 0x13, 0xc3, 0x85, 0xf4, 0xd5, 0x71, 0x65, 0xd0, 0xc0, 0xdd, 0xfc, 0xe6, 0xec, 0x9c, 0x5b,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xf0, 0x11, 0xb5, 0x2c, 0xf3, 0x48, 0xc1, 0x36, 0x8c, 0xa2, 0x96, 0x48, 0x84};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Boseconst uint8_t test_cert2_der[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x82, 0x06, 0x98, 0x30, 0x82, 0x05, 0x80, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x0a, 0x61,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x22, 0x88, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa6, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x15, 0x30, 0x13, 0x06, 0x0a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19, 0x16, 0x05, 0x64, 0x65, 0x76, 0x65,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x0a, 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x19, 0x16, 0x02, 0x61, 0x64, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x61, 0x64, 0x2d, 0x41, 0x44, 0x2d, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x2d, 0x43, 0x41, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x1e, 0x17, 0x0d, 0x31, 0x36, 0x31, 0x31, 0x31, 0x31, 0x31, 0x33, 0x35, 0x31, 0x31, 0x31, 0x5a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x17, 0x0d, 0x31, 0x37, 0x31, 0x31, 0x31, 0x31, 0x31, 0x33, 0x35, 0x31, 0x31, 0x31, 0x5a, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x70, 0x31, 0x15, 0x30, 0x13, 0x06, 0x0a, 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x19, 0x16, 0x05, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x0a, 0x09, 0x92,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19, 0x16, 0x02, 0x61, 0x64, 0x31, 0x0e, 0x30, 0x0c,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x05, 0x55, 0x73, 0x65, 0x72, 0x73, 0x31, 0x0c, 0x30, 0x0a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x74, 0x20, 0x75, 0x31, 0x25, 0x30, 0x23, 0x06, 0x09,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x16, 0x74, 0x65, 0x73, 0x74, 0x2e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x75, 0x73, 0x65, 0x72, 0x40, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6e, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x00, 0x9c, 0xcf, 0x36, 0x99, 0xde, 0x63, 0x74, 0x2b, 0x77, 0x25, 0x9e, 0x24, 0xd9, 0x77,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x4b, 0x5f, 0x98, 0xc0, 0x8c, 0xd7, 0x20, 0x91, 0xc0, 0x1c, 0xe8, 0x37, 0x45, 0xbf, 0x3c, 0xd9,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x33, 0xbd, 0xe9, 0xde, 0xc9, 0x5d, 0xd4, 0xcd, 0x06, 0x0a, 0x0d, 0xd4, 0xf1, 0x7c, 0x74, 0x5b,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x29, 0xd5, 0x66, 0x9c, 0x2c, 0x9f, 0x6b, 0x1a, 0x0f, 0x0d, 0xe6, 0x6c, 0x62, 0xa5, 0x41, 0x4f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xc3, 0xa4, 0x88, 0x27, 0x11, 0x5d, 0xb7, 0xb1, 0xfb, 0xf8, 0x8d, 0xee, 0x43, 0x8d, 0x93, 0xb5,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x8c, 0xb4, 0x34, 0x06, 0xf5, 0xe9, 0x2f, 0x5a, 0x26, 0x68, 0xd7, 0x43, 0x60, 0x82, 0x5e, 0x22,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xa7, 0xc6, 0x34, 0x40, 0x19, 0xa5, 0x8e, 0xf0, 0x58, 0x9f, 0x16, 0x2d, 0x43, 0x3f, 0x0c, 0xda,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xe2, 0x23, 0xf6, 0x09, 0x2a, 0x5e, 0xbd, 0x84, 0x27, 0xc8, 0xab, 0xd5, 0x70, 0xf8, 0x3d, 0x9c,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x14, 0xc2, 0xc2, 0xa2, 0x77, 0xe8, 0x44, 0x73, 0x10, 0x01, 0x34, 0x40, 0x1f, 0xc6, 0x2f, 0xa0,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x70, 0xee, 0x2f, 0xd5, 0x4b, 0xbe, 0x4c, 0xc7, 0x45, 0xf7, 0xac, 0x9c, 0xc3, 0x68, 0x5b, 0x1d,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x5a, 0x4b, 0x77, 0x65, 0x76, 0xe4, 0xb3, 0x92, 0xf4, 0x84, 0x0a, 0x9e, 0x6a, 0x9c, 0xc9, 0x53,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x42, 0x9f, 0x6d, 0xfe, 0xf9, 0xf5, 0xf2, 0x9a, 0x15, 0x50, 0x47, 0xef, 0xf4, 0x06, 0x59, 0xc8,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x50, 0x48, 0x4b, 0x46, 0x95, 0x68, 0x25, 0xc5, 0xbd, 0x4f, 0x65, 0x34, 0x00, 0xfc, 0x31, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xf8, 0x3e, 0xe0, 0x20, 0x83, 0x41, 0x27, 0x0b, 0x5c, 0x46, 0x98, 0x14, 0xf0, 0x07, 0xde, 0x02,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x17, 0xb1, 0xd2, 0x9c, 0xbe, 0x1c, 0x0d, 0x56, 0x22, 0x1b, 0x02, 0xfe, 0xda, 0x69, 0xb9, 0xef,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x91, 0x37, 0x39, 0x7f, 0x24, 0xda, 0xc4, 0x81, 0x5e, 0x82, 0x31, 0x2f, 0x98, 0x1d, 0xf7, 0x73,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x5b, 0x23, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x03, 0x5d, 0x30, 0x82, 0x03, 0x59, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3d, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x15, 0x07, 0x04, 0x30, 0x30, 0x2e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x26, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x15, 0x08, 0x87, 0x85, 0xa1, 0x23, 0x84,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xc8, 0xb2, 0x26, 0x83, 0x9d, 0x9d, 0x21, 0x82, 0xd4, 0xa6, 0x1b, 0x86, 0xa3, 0xba, 0x37, 0x81,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x10, 0x85, 0x89, 0xd5, 0x02, 0xd6, 0x8f, 0x24, 0x02, 0x01, 0x64, 0x02, 0x01, 0x02, 0x30, 0x29,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x22, 0x30, 0x20, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x07, 0x03, 0x02, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04, 0x06, 0x0a, 0x2b,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0a, 0x03, 0x04, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x35, 0x06, 0x09, 0x2b, 0x06, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x04, 0x01, 0x82, 0x37, 0x15, 0x0a, 0x04, 0x28, 0x30, 0x26, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x03, 0x04, 0x30, 0x0c, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0a, 0x03, 0x04,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x81, 0x94, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x0f, 0x04, 0x81,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x86, 0x30, 0x81, 0x83, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2a, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x2d, 0x30, 0x0b,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x16, 0x30, 0x0b, 0x06, 0x09, 0x60,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x19, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x65, 0x03, 0x04, 0x01, 0x02, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x05, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x30, 0x07,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x07, 0x30, 0x0e, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0d, 0x03, 0x02, 0x02, 0x02, 0x00, 0x80, 0x30, 0x0e, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x0d, 0x03, 0x04, 0x02, 0x02, 0x02, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x04, 0x14, 0x49, 0xac, 0xad, 0xe0, 0x65, 0x30, 0xc4, 0xce, 0xa0, 0x09, 0x03, 0x5b, 0xad, 0x4a,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x7b, 0x49, 0x5e, 0xc9, 0x6c, 0xb4, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x16, 0x80, 0x14, 0x62, 0x50, 0xb6, 0x8d, 0xa1, 0xe6, 0x2d, 0x91, 0xbf, 0xb0, 0x54, 0x4d, 0x8f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xa8, 0xca, 0x10, 0xae, 0xb8, 0xdd, 0x54, 0x30, 0x81, 0xcc, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x81, 0xc4, 0x30, 0x81, 0xc1, 0x30, 0x81, 0xbe, 0xa0, 0x81, 0xbb, 0xa0, 0x81, 0xb8, 0x86, 0x81,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xb5, 0x6c, 0x64, 0x61, 0x70, 0x3a, 0x2f, 0x2f, 0x2f, 0x43, 0x4e, 0x3d, 0x61, 0x64, 0x2d, 0x41,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x44, 0x2d, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x2d, 0x43, 0x41, 0x2c, 0x43, 0x4e, 0x3d, 0x61,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x64, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2c, 0x43, 0x4e, 0x3d, 0x43, 0x44, 0x50, 0x2c,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x43, 0x4e, 0x3d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x25, 0x32, 0x30, 0x4b, 0x65, 0x79, 0x25,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x32, 0x30, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2c, 0x43, 0x4e, 0x3d, 0x53, 0x65,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2c, 0x43, 0x4e, 0x3d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x44, 0x43, 0x3d, 0x61, 0x64, 0x2c, 0x44, 0x43,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3d, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x3f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x74, 0x65, 0x52, 0x65, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3f, 0x62, 0x61, 0x73, 0x65, 0x3f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x73, 0x3d, 0x63, 0x52, 0x4c, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x30, 0x81, 0xbe, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x07, 0x01, 0x01, 0x04, 0x81, 0xb1, 0x30, 0x81, 0xae, 0x30, 0x81, 0xab, 0x06, 0x08, 0x2b, 0x06,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x81, 0x9e, 0x6c, 0x64, 0x61, 0x70, 0x3a, 0x2f, 0x2f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2f, 0x43, 0x4e, 0x3d, 0x61, 0x64, 0x2d, 0x41, 0x44, 0x2d, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2d, 0x43, 0x41, 0x2c, 0x43, 0x4e, 0x3d, 0x41, 0x49, 0x41, 0x2c, 0x43, 0x4e, 0x3d, 0x50, 0x75,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x62, 0x6c, 0x69, 0x63, 0x25, 0x32, 0x30, 0x4b, 0x65, 0x79, 0x25, 0x32, 0x30, 0x53, 0x65, 0x72,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x76, 0x69, 0x63, 0x65, 0x73, 0x2c, 0x43, 0x4e, 0x3d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x73, 0x2c, 0x43, 0x4e, 0x3d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6f, 0x6e, 0x2c, 0x44, 0x43, 0x3d, 0x61, 0x64, 0x2c, 0x44, 0x43, 0x3d, 0x64, 0x65, 0x76, 0x65,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6c, 0x3f, 0x63, 0x41, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x62, 0x61, 0x73, 0x65, 0x3f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3d, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x3f, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x38,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x30, 0x36, 0xa0, 0x1c, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x14, 0x02, 0x03,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xa0, 0x0e, 0x0c, 0x0c, 0x74, 0x75, 0x31, 0x40, 0x61, 0x64, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x81, 0x16, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x40, 0x65, 0x6d, 0x61, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x6c, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x41, 0x45, 0x0a, 0x6d,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xbb, 0x7f, 0x5c, 0x07, 0x0c, 0xc9, 0xb0, 0x39, 0x55, 0x6d, 0x7c, 0xb5, 0x02, 0xcd, 0xe8, 0xb2,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xe5, 0x02, 0x94, 0x77, 0x60, 0xdb, 0xd1, 0xaf, 0x1d, 0xdb, 0x44, 0x5f, 0xce, 0x83, 0xdb, 0x80,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x2e, 0xe2, 0xb2, 0x08, 0x25, 0x82, 0x14, 0xcb, 0x48, 0x95, 0x20, 0x13, 0x6c, 0xa9, 0xaa, 0xf8,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x31, 0x56, 0xed, 0xc0, 0x3b, 0xd4, 0xae, 0x2e, 0xe3, 0x8f, 0x05, 0xfc, 0xab, 0x5f, 0x2a, 0x69,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x23, 0xbc, 0xb8, 0x8c, 0xec, 0x2d, 0xa9, 0x0b, 0x86, 0x95, 0x73, 0x73, 0xdb, 0x17, 0xce, 0xc6,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xae, 0xc5, 0xb4, 0xc1, 0x25, 0x87, 0x3b, 0x67, 0x43, 0x9e, 0x87, 0x5a, 0xe6, 0xb9, 0xa0, 0x28,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x12, 0x3d, 0xa8, 0x2e, 0xd7, 0x5e, 0xef, 0x65, 0x2d, 0xe6, 0xa5, 0x67, 0x84, 0xac, 0xfd, 0x31,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xc1, 0x78, 0xd8, 0x72, 0x51, 0xa2, 0x88, 0x55, 0x0f, 0x97, 0x47, 0x93, 0x07, 0xea, 0x8a, 0x53,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x27, 0x4e, 0x34, 0x54, 0x34, 0x1f, 0xa0, 0x6a, 0x03, 0x44, 0xfb, 0x23, 0x61, 0x8e, 0x87, 0x8e,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x3c, 0xd0, 0x8f, 0xae, 0xe4, 0xcf, 0xee, 0x65, 0xa8, 0xba, 0x96, 0x68, 0x08, 0x1c, 0x60, 0xe2,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x4e, 0x11, 0xa3, 0x74, 0xb8, 0xa5, 0x4e, 0xea, 0x6a, 0x82, 0x4c, 0xc2, 0x4d, 0x63, 0x8e, 0x9f,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x7c, 0x2f, 0xa8, 0xc0, 0x62, 0xf8, 0xf7, 0xd9, 0x25, 0xc4, 0x91, 0xab, 0x4d, 0x6a, 0x44, 0xaf,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x75, 0x93, 0x53, 0x03, 0xa4, 0x99, 0xc8, 0xcd, 0x91, 0x89, 0x60, 0x75, 0x30, 0x99, 0x76, 0x05,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0x5a, 0xa0, 0x03, 0xa7, 0xa1, 0x2c, 0x03, 0x04, 0x8f, 0xd4, 0x5a, 0x31, 0x52, 0x28, 0x5a, 0xe6,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xa2, 0xd3, 0x43, 0x21, 0x5b, 0xdc, 0xa2, 0x1d, 0x55, 0xa9, 0x48, 0xc5, 0xc4, 0xaa, 0xf3, 0x8b,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose0xe6, 0x3e, 0x75, 0x96, 0xe4, 0x3e, 0x64, 0xaf, 0xe8, 0xa7, 0x6a, 0xb6};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose/* used to test SAN principal encoding according to RFC4556 */
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Boseconst uint8_t test_cert3_der[] = {
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x30, 0x82, 0x03, 0x70, 0x30, 0x82, 0x02, 0x58, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xe5, 0x8f, 0x16, 0xfe, 0x23, 0x4d, 0xc5, 0xd6, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x1a, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x04, 0x03, 0x0c, 0x0f, 0x6b, 0x72, 0x62, 0x35, 0x5f, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x5f, 0x74,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x65, 0x73, 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x37, 0x31, 0x32, 0x30, 0x39, 0x32,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x34, 0x31, 0x38, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x34, 0x30, 0x37, 0x30, 0x39, 0x32, 0x34,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x31, 0x38, 0x5a, 0x30, 0x1a, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x6b, 0x72, 0x62, 0x35, 0x5f, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x30,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xbf, 0x84, 0x34, 0x46, 0x37, 0x50, 0xb1, 0xca, 0x14, 0x4c, 0x6b, 0x0d, 0xe4, 0xab, 0xc1, 0xce,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xf4, 0xd1, 0xde, 0xca, 0xf5, 0x50, 0x46, 0x3c, 0x63, 0x0f, 0x8e, 0xb8, 0xe9, 0xf9, 0x3e, 0xc4,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xf3, 0x24, 0xc1, 0xe4, 0x78, 0xf6, 0xa4, 0x39, 0x6f, 0xc1, 0xd8, 0x9c, 0x1c, 0xa7, 0x47, 0xe4,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xc8, 0x71, 0x32, 0x9a, 0x1d, 0x1d, 0xfb, 0x30, 0x0f, 0xf9, 0x85, 0x48, 0xf8, 0x1f, 0xa7, 0xbd,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xda, 0x39, 0xd4, 0xc7, 0x27, 0x4f, 0xf5, 0x34, 0xee, 0x4a, 0x59, 0x0c, 0x7a, 0xec, 0x2b, 0xaf,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x81, 0x8e, 0x41, 0x54, 0x6f, 0xcc, 0x91, 0x61, 0x4c, 0x61, 0x80, 0xca, 0x37, 0xab, 0x2c, 0x63,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x8d, 0xce, 0x07, 0xcd, 0x61, 0x11, 0x10, 0xa0, 0xe4, 0x08, 0x7d, 0x1d, 0x10, 0x85, 0xb1, 0x64,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x33, 0x6b, 0x4d, 0x8d, 0xd2, 0x9d, 0xd7, 0x0b, 0x21, 0xbc, 0x15, 0xcd, 0xed, 0xaa, 0xc0, 0x01,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x67, 0xe1, 0x7c, 0xd4, 0xf7, 0xdd, 0xf8, 0x28, 0x92, 0xce, 0x8b, 0x7f, 0x08, 0x29, 0x76, 0x6e,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xa5, 0xe6, 0xcd, 0xeb, 0x9c, 0x13, 0x78, 0xa3, 0x08, 0xb5, 0xdc, 0x7f, 0xc2, 0x60, 0xc3, 0xac,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x68, 0x30, 0x37, 0xe1, 0x54, 0x6a, 0xa9, 0x34, 0x3e, 0x43, 0x8d, 0x6f, 0x9b, 0xe5, 0x8a, 0xf9,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xa4, 0x22, 0xab, 0x33, 0x01, 0x32, 0xaf, 0xc4, 0x9f, 0xb1, 0x27, 0xba, 0xae, 0x20, 0x60, 0xd7,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x16, 0x48, 0x66, 0x2b, 0x36, 0x9c, 0x54, 0xd0, 0x6e, 0x45, 0xd3, 0x23, 0x3f, 0x17, 0x2e, 0xee,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xd4, 0x55, 0xa7, 0x75, 0x2f, 0x28, 0xa9, 0x40, 0x3b, 0xbc, 0x79, 0x69, 0xea, 0x58, 0xc2, 0x3c,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x4c, 0x70, 0x4b, 0x93, 0xd8, 0xa4, 0xb6, 0x59, 0x24, 0x77, 0x10, 0xb3, 0xc7, 0x34, 0x99, 0x6b,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x28, 0xbd, 0x03, 0xdb, 0xda, 0xea, 0x23, 0x19, 0x10, 0x56, 0x7e, 0xa4, 0x28, 0x04, 0x5a, 0x53,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0xb8, 0x30, 0x81, 0xb5, 0x30, 0x09, 0x06, 0x03, 0x55,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x02, 0x03, 0xa8, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x0b, 0x30, 0x09, 0x06, 0x07,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x04, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x04, 0x14, 0xea, 0xd4, 0x30, 0xd7, 0x7d, 0x3b, 0xc7, 0xb4, 0x83, 0x53, 0x2c, 0xa5, 0xb9, 0xd8,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x1a, 0x47, 0x6b, 0xb5, 0xe5, 0x9d, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x16, 0x80, 0x14, 0xea, 0xd4, 0x30, 0xd7, 0x7d, 0x3b, 0xc7, 0xb4, 0x83, 0x53, 0x2c, 0xa5, 0xb9,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xd8, 0x1a, 0x47, 0x6b, 0xb5, 0xe5, 0x9d, 0x30, 0x47, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x40,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x30, 0x3e, 0xa0, 0x3c, 0x06, 0x06, 0x2b, 0x06, 0x01, 0x05, 0x02, 0x02, 0xa0, 0x32, 0x30, 0x30,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xa0, 0x0b, 0x1b, 0x09, 0x53, 0x53, 0x53, 0x44, 0x2e, 0x54, 0x45, 0x53, 0x54, 0xa1, 0x21, 0x30,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x1f, 0xa0, 0x03, 0x02, 0x01, 0x01, 0xa1, 0x18, 0x30, 0x16, 0x1b, 0x04, 0x74, 0x65, 0x73, 0x74,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x1b, 0x05, 0x63, 0x6f, 0x6d, 0x70, 0x32, 0x1b, 0x07, 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x82, 0x01, 0x01, 0x00, 0x08, 0x64, 0x63, 0x89, 0x6d, 0x3d, 0x66, 0x77, 0xe3, 0xb6, 0x40, 0x54,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xd7, 0xe2, 0xc5, 0x99, 0xac, 0x98, 0x6e, 0xf8, 0xcd, 0x62, 0xa4, 0xf8, 0xd9, 0xaf, 0xdb, 0xef,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xb7, 0x10, 0x8e, 0x45, 0x42, 0x53, 0x5c, 0x3f, 0x6a, 0x8d, 0xa8, 0x8a, 0x6d, 0x76, 0x51, 0x1a,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xf4, 0x71, 0x54, 0x27, 0x27, 0xe2, 0x45, 0xe8, 0xa8, 0xd2, 0xa9, 0xcd, 0x62, 0x0d, 0xfc, 0x0d,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x28, 0x46, 0x9e, 0x4e, 0x5a, 0x57, 0x72, 0xb4, 0xf2, 0x35, 0x91, 0x57, 0x11, 0xae, 0x2b, 0x9c,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x6a, 0x80, 0x21, 0x8e, 0x4c, 0x19, 0x4a, 0x2d, 0xe0, 0xd2, 0xdf, 0x83, 0x9d, 0x65, 0x49, 0xd1,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x34, 0x34, 0x14, 0xa0, 0xbb, 0x1c, 0xa8, 0x12, 0xb0, 0xe3, 0x5e, 0x82, 0x36, 0x41, 0x4c, 0x87,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xd1, 0x1e, 0x1a, 0xe9, 0xff, 0x55, 0xef, 0xb5, 0x2d, 0x20, 0xc5, 0xa7, 0xe5, 0x5a, 0xf2, 0xfc,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xf7, 0xd2, 0x21, 0xc5, 0x32, 0xb4, 0x07, 0x8f, 0xc4, 0x94, 0x56, 0xa6, 0x21, 0x6a, 0xb6, 0x26,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x05, 0x48, 0x90, 0xe0, 0x6b, 0x22, 0x35, 0x00, 0x51, 0x2e, 0xd7, 0xe8, 0x3a, 0x56, 0xa8, 0x70,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x7d, 0x0f, 0x9a, 0x97, 0x5a, 0xb8, 0x7f, 0x33, 0xc1, 0xe0, 0x92, 0x0f, 0xb3, 0xfe, 0x36, 0xe6,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x8b, 0x97, 0x58, 0x42, 0x49, 0xcb, 0x74, 0xde, 0x19, 0x59, 0x90, 0xb6, 0x36, 0x38, 0x07, 0x48,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x5d, 0x5b, 0xab, 0x08, 0xf0, 0x69, 0x22, 0x42, 0x08, 0x29, 0xfe, 0x43, 0xab, 0x83, 0x73, 0x74,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x5a, 0x3f, 0x3b, 0x5d, 0x8e, 0xca, 0x6f, 0x2d, 0xad, 0xa1, 0x6e, 0x80, 0x80, 0xd2, 0xc8, 0x16,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0xb7, 0x67, 0x1a, 0x2d, 0x37, 0x8c, 0x20, 0x3b, 0x15, 0xef, 0xb2, 0x94, 0x86, 0x5c, 0xaf, 0xa2,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x61, 0x8b, 0xc7, 0xc1, 0xe4, 0xbe, 0x60, 0x5a, 0x86, 0x5c, 0x86, 0xba, 0x59, 0x97, 0x83, 0x1b,
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose0x79, 0x1c, 0x7c, 0x26};
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosevoid test_sss_cert_get_content(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_cert_content *content;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_cert_get_content(NULL, test_cert_der, sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret , 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->issuer_str);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_str, "CN=Certificate Authority,O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->subject_str);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_str, "CN=ipa-devel.ipa.devel,O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(content->key_usage, SSS_KU_DIGITAL_SIGNATURE
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose |SSS_KU_NON_REPUDIATION
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose |SSS_KU_KEY_ENCIPHERMENT
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose |SSS_KU_DATA_ENCIPHERMENT);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->extended_key_usage_oids);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->extended_key_usage_oids[0]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.1",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(content->extended_key_usage_oids), true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.2",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(content->extended_key_usage_oids), true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->extended_key_usage_oids[2]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(content->cert_der_size, sizeof(test_cert_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_memory_equal(content->cert_der, test_cert_der, sizeof(test_cert_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->issuer_rdn_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_rdn_list[0], "O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_rdn_list[1], "CN=Certificate Authority");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->issuer_rdn_list[2]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->subject_rdn_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[0], "O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[1], "CN=ipa-devel.ipa.devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->subject_rdn_list[2]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosevoid test_sss_cert_get_content_2(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_cert_content *content;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct san_list *i;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_cert_get_content(NULL, test_cert2_der, sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->issuer_str);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_str,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "CN=ad-AD-SERVER-CA,DC=ad,DC=devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->subject_str);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#if 0
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit BoseFIXME:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_str,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "E=test.user@email.domain,CN=t u,CN=Users,DC=ad,DC=devel,DC=ad,DC=devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose //"CN=t u/emailAddress=test.user@email.domain,DC=ad,DC=devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#endif
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(content->key_usage, SSS_KU_DIGITAL_SIGNATURE
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose |SSS_KU_KEY_ENCIPHERMENT);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->extended_key_usage_oids);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->extended_key_usage_oids[0]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.2",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(content->extended_key_usage_oids), true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.5.5.7.3.4",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(content->extended_key_usage_oids), true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose /* Can use Microsoft Encrypted File System OID */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(string_in_list("1.3.6.1.4.1.311.10.3.4",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose discard_const(content->extended_key_usage_oids), true));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->extended_key_usage_oids[3]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(content->cert_der_size, sizeof(test_cert2_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_memory_equal(content->cert_der, test_cert2_der,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->issuer_rdn_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_rdn_list[0], "DC=devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_rdn_list[1], "DC=ad");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->issuer_rdn_list[2], "CN=ad-AD-SERVER-CA");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->issuer_rdn_list[3]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->subject_rdn_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[0], "DC=devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[1], "DC=ad");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[2], "CN=Users");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[3], "CN=t u");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(content->subject_rdn_list[4],
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "E=test.user@email.domain");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(content->subject_rdn_list[5]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(content->san_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose DLIST_FOR_EACH(i, content->san_list) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose switch (i->san_opt) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose case SAN_RFC822_NAME:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(i->val, "test.user@email.domain");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(i->short_name, "test.user");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose break;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose case SAN_STRING_OTHER_NAME:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(i->other_name_oid, "1.3.6.1.4.1.311.20.2.3");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(i->bin_val_len, 14);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_memory_equal(i->bin_val, "\f\ftu1@ad.devel", 14);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose break;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose case SAN_NT:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose case SAN_PRINCIPAL:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(i->val, "tu1@ad.devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(i->short_name, "tu1");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose break;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose default:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_true(false);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(content);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_match_cert(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose size_t c;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct match_tests {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const char *rule;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int result;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose } match_tests[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature,nonRepudiation", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature,cRLSign", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth,OCSPSigning", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth,serverAuth", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {NULL, 0}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose };
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct match_tests match_tests_2[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>keyEncipherment", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature,keyEncipherment", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<KU>digitalSignature,keyEncipherment,cRLSign", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth,1.3.6.1.4.1.311.10.3.4", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<EKU>clientAuth,1.3.6.1.4.1.311.10.3.41", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:Principal>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:ntPrincipalName>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:pkinitSAN>tu1", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:Principal>^tu1@ad.devel$", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:rfc822Name>tu", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:rfc822Name>test.user", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:rfc822Name>test.user<SAN>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:||<SAN:rfc822Name>test.user<SAN>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:&&<SAN:rfc822Name>tu1<SAN>tu1", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:||<SAN:rfc822Name>tu1<SAN>tu1", 0},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:otherName>MTIz", ENOENT}, /* 123 */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:otherName>DAx0dTFAYWQuZGV2ZWw=", 0}, /* "\f\ftu1@ad.devel" */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:otherName>DAx0dTFAYWQuZGV2ZWx4", ENOENT}, /* "\f\ftu1@ad.develx" */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:otherName>dHUxQGFkLmRldmVs", 0}, /* "tu1@ad.devel" */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:1.3.6.1.4.1.311.20.2.3>test", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:1.3.6.1.4.1.311.20.2.3>tu1@ad", 0},
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Fails because the NT principal SAN starts with binary values */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {"KRB5:<SAN:1.3.6.1.4.1.311.20.2.3>^tu1@ad.devel$", ENOENT},
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose {NULL, 0}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose };
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose struct match_tests match_tests_3[] = {
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<KU>digitalSignature", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<KU>keyEncipherment", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<KU>keyAgreement", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<KU>digitalSignature,keyAgreement,keyEncipherment", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:Principal>test", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:ntPrincipal>test", ENOENT},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:Principal>comp2", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:Principal>another", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:Principal>test/comp2/another@SSSD.TEST", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:Principal>^test/comp2/another@SSSD.TEST$", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {"KRB5:<SAN:pkinitSAN>^test/comp2/another@SSSD.TEST$", 0},
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose {NULL, 0}
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose };
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, "KRB5:<ISSUER>xyz<SUBJECT>xyz",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_match_cert(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, ENOENT);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_match_cert(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (c = 0; match_tests[c].rule != NULL; c++) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, match_tests[c].rule, NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_match_cert(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, match_tests[c].result);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose for (c = 0; match_tests_2[c].rule != NULL; c++) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose print_error("Checking matching rule [%s]\n", match_tests_2[c].rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, match_tests_2[c].rule, NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_match_cert(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, match_tests_2[c].result);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose for (c = 0; match_tests_3[c].rule != NULL; c++) {
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose assert_int_equal(ret, EOK);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose assert_non_null(ctx);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose assert_null(ctx->prio_list);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose print_error("Checking matching rule [%s]\n", match_tests_3[c].rule);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose ret = sss_certmap_add_rule(ctx, 1, match_tests_3[c].rule, NULL, NULL);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose assert_int_equal(ret, EOK);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose ret = sss_certmap_match_cert(ctx, discard_const(test_cert3_der),
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose sizeof(test_cert3_der));
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose assert_int_equal(ret, match_tests_3[c].result);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose sss_certmap_free_ctx(ctx);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_add_mapping_rule(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, NULL, "FWEAWEF:fwefwe", NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, ESRCH);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, NULL, "LDAP:abc", NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule->list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_string,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("abc",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, NULL, "LDAP:abc{issuer_dn}", NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule->list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_string,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("abc",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_template,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("issuer_dn",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, NULL, "{issuer_dn}a:b{{c}}", NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule->list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_template,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("issuer_dn",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_string,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("a:b{c}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 1, NULL, "LDAP:{issuer_dn}{subject_dn}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx->prio_list->rule_list->parsed_mapping_rule->list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_template,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("issuer_dn",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(comp_template,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->type);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal("subject_dn",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ctx->prio_list->rule_list->parsed_mapping_rule->list->next->val);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose talloc_free(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#define TEST_CERT_BIN \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\82\\04\\09\\30\\82\\02\\f1\\a0\\03\\02\\01\\02\\02\\01\\09" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\0d\\06\\09\\2a\\86\\48\\86\\f7\\0d\\01\\01\\0b\\05\\00\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\34\\31\\12\\30\\10\\06\\03\\55\\04\\0a\\0c\\09\\49\\50\\41\\2e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\44\\45\\56\\45\\4c\\31\\1e\\30\\1c\\06\\03\\55\\04\\03\\0c\\15" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\43\\65\\72\\74\\69\\66\\69\\63\\61\\74\\65\\20\\41\\75\\74\\68" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6f\\72\\69\\74\\79\\30\\1e\\17\\0d\\31\\35\\30\\34\\32\\38\\31" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\32\\31\\31\\31\\5a\\17\\0d\\31\\37\\30\\34\\32\\38\\31\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\32\\31\\31\\31\\5a\\30\\32\\31\\12\\30\\10\\06\\03\\55\\04\\0a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0c\\09\\49\\50\\41\\2e\\44\\45\\56\\45\\4c\\31\\1c\\30\\1a\\06" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\03\\55\\04\\03\\0c\\13\\69\\70\\61\\2d\\64\\65\\76\\65\\6c\\2e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\69\\70\\61\\2e\\64\\65\\76\\65\\6c\\30\\82\\01\\22\\30\\0d\\06" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\09\\2a\\86\\48\\86\\f7\\0d\\01\\01\\01\\05\\00\\03\\82\\01\\0f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\00\\30\\82\\01\\0a\\02\\82\\01\\01\\00\\b2\\32\\92\\ab\\47\\b8" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0c\\13\\54\\4a\\1f\\1e\\29\\06\\ff\\d0\\50\\cb\\f7\\5f\\79\\91" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\65\\b1\\39\\01\\83\\6a\\ad\\9e\\77\\3b\\f3\\0d\\d7\\b9\\f6\\dc" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\9e\\4a\\49\\a7\\d0\\66\\72\\cc\\bf\\77\\d6\\de\\a9\\fe\\67\\96" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\cc\\49\\f1\\37\\23\\2e\\c4\\50\\f4\\eb\\ba\\62\\d4\\23\\4d\\f3" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\37\\38\\82\\ee\\3b\\3f\\2c\\d0\\80\\9b\\17\\aa\\9b\\eb\\a6\\dd" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\f6\\15\\ff\\06\\b2\\ce\\ff\\df\\8a\\9e\\95\\85\\49\\1f\\84\\fd" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\81\\26\\ce\\06\\32\\0d\\36\\ca\\7c\\15\\81\\68\\6b\\8f\\3e\\b3" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\a2\\fc\\ae\\af\\c2\\44\\58\\15\\95\\40\\fc\\56\\19\\91\\80\\ed" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\42\\11\\66\\04\\ef\\3c\\e0\\76\\33\\4b\\83\\fa\\7e\\b4\\47\\dc" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\fb\\ed\\46\\a5\\8d\\0a\\66\\87\\a5\\ef\\7b\\74\\62\\ac\\be\\73" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\36\\c9\\b4\\fe\\20\\c4\\81\\f3\\fe\\78\\19\\a8\\d0\\af\\7f\\81" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\72\\24\\61\\d9\\76\\93\\e3\\0b\\d2\\4f\\19\\17\\33\\57\\d4\\82" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\b0\\f1\\a8\\03\\f6\\01\\99\\a9\\b8\\8c\\83\\c9\\ba\\19\\87\\ea" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\d6\\3b\\06\\eb\\4c\\f7\\f1\\e5\\28\\a9\\10\\b6\\46\\de\\e1\\e1" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3f\\c1\\cc\\72\\be\\2a\\43\\c6\\f6\\d0\\b5\\a0\\c4\\24\\6e\\4f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\bd\\ec\\22\\8a\\07\\11\\3d\\f9\\d3\\15\\02\\03\\01\\00\\01\\a3" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\82\\01\\26\\30\\82\\01\\22\\30\\1f\\06\\03\\55\\1d\\23\\04\\18" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\16\\80\\14\\f2\\9d\\42\\4e\\0f\\c4\\48\\25\\58\\2f\\1c\\ce" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0f\\a1\\3f\\22\\c8\\55\\c8\\91\\30\\3b\\06\\08\\2b\\06\\01\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\05\\07\\01\\01\\04\\2f\\30\\2d\\30\\2b\\06\\08\\2b\\06\\01\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\05\\07\\30\\01\\86\\1f\\68\\74\\74\\70\\3a\\2f\\2f\\69\\70\\61" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2d\\63\\61\\2e\\69\\70\\61\\2e\\64\\65\\76\\65\\6c\\2f\\63\\61" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2f\\6f\\63\\73\\70\\30\\0e\\06\\03\\55\\1d\\0f\\01\\01\\ff\\04" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\04\\03\\02\\04\\f0\\30\\1d\\06\\03\\55\\1d\\25\\04\\16\\30\\14" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\08\\2b\\06\\01\\05\\05\\07\\03\\01\\06\\08\\2b\\06\\01\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\05\\07\\03\\02\\30\\74\\06\\03\\55\\1d\\1f\\04\\6d\\30\\6b\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\69\\a0\\31\\a0\\2f\\86\\2d\\68\\74\\74\\70\\3a\\2f\\2f\\69\\70" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\61\\2d\\63\\61\\2e\\69\\70\\61\\2e\\64\\65\\76\\65\\6c\\2f\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\70\\61\\2f\\63\\72\\6c\\2f\\4d\\61\\73\\74\\65\\72\\43\\52\\4c" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2e\\62\\69\\6e\\a2\\34\\a4\\32\\30\\30\\31\\0e\\30\\0c\\06\\03" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\55\\04\\0a\\0c\\05\\69\\70\\61\\63\\61\\31\\1e\\30\\1c\\06\\03" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\55\\04\\03\\0c\\15\\43\\65\\72\\74\\69\\66\\69\\63\\61\\74\\65" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\20\\41\\75\\74\\68\\6f\\72\\69\\74\\79\\30\\1d\\06\\03\\55\\1d" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0e\\04\\16\\04\\14\\2d\\2b\\3f\\cb\\f5\\b2\\ff\\32\\2c\\a8\\c2" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\1c\\dd\\bd\\8c\\80\\1e\\dd\\31\\82\\30\\0d\\06\\09\\2a\\86\\48" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\86\\f7\\0d\\01\\01\\0b\\05\\00\\03\\82\\01\\01\\00\\9a\\47\\2e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\50\\a7\\4d\\1d\\53\\0f\\c9\\71\\42\\0c\\e5\\da\\7d\\49\\64\\e7" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\ab\\c8\\df\\df\\02\\c1\\87\\d1\\5b\\de\\da\\6f\\2b\\e4\\f0\\be" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\ba\\09\\df\\02\\85\\0b\\8a\\e6\\9b\\06\\7d\\69\\38\\6c\\72\\ff" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\4c\\7b\\2a\\0d\\3f\\23\\2f\\16\\46\\ff\\05\\93\\b0\\ea\\24\\28" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\d7\\12\\a1\\57\\b8\\59\\19\\25\\f3\\43\\0a\\d3\\fd\\0f\\37\\8d" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\b8\\ca\\15\\e7\\48\\8a\\a0\\c7\\c7\\4b\\7f\\01\\3c\\58\\d7\\37" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\e5\\ff\\7d\\2b\\01\\ac\\0d\\9f\\51\\6a\\e5\\40\\24\\e6\\5e\\55" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0d\\f7\\b8\\2f\\42\\ac\\6d\\e5\\29\\6b\\c6\\0b\\a4\\bf\\19\\bd" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\39\\27\\ee\\fe\\c5\\b3\\db\\62\\d4\\be\\d2\\47\\ba\\96\\30\\5a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\fd\\62\\00\\b8\\27\\5d\\2f\\3a\\94\\0b\\95\\35\\85\\40\\2c\\bc" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\67\\df\\8a\\f9\\f1\\7b\\19\\96\\3e\\42\\48\\13\\23\\04\\95\\a9" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6b\\11\\33\\81\\47\\5a\\83\\72\\f6\\20\\fa\\8e\\41\\7b\\8f\\77" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\47\\7c\\c7\\5d\\46\\f4\\4f\\fd\\81\\0a\\ae\\39\\27\\b6\\6a\\26" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\63\\b1\\d3\\bf\\55\\83\\82\\9b\\36\\6c\\33\\64\\0f\\50\\c0\\55" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\94\\13\\c3\\85\\f4\\d5\\71\\65\\d0\\c0\\dd\\fc\\e6\\ec\\9c\\5b" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\f0\\11\\b5\\2c\\f3\\48\\c1\\36\\8c\\a2\\96\\48\\84"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#define TEST_CERT2_BIN \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\82\\06\\98\\30\\82\\05\\80\\a0\\03\\02\\01\\02\\02\\0a\\61" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\22\\88\\c2\\00\\00\\00\\00\\02\\a6\\30\\0d\\06\\09\\2a\\86\\48" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\86\\f7\\0d\\01\\01\\05\\05\\00\\30\\45\\31\\15\\30\\13\\06\\0a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\09\\92\\26\\89\\93\\f2\\2c\\64\\01\\19\\16\\05\\64\\65\\76\\65" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6c\\31\\12\\30\\10\\06\\0a\\09\\92\\26\\89\\93\\f2\\2c\\64\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\19\\16\\02\\61\\64\\31\\18\\30\\16\\06\\03\\55\\04\\03\\13\\0f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\61\\64\\2d\\41\\44\\2d\\53\\45\\52\\56\\45\\52\\2d\\43\\41\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\1e\\17\\0d\\31\\36\\31\\31\\31\\31\\31\\33\\35\\31\\31\\31\\5a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\17\\0d\\31\\37\\31\\31\\31\\31\\31\\33\\35\\31\\31\\31\\5a\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\70\\31\\15\\30\\13\\06\\0a\\09\\92\\26\\89\\93\\f2\\2c\\64\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\19\\16\\05\\64\\65\\76\\65\\6c\\31\\12\\30\\10\\06\\0a\\09\\92" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\26\\89\\93\\f2\\2c\\64\\01\\19\\16\\02\\61\\64\\31\\0e\\30\\0c" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\03\\55\\04\\03\\13\\05\\55\\73\\65\\72\\73\\31\\0c\\30\\0a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\03\\55\\04\\03\\13\\03\\74\\20\\75\\31\\25\\30\\23\\06\\09" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2a\\86\\48\\86\\f7\\0d\\01\\09\\01\\16\\16\\74\\65\\73\\74\\2e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\75\\73\\65\\72\\40\\65\\6d\\61\\69\\6c\\2e\\64\\6f\\6d\\61\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6e\\30\\82\\01\\22\\30\\0d\\06\\09\\2a\\86\\48\\86\\f7\\0d\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\01\\05\\00\\03\\82\\01\\0f\\00\\30\\82\\01\\0a\\02\\82\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\00\\9c\\cf\\36\\99\\de\\63\\74\\2b\\77\\25\\9e\\24\\d9\\77" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\4b\\5f\\98\\c0\\8c\\d7\\20\\91\\c0\\1c\\e8\\37\\45\\bf\\3c\\d9" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\33\\bd\\e9\\de\\c9\\5d\\d4\\cd\\06\\0a\\0d\\d4\\f1\\7c\\74\\5b" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\29\\d5\\66\\9c\\2c\\9f\\6b\\1a\\0f\\0d\\e6\\6c\\62\\a5\\41\\4f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\c3\\a4\\88\\27\\11\\5d\\b7\\b1\\fb\\f8\\8d\\ee\\43\\8d\\93\\b5" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\8c\\b4\\34\\06\\f5\\e9\\2f\\5a\\26\\68\\d7\\43\\60\\82\\5e\\22" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\a7\\c6\\34\\40\\19\\a5\\8e\\f0\\58\\9f\\16\\2d\\43\\3f\\0c\\da" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\e2\\23\\f6\\09\\2a\\5e\\bd\\84\\27\\c8\\ab\\d5\\70\\f8\\3d\\9c" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\14\\c2\\c2\\a2\\77\\e8\\44\\73\\10\\01\\34\\40\\1f\\c6\\2f\\a0" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\70\\ee\\2f\\d5\\4b\\be\\4c\\c7\\45\\f7\\ac\\9c\\c3\\68\\5b\\1d" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\5a\\4b\\77\\65\\76\\e4\\b3\\92\\f4\\84\\0a\\9e\\6a\\9c\\c9\\53" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\42\\9f\\6d\\fe\\f9\\f5\\f2\\9a\\15\\50\\47\\ef\\f4\\06\\59\\c8" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\50\\48\\4b\\46\\95\\68\\25\\c5\\bd\\4f\\65\\34\\00\\fc\\31\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\f8\\3e\\e0\\20\\83\\41\\27\\0b\\5c\\46\\98\\14\\f0\\07\\de\\02" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\17\\b1\\d2\\9c\\be\\1c\\0d\\56\\22\\1b\\02\\fe\\da\\69\\b9\\ef" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\91\\37\\39\\7f\\24\\da\\c4\\81\\5e\\82\\31\\2f\\98\\1d\\f7\\73" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\5b\\23\\02\\03\\01\\00\\01\\a3\\82\\03\\5d\\30\\82\\03\\59\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3d\\06\\09\\2b\\06\\01\\04\\01\\82\\37\\15\\07\\04\\30\\30\\2e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\26\\2b\\06\\01\\04\\01\\82\\37\\15\\08\\87\\85\\a1\\23\\84" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\c8\\b2\\26\\83\\9d\\9d\\21\\82\\d4\\a6\\1b\\86\\a3\\ba\\37\\81" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\10\\85\\89\\d5\\02\\d6\\8f\\24\\02\\01\\64\\02\\01\\02\\30\\29" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\03\\55\\1d\\25\\04\\22\\30\\20\\06\\08\\2b\\06\\01\\05\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\07\\03\\02\\06\\08\\2b\\06\\01\\05\\05\\07\\03\\04\\06\\0a\\2b" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\01\\04\\01\\82\\37\\0a\\03\\04\\30\\0e\\06\\03\\55\\1d\\0f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\01\\ff\\04\\04\\03\\02\\05\\a0\\30\\35\\06\\09\\2b\\06\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\04\\01\\82\\37\\15\\0a\\04\\28\\30\\26\\30\\0a\\06\\08\\2b\\06" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\05\\05\\07\\03\\02\\30\\0a\\06\\08\\2b\\06\\01\\05\\05\\07" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\03\\04\\30\\0c\\06\\0a\\2b\\06\\01\\04\\01\\82\\37\\0a\\03\\04" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\81\\94\\06\\09\\2a\\86\\48\\86\\f7\\0d\\01\\09\\0f\\04\\81" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\86\\30\\81\\83\\30\\0b\\06\\09\\60\\86\\48\\01\\65\\03\\04\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2a\\30\\0b\\06\\09\\60\\86\\48\\01\\65\\03\\04\\01\\2d\\30\\0b" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\09\\60\\86\\48\\01\\65\\03\\04\\01\\16\\30\\0b\\06\\09\\60" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\86\\48\\01\\65\\03\\04\\01\\19\\30\\0b\\06\\09\\60\\86\\48\\01" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\65\\03\\04\\01\\02\\30\\0b\\06\\09\\60\\86\\48\\01\\65\\03\\04" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\05\\30\\0a\\06\\08\\2a\\86\\48\\86\\f7\\0d\\03\\07\\30\\07" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\06\\05\\2b\\0e\\03\\02\\07\\30\\0e\\06\\08\\2a\\86\\48\\86\\f7" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0d\\03\\02\\02\\02\\00\\80\\30\\0e\\06\\08\\2a\\86\\48\\86\\f7" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\0d\\03\\04\\02\\02\\02\\00\\30\\1d\\06\\03\\55\\1d\\0e\\04\\16" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\04\\14\\49\\ac\\ad\\e0\\65\\30\\c4\\ce\\a0\\09\\03\\5b\\ad\\4a" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\7b\\49\\5e\\c9\\6c\\b4\\30\\1f\\06\\03\\55\\1d\\23\\04\\18\\30" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\16\\80\\14\\62\\50\\b6\\8d\\a1\\e6\\2d\\91\\bf\\b0\\54\\4d\\8f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\a8\\ca\\10\\ae\\b8\\dd\\54\\30\\81\\cc\\06\\03\\55\\1d\\1f\\04" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\81\\c4\\30\\81\\c1\\30\\81\\be\\a0\\81\\bb\\a0\\81\\b8\\86\\81" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\b5\\6c\\64\\61\\70\\3a\\2f\\2f\\2f\\43\\4e\\3d\\61\\64\\2d\\41" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\44\\2d\\53\\45\\52\\56\\45\\52\\2d\\43\\41\\2c\\43\\4e\\3d\\61" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\64\\2d\\73\\65\\72\\76\\65\\72\\2c\\43\\4e\\3d\\43\\44\\50\\2c" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\43\\4e\\3d\\50\\75\\62\\6c\\69\\63\\25\\32\\30\\4b\\65\\79\\25" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\32\\30\\53\\65\\72\\76\\69\\63\\65\\73\\2c\\43\\4e\\3d\\53\\65" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\72\\76\\69\\63\\65\\73\\2c\\43\\4e\\3d\\43\\6f\\6e\\66\\69\\67" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\75\\72\\61\\74\\69\\6f\\6e\\2c\\44\\43\\3d\\61\\64\\2c\\44\\43" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3d\\64\\65\\76\\65\\6c\\3f\\63\\65\\72\\74\\69\\66\\69\\63\\61" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\74\\65\\52\\65\\76\\6f\\63\\61\\74\\69\\6f\\6e\\4c\\69\\73\\74" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3f\\62\\61\\73\\65\\3f\\6f\\62\\6a\\65\\63\\74\\43\\6c\\61\\73" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\73\\3d\\63\\52\\4c\\44\\69\\73\\74\\72\\69\\62\\75\\74\\69\\6f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6e\\50\\6f\\69\\6e\\74\\30\\81\\be\\06\\08\\2b\\06\\01\\05\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\07\\01\\01\\04\\81\\b1\\30\\81\\ae\\30\\81\\ab\\06\\08\\2b\\06" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\01\\05\\05\\07\\30\\02\\86\\81\\9e\\6c\\64\\61\\70\\3a\\2f\\2f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2f\\43\\4e\\3d\\61\\64\\2d\\41\\44\\2d\\53\\45\\52\\56\\45\\52" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2d\\43\\41\\2c\\43\\4e\\3d\\41\\49\\41\\2c\\43\\4e\\3d\\50\\75" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\62\\6c\\69\\63\\25\\32\\30\\4b\\65\\79\\25\\32\\30\\53\\65\\72" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\76\\69\\63\\65\\73\\2c\\43\\4e\\3d\\53\\65\\72\\76\\69\\63\\65" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\73\\2c\\43\\4e\\3d\\43\\6f\\6e\\66\\69\\67\\75\\72\\61\\74\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6f\\6e\\2c\\44\\43\\3d\\61\\64\\2c\\44\\43\\3d\\64\\65\\76\\65" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6c\\3f\\63\\41\\43\\65\\72\\74\\69\\66\\69\\63\\61\\74\\65\\3f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\62\\61\\73\\65\\3f\\6f\\62\\6a\\65\\63\\74\\43\\6c\\61\\73\\73" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3d\\63\\65\\72\\74\\69\\66\\69\\63\\61\\74\\69\\6f\\6e\\41\\75" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\74\\68\\6f\\72\\69\\74\\79\\30\\3f\\06\\03\\55\\1d\\11\\04\\38" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\30\\36\\a0\\1c\\06\\0a\\2b\\06\\01\\04\\01\\82\\37\\14\\02\\03" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\a0\\0e\\0c\\0c\\74\\75\\31\\40\\61\\64\\2e\\64\\65\\76\\65\\6c" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\81\\16\\74\\65\\73\\74\\2e\\75\\73\\65\\72\\40\\65\\6d\\61\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\6c\\2e\\64\\6f\\6d\\61\\69\\6e\\30\\0d\\06\\09\\2a\\86\\48\\86" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\f7\\0d\\01\\01\\05\\05\\00\\03\\82\\01\\01\\00\\41\\45\\0a\\6d" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\bb\\7f\\5c\\07\\0c\\c9\\b0\\39\\55\\6d\\7c\\b5\\02\\cd\\e8\\b2" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\e5\\02\\94\\77\\60\\db\\d1\\af\\1d\\db\\44\\5f\\ce\\83\\db\\80" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\2e\\e2\\b2\\08\\25\\82\\14\\cb\\48\\95\\20\\13\\6c\\a9\\aa\\f8" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\31\\56\\ed\\c0\\3b\\d4\\ae\\2e\\e3\\8f\\05\\fc\\ab\\5f\\2a\\69" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\23\\bc\\b8\\8c\\ec\\2d\\a9\\0b\\86\\95\\73\\73\\db\\17\\ce\\c6" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\ae\\c5\\b4\\c1\\25\\87\\3b\\67\\43\\9e\\87\\5a\\e6\\b9\\a0\\28" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\12\\3d\\a8\\2e\\d7\\5e\\ef\\65\\2d\\e6\\a5\\67\\84\\ac\\fd\\31" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\c1\\78\\d8\\72\\51\\a2\\88\\55\\0f\\97\\47\\93\\07\\ea\\8a\\53" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\27\\4e\\34\\54\\34\\1f\\a0\\6a\\03\\44\\fb\\23\\61\\8e\\87\\8e" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\3c\\d0\\8f\\ae\\e4\\cf\\ee\\65\\a8\\ba\\96\\68\\08\\1c\\60\\e2" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\4e\\11\\a3\\74\\b8\\a5\\4e\\ea\\6a\\82\\4c\\c2\\4d\\63\\8e\\9f" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\7c\\2f\\a8\\c0\\62\\f8\\f7\\d9\\25\\c4\\91\\ab\\4d\\6a\\44\\af" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\75\\93\\53\\03\\a4\\99\\c8\\cd\\91\\89\\60\\75\\30\\99\\76\\05" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\5a\\a0\\03\\a7\\a1\\2c\\03\\04\\8f\\d4\\5a\\31\\52\\28\\5a\\e6" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\a2\\d3\\43\\21\\5b\\dc\\a2\\1d\\55\\a9\\48\\c5\\c4\\aa\\f3\\8b" \
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "\\e6\\3e\\75\\96\\e4\\3e\\64\\af\\e8\\a7\\6a\\b6"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bosestatic void test_sss_certmap_get_search_filter(void **state)
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int ret;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct sss_certmap_ctx *ctx;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose char *filter;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose char **domains;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const char *dom_list[] = {"test.dom", NULL};
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 100,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule100=<I>{issuer_dn}<S>{subject_dn}", NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule100=<I>CN=Certificate Authority,O=IPA.DEVEL"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>CN=ipa-devel.ipa.devel,O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 99,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule99=<I>{issuer_dn}<S>{subject_dn}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose dom_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule99=<I>CN=Certificate Authority,O=IPA.DEVEL"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>CN=ipa-devel.ipa.devel,O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(domains[0], "test.dom");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains[1]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 98,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule98=userCertificate;binary={cert!bin}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose dom_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule98=userCertificate;binary=" TEST_CERT_BIN);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(domains[0], "test.dom");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains[1]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 97,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule97=<I>{issuer_dn!nss_x500}<S>{subject_dn}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose dom_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule97=<I>O=IPA.DEVEL,CN=Certificate Authority"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>CN=ipa-devel.ipa.devel,O=IPA.DEVEL");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(domains[0], "test.dom");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains[1]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 96,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule96=<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose dom_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule96=<I>O=IPA.DEVEL,CN=Certificate Authority"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>O=IPA.DEVEL,CN=ipa-devel.ipa.devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(domains[0], "test.dom");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains[1]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 95,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "(userCertificate;binary=" TEST_CERT_BIN ")");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 94,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "KRB5:<ISSUER>CN=Certificate Authority,O=IPA.DEVEL",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule94=<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose dom_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule94=<I>O=IPA.DEVEL,CN=Certificate Authority"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>O=IPA.DEVEL,CN=ipa-devel.ipa.devel");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(domains[0], "test.dom");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains[1]);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 89, NULL,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "(rule89={subject_nt_principal})",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "(rule89=tu1@ad.devel)");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 88, NULL,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "(rule88={subject_nt_principal.short_name})",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "(rule88=tu1)");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 87, NULL,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule87=<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule87=<I>DC=devel,DC=ad,CN=ad-AD-SERVER-CA"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>DC=devel,DC=ad,CN=Users,CN=t u,E=test.user@email.domain");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_add_rule(ctx, 86, NULL,
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "LDAP:rule86=<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "rule86=<I>DC=devel,DC=ad,CN=ad-AD-SERVER-CA"
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose "<S>DC=devel,DC=ad,CN=Users,CN=t u,E=test.user@email.domain");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose /* check defaults when no rules are added yet */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_init(NULL, ext_debug, NULL, &ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, EOK);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(ctx->prio_list);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose ret = sss_certmap_get_search_filter(ctx, discard_const(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose sizeof(test_cert2_der),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose &filter, &domains);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_int_equal(ret, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_non_null(filter);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_string_equal(filter, "(userCertificate;binary=" TEST_CERT2_BIN")");
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose assert_null(domains);
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose sss_certmap_free_ctx(ctx);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Boseint main(int argc, const char *argv[])
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose{
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int rv;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose poptContext pc;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose int opt;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose struct poptOption long_options[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose POPT_AUTOHELP
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose SSSD_DEBUG_OPTS
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose POPT_TABLEEND
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose };
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose const struct CMUnitTest tests[] = {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_init),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_add_rule),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_add_matching_rule),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_check_ad_attr_name),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_cert_get_content),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_cert_get_content_2),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_match_cert),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_add_mapping_rule),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose cmocka_unit_test(test_sss_certmap_get_search_filter),
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose };
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose debug_level = SSSDBG_INVALID;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose pc = poptGetContext(argv[0], argc, argv, long_options, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose while((opt = poptGetNextOpt(pc)) != -1) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose switch(opt) {
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose default:
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose fprintf(stderr, "\nInvalid option %s: %s\n\n",
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose poptBadOption(pc, 0), poptStrerror(opt));
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose poptPrintUsage(pc, stderr, 0);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose return 1;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose }
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose poptFreeContext(pc);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose DEBUG_CLI_INIT(debug_level);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#ifdef HAVE_NSS
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose nspr_nss_init();
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#endif
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose tests_set_cwd();
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose rv = cmocka_run_group_tests(tests, NULL, NULL);
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#ifdef HAVE_NSS
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Cleanup NSS and NSPR to make Valgrind happy. */
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose nspr_nss_cleanup();
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose#endif
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose#ifdef HAVE_LIBCRYPTO
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz CRYPTO_cleanup_all_ex_data(); /* to make Valgrind happy */
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose#endif
a20fb9cbd5f42a6ca895aea1b84347fdfea34b89Sumit Bose
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose return rv;
db36dca3d45e6eefbb30042ee65876566f1a6014Sumit Bose}