"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/test_expr.c" between
nss-pam-ldapd-0.9.11.tar.gz and nss-pam-ldapd-0.9.12.tar.gz

About: nss-pam-ldapd is a Name Service Switch (NSS) module and Pluggable Authentication Module (PAM) that allows your LDAP server to provide user account, group, host name, alias, netgroup, and basically any other information that you would normally get from /etc flat files or NIS. It also allows you to do authentication to an LDAP server.

test_expr.c  (nss-pam-ldapd-0.9.11):test_expr.c  (nss-pam-ldapd-0.9.12)
/* /*
test_expr.c - simple tests for the expr module test_expr.c - simple tests for the expr module
This file is part of the nss-pam-ldapd library. This file is part of the nss-pam-ldapd library.
Copyright (C) 2009, 2011, 2012, 2013 Arthur de Jong Copyright (C) 2009-2021 Arthur de Jong
Copyright (c) 2016 Giovanni Mascellani Copyright (c) 2016 Giovanni Mascellani
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
skipping to change at line 40 skipping to change at line 40
#include "common.h" #include "common.h"
/* we include expr.c because we want to test the static methods */ /* we include expr.c because we want to test the static methods */
#include "common/expr.c" #include "common/expr.c"
static void test_parse_name(void) static void test_parse_name(void)
{ {
char buffer[20]; char buffer[20];
int i; int i;
i = 0; i = 0;
assert(parse_name("fooBar", &i, buffer, sizeof(buffer)) != NULL); assert(parse_name("fooBar", &i, buffer, sizeof(buffer), 0) != NULL);
assert(i == 6); assert(i == 6);
i = 0; i = 0;
assert(parse_name("nameThatWillNotFitInBuffer", &i, buffer, sizeof(buffer)) == NULL); assert(parse_name("nameThatWillNotFitInBuffer", &i, buffer, sizeof(buffer), 0) == NULL);
i = 0; i = 0;
assert(parse_name("foo Bar", &i, buffer, sizeof(buffer)) != NULL); assert(parse_name("foo Bar", &i, buffer, sizeof(buffer), 0) != NULL);
assert(i == 3); assert(i == 3);
assertstreq(buffer, "foo"); assertstreq(buffer, "foo");
i = 0;
assert(parse_name("foo-Bar", &i, buffer, sizeof(buffer), 0) != NULL);
assert(i == 3);
assertstreq(buffer, "foo");
i = 0;
assert(parse_name("foo-Bar", &i, buffer, sizeof(buffer), 1) != NULL);
assert(i == 7);
assertstreq(buffer, "foo-Bar");
} }
static const char *expanderfn(const char *name, void UNUSED(*expander_attr)) static const char *expanderfn(const char *name, void UNUSED(*expander_attr))
{ {
if (strcmp(name, "empty") == 0) if (strcmp(name, "empty") == 0)
return ""; return "";
if (strcmp(name, "null") == 0) if (strcmp(name, "null") == 0)
return NULL; return NULL;
if (strcmp(name, "userPassword") == 0) if (strcmp(name, "userPassword") == 0)
return "{crypt}HASH"; return "{crypt}HASH";
skipping to change at line 73 skipping to change at line 81
{ {
char buffer[1024]; char buffer[1024];
assert(expr_parse("$test1", buffer, sizeof(buffer), expanderfn, NULL) != NULL) ; assert(expr_parse("$test1", buffer, sizeof(buffer), expanderfn, NULL) != NULL) ;
assertstreq(buffer, "foobar"); assertstreq(buffer, "foobar");
assert(expr_parse("\\$test1", buffer, sizeof(buffer), expanderfn, NULL) != NUL L); assert(expr_parse("\\$test1", buffer, sizeof(buffer), expanderfn, NULL) != NUL L);
assertstreq(buffer, "$test1"); assertstreq(buffer, "$test1");
assert(expr_parse("$empty", buffer, sizeof(buffer), expanderfn, NULL) != NULL) ; assert(expr_parse("$empty", buffer, sizeof(buffer), expanderfn, NULL) != NULL) ;
assertstreq(buffer, ""); assertstreq(buffer, "");
assert(expr_parse("$foo1$empty-$foo2", buffer, sizeof(buffer), expanderfn, NUL L) != NULL); assert(expr_parse("$foo1$empty-$foo2", buffer, sizeof(buffer), expanderfn, NUL L) != NULL);
assertstreq(buffer, "foobar-foobar"); assertstreq(buffer, "foobar-foobar");
assert(expr_parse("$test-var", buffer, sizeof(buffer), expanderfn, NULL) != NU
LL);
assertstreq(buffer, "foobar-var");
assert(expr_parse("${test-var}", buffer, sizeof(buffer), expanderfn, NULL) !=
NULL);
assertstreq(buffer, "foobar");
assert(expr_parse("$foo1+$null+$foo2", buffer, sizeof(buffer), expanderfn, NUL L) != NULL); assert(expr_parse("$foo1+$null+$foo2", buffer, sizeof(buffer), expanderfn, NUL L) != NULL);
assertstreq(buffer, "foobar++foobar"); assertstreq(buffer, "foobar++foobar");
assert(expr_parse("${test1}\\$", buffer, sizeof(buffer), expanderfn, NULL) != NULL); assert(expr_parse("${test1}\\$", buffer, sizeof(buffer), expanderfn, NULL) != NULL);
assertstreq(buffer, "foobar$"); assertstreq(buffer, "foobar$");
assert(expr_parse("${test1:-default}", buffer, sizeof(buffer), expanderfn, NUL L) != NULL); assert(expr_parse("${test1:-default}", buffer, sizeof(buffer), expanderfn, NUL L) != NULL);
assertstreq(buffer, "foobar"); assertstreq(buffer, "foobar");
assert(expr_parse("${empty:-default}", buffer, sizeof(buffer), expanderfn, NUL L) != NULL); assert(expr_parse("${empty:-default}", buffer, sizeof(buffer), expanderfn, NUL L) != NULL);
assertstreq(buffer, "default"); assertstreq(buffer, "default");
assert(expr_parse("${test1:+setset}", buffer, sizeof(buffer), expanderfn, NULL ) != NULL); assert(expr_parse("${test1:+setset}", buffer, sizeof(buffer), expanderfn, NULL ) != NULL);
assertstreq(buffer, "setset"); assertstreq(buffer, "setset");
 End of changes. 6 change blocks. 
4 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)