Blame tests/test_attmap.c

Packit 6bd9ab
/*
Packit 6bd9ab
   test_cfg.c - simple test for the cfg module
Packit 6bd9ab
   This file is part of the nss-pam-ldapd library.
Packit 6bd9ab
Packit 6bd9ab
   Copyright (C) 2014 Arthur de Jong
Packit 6bd9ab
Packit 6bd9ab
   This library is free software; you can redistribute it and/or
Packit 6bd9ab
   modify it under the terms of the GNU Lesser General Public
Packit 6bd9ab
   License as published by the Free Software Foundation; either
Packit 6bd9ab
   version 2.1 of the License, or (at your option) any later version.
Packit 6bd9ab
Packit 6bd9ab
   This library is distributed in the hope that it will be useful,
Packit 6bd9ab
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6bd9ab
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6bd9ab
   Lesser General Public License for more details.
Packit 6bd9ab
Packit 6bd9ab
   You should have received a copy of the GNU Lesser General Public
Packit 6bd9ab
   License along with this library; if not, write to the Free Software
Packit 6bd9ab
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 6bd9ab
   02110-1301 USA
Packit 6bd9ab
*/
Packit 6bd9ab
Packit 6bd9ab
#include "config.h"
Packit 6bd9ab
Packit 6bd9ab
#include <stdio.h>
Packit 6bd9ab
#include <string.h>
Packit 6bd9ab
#include <assert.h>
Packit 6bd9ab
Packit 6bd9ab
#include "common.h"
Packit 6bd9ab
Packit 6bd9ab
#include "nslcd/attmap.h"
Packit 6bd9ab
Packit 6bd9ab
static void test_member_map(void)
Packit 6bd9ab
{
Packit 6bd9ab
  const char **var;
Packit 6bd9ab
  const char *res;
Packit 6bd9ab
  var = attmap_get_var(LM_GROUP, "member");
Packit 6bd9ab
  assert(var != NULL);
Packit 6bd9ab
  /* expected mapping */
Packit 6bd9ab
  res = attmap_set_mapping(var, "uniqueMember");
Packit 6bd9ab
  assert(res != NULL);
Packit 6bd9ab
  assertstreq(res, "uniqueMember");
Packit 6bd9ab
  /* no support for expressions */
Packit 6bd9ab
  res = attmap_set_mapping(var, "\"$fred\"");
Packit 6bd9ab
  assert(res == NULL);
Packit 6bd9ab
  /* but support empty string */
Packit 6bd9ab
  res = attmap_set_mapping(var, "\"\"");
Packit 6bd9ab
  assert(res != NULL);
Packit 6bd9ab
  assertstreq(res, "\"\"");
Packit 6bd9ab
}
Packit 6bd9ab
Packit 6bd9ab
int main(int UNUSED(argc), char UNUSED(*argv[]))
Packit 6bd9ab
{
Packit 6bd9ab
  test_member_map();
Packit 6bd9ab
  return EXIT_SUCCESS;
Packit 6bd9ab
}