1#!/bin/sh 2src=`pwd` 3tmp=$src/tests-tmp 4rm -rf $tmp 5mkdir -p $tmp 6PATH="$src:/bin:/usr/bin:/usr/local/bin" 7tests_failed=0 8tests_count=0 9_UID=`id -u` 10_GID=`id -g` 11 12usage() { 13 echo "usage: sh $0 [-v]" 14} 15 16vecho() { :; } 17while getopts v flag 18do 19 case $flag in 20 v) vecho() { echo "$*"; } ;; 21 *) usage; exit 1 ;; 22 esac 23done 24printf='env printf' 25 26home=$tmp/home 27mkdir $home 28 29CVM_PWFILE_PATH=$tmp/pwfile 30export CVM_PWFILE_PATH 31make_pwfile() 32{ 33 ( 34 echo 'pwfuser:testpass:123:456:Gecos,xyz:/home/ftp:/bin/false' 35 echo 'cryptuser:tpzv1IkcX9.fE:234:567:Crypt:/home/crypt:/bin/true' 36 ) >$CVM_PWFILE_PATH 37} 38 39CVM_SQLITE_DB=$tmp/db.sqlite 40CVM_SQLITE_QUERY='SELECT password, username, userid, groupid, directory, realname, shell, groupname, domain, sys_username, sys_directory, mailbox_path FROM accounts WHERE username=$account AND domain=$domain' 41CVM_SQLITE_PWCMP=plain 42export CVM_SQLITE_DB CVM_SQLITE_QUERY CVM_SQLITE_PWCMP 43make_sqlite() 44{ 45 sqlite3 $CVM_SQLITE_DB <<EOF 46CREATE TABLE accounts ( 47 username TEXT NOT NULL, 48 domain TEXT NOT NULL, 49 password TEXT NOT NULL, 50 userid TEXT NOT NULL, 51 groupid TEXT NOT NULL, 52 realname TEXT, 53 directory TEXT NOT NULL, 54 shell TEXT, 55 groupname TEXT, 56 sys_username TEXT, 57 sys_directory TEXT, 58 mailbox_path TEXT, 59 UNIQUE (username, domain) 60); 61INSERT INTO accounts VALUES ('sluser','','testpass',123,456,'realname','/home/sluser','/bin/false',NULL,NULL,NULL,NULL); 62INSERT INTO accounts VALUES ('sluser','domain','pass2',234,567,'sluser2','/home/sluser2','/bin/true',NULL,NULL,NULL,NULL); 63EOF 64} 65 66for base in pwfile qmail vmailmgr; do 67 68cat <<EOF >$tmp/cvm-$base-lookup 69#!/bin/sh 70CVM_LOOKUP_SECRET=secret export CVM_LOOKUP_SECRET 71exec $src/cvm-$base 72EOF 73 74cat <<EOF >$tmp/cvm-$base-nosecret 75#!/bin/bash 76unset CVM_LOOKUP_SECRET 77exec $src/cvm-$base 78EOF 79 80done 81 82chmod +x $tmp/cvm-* 83 84QMAIL_ROOT=$tmp 85export QMAIL_ROOT 86 87mkdir $tmp/users 88( 89 uid=`id -u` 90 gid=`id -g` 91 hlen=`echo $home $uid $gid | wc -c` 92 tlen=`echo $tmp $uid $gid | wc -c` 93 $printf "+6,%d:!user\0->user\000$uid\000$gid\000$home\0\0\n" $(($hlen+6)) 94 $printf "+6,%d:!user-->user\000$uid\000$gid\000$home\0-\0\n" $(($hlen+7)) 95 $printf "+7,%d:!alias\0->alias\000$uid\000$gid\000$tmp/alias\0\0\n" $(($tlen+13)) 96 $printf "+7,%d:!alias-->alias\000$uid\000$gid\000$tmp/alias\0-\0\n" $(($tlen+14)) 97 $printf "+1,%d:!->alias\000$uid\000$gid\000$tmp/alias\0-\0\n" $(($tlen+14)) 98 echo 99) | cdbmake $tmp/users/cdb $tmp/users/tmp 100 101mkdir $tmp/control 102echo local.dom >$tmp/control/locals 103echo test.tld:user >$tmp/control/virtualdomains 104echo noathost:user >>$tmp/control/virtualdomains 105echo noathost >$tmp/control/envnoathost 106mkdir $tmp/alias 107echo \# >$home/.qmail-wild-default 108echo \# >$home/.qmail-addr 109echo \# >$home/.qmail-dot:addr 110echo \# >$tmp/alias/.qmail-alias 111echo \# >$tmp/alias/.qmail-awild-default 112echo \# >$tmp/alias/.qmail-adot:addr 113 114( 115 $printf '+4,69:virt->\x2\x8\x1\0$1$aSoIrl/J$TmAwoxKzrPJ0IaW5UvX4A0\0./virt\0\0\0-\0-\0-\0-\0001016731358\0-\0\n' 116 echo 117) | cdbmake $home/passwd.cdb $home/passwd.tmp 118 119sasltest() { 120 make_pwfile 121 env \ 122 CVM_SASL_PLAIN=$src/cvm-pwfile \ 123 PROTO=TCP \ 124 TCPLOCALHOST=localhost \ 125 $src/sasl-auth-test "$@" 126 rm -f $CVM_PWFILE_PATH 127} 128 129 130run_compare_test() { 131 local name=$1 132 shift 133 sed -e "s:@SOURCE@:$src:g" -e "s:@TMPDIR@:$tmp:g" -e "s:@UID@:$_UID:" -e "s:@GID@:$_GID:" >$tmp/expected 134 ( runtest "$@" 2>&1 ) 2>&1 >$tmp/actual-raw 135 cat -v $tmp/actual-raw >$tmp/actual 136 if ! cmp $tmp/expected $tmp/actual >/dev/null 2>&1 137 then 138 echo "Test $name $* failed:" 139 ( cd $tmp; diff -U 9999 expected actual | tail -n +3; echo; ) 140 tests_failed=$(($tests_failed+1)) 141 fi 142 rm -f $tmp/expected $tmp/actual 143 tests_count=$(($tests_count+1)) 144} 145 146##### Test tests/sqlite ##### 147 148runtest() { 149make_sqlite 150 151# Can it look up the right user 152$src/cvm-testclient $src/cvm-sqlite sluser '' testpass 153 154echo 155# Does it check the password 156$src/cvm-testclient $src/cvm-sqlite sluser '' testpasx 157 158echo 159# Does it look up the domain 160$src/cvm-testclient $src/cvm-sqlite sluser domain pass2 161 162rm $CVM_SQLITE_DB 163} 164vecho "Running test tests/sqlite " 165run_compare_test tests/sqlite <<END_OF_TEST_RESULTS 166user name: sluser 167user ID: 123 168group ID: 456 169real name: realname 170directory: /home/sluser 171shell: /bin/false 172group name: (null) 173system user name: (null) 174system directory: (null) 175domain: 176mailbox path: (null) 177 178cvm-testclient: Authentication failed, error #100 (Credentials rejected) 179 180user name: sluser 181user ID: 234 182group ID: 567 183real name: sluser2 184directory: /home/sluser2 185shell: /bin/true 186group name: (null) 187system user name: (null) 188system directory: (null) 189domain: domain 190mailbox path: (null) 191END_OF_TEST_RESULTS 192 193 194##### Test tests/qmail-lookup-assume ##### 195 196runtest() { 197env CVM_LOOKUP_SECRET=secret \ 198$src/cvm-testclient $tmp/cvm-qmail-lookup user nothingness 199 200echo 201 202env CVM_LOOKUP_SECRET=secret CVM_QMAIL_ASSUME_LOCAL=1 \ 203$src/cvm-testclient $tmp/cvm-qmail-lookup user nothingness 204} 205vecho "Running test tests/qmail-lookup-assume " 206run_compare_test tests/qmail-lookup-assume <<END_OF_TEST_RESULTS 207cvm-testclient: Authentication failed, error #100 (Credentials rejected) 208out of scope: 1 209 210user name: user 211user ID: @UID@ 212group ID: @GID@ 213real name: (null) 214directory: @TMPDIR@/home 215shell: (null) 216group name: (null) 217system user name: user 218system directory: @TMPDIR@/home 219domain: nothingness 220mailbox path: @TMPDIR@/home 221END_OF_TEST_RESULTS 222 223 224##### Test tests/vmlookup-normal ##### 225 226runtest() { 227CVM_LOOKUP_SECRET=secret \ 228$src/cvm-testclient $tmp/cvm-vmailmgr-lookup virt test.tld 229} 230vecho "Running test tests/vmlookup-normal " 231run_compare_test tests/vmlookup-normal <<END_OF_TEST_RESULTS 232user name: virt 233user ID: @UID@ 234group ID: @GID@ 235real name: (null) 236directory: @TMPDIR@/home/virt 237shell: (null) 238group name: (null) 239system user name: user 240system directory: @TMPDIR@/home 241domain: test.tld 242mailbox path: @TMPDIR@/home/virt 243END_OF_TEST_RESULTS 244 245 246##### Test tests/sql-substitution ##### 247 248runtest() { 249sqt() { env - var1=1 var_2=2 $src/sql-query-test "$@"; } 250sqt 'one two' act dom 251sqt '$account $domain one two' act dom 252sqt 'one $account two' act dom 253sqt 'one two $account' act dom 254sqt '$var1 one two' act dom 255sqt 'one $var1 two' act dom 256sqt 'one two $var1' act dom 257sqt '$var_2 one two' act dom 258sqt 'one $var_2 two' act dom 259sqt 'one two $var_2' act dom 260sqt '$var1one two' act dom 261sqt 'one $var1two' act dom 262sqt '${var1} one two' act dom 263sqt 'one ${var1} two' act dom 264sqt 'one two ${var1}' act dom 265} 266vecho "Running test tests/sql-substitution " 267run_compare_test tests/sql-substitution <<END_OF_TEST_RESULTS 268one two 269'act' 'dom' one two 270one 'act' two 271one two 'act' 272'1' one two 273one '1' two 274one two '1' 275'2' one two 276one '2' two 277one two '2' 278 two 279one 280'1' one two 281one '1' two 282one two '1' 283END_OF_TEST_RESULTS 284 285 286##### Test tests/vmlookup-notable ##### 287 288runtest() { 289mv $home/passwd.cdb $home/passwd.cdb.donotuse 290 291$src/cvm-testclient $src/cvm-vmailmgr virt test.tld 'xpass' 292 293mv $home/passwd.cdb.donotuse $home/passwd.cdb 294chmod 000 $home/passwd.cdb 295 296$src/cvm-testclient $src/cvm-vmailmgr virt test.tld 'xpass' 297 298chmod 444 $home/passwd.cdb 299} 300vecho "Running test tests/vmlookup-notable " 301run_compare_test tests/vmlookup-notable <<END_OF_TEST_RESULTS 302cvm-testclient: Authentication failed, error #100 (Credentials rejected) 303out of scope: 1 304cvm-testclient: Authentication failed, error #4 (Input/Output error) 305END_OF_TEST_RESULTS 306 307 308##### Test tests/pwfile-crypt ##### 309 310runtest() { 311make_pwfile 312CVM_PWFILE_PWCMP=crypt export CVM_PWFILE_PWCMP 313$src/cvm-testclient $src/cvm-pwfile cryptuser '' testpass 314} 315vecho "Running test tests/pwfile-crypt " 316run_compare_test tests/pwfile-crypt <<END_OF_TEST_RESULTS 317user name: cryptuser 318user ID: 234 319group ID: 567 320real name: Crypt 321directory: /home/crypt 322shell: /bin/true 323group name: (null) 324system user name: (null) 325system directory: (null) 326domain: (null) 327mailbox path: (null) 328END_OF_TEST_RESULTS 329 330 331##### Test tests/vmlookup-upper-virt ##### 332 333runtest() { 334CVM_LOOKUP_SECRET=secret \ 335$src/cvm-testclient $tmp/cvm-vmailmgr-lookup Virt test.tld 336} 337vecho "Running test tests/vmlookup-upper-virt " 338run_compare_test tests/vmlookup-upper-virt <<END_OF_TEST_RESULTS 339user name: virt 340user ID: @UID@ 341group ID: @GID@ 342real name: (null) 343directory: @TMPDIR@/home/virt 344shell: (null) 345group name: (null) 346system user name: user 347system directory: @TMPDIR@/home 348domain: test.tld 349mailbox path: @TMPDIR@/home/virt 350END_OF_TEST_RESULTS 351 352 353##### Test tests/qmail-lookup-novirtualdomains ##### 354 355runtest() { 356mv $QMAIL_ROOT/control/virtualdomains $QMAIL_ROOT/control/vds 357 358env CVM_LOOKUP_SECRET=secret \ 359$src/cvm-testclient $tmp/cvm-qmail-lookup user test.tld 360 361mv $QMAIL_ROOT/control/vds $QMAIL_ROOT/control/virtualdomains 362} 363vecho "Running test tests/qmail-lookup-novirtualdomains " 364run_compare_test tests/qmail-lookup-novirtualdomains <<END_OF_TEST_RESULTS 365cvm-testclient: Authentication failed, error #100 (Credentials rejected) 366out of scope: 1 367END_OF_TEST_RESULTS 368 369 370##### Test tests/qmail-lookup ##### 371 372runtest() { 373local addr="$1" 374local domain="$2" 375 376env CVM_LOOKUP_SECRET=secret \ 377$src/cvm-testclient $tmp/cvm-qmail-lookup $addr $domain 378} 379vecho "Running test tests/qmail-lookup 'user' 'local.dom'" 380run_compare_test tests/qmail-lookup 'user' 'local.dom' <<END_OF_TEST_RESULTS 381user name: user 382user ID: @UID@ 383group ID: @GID@ 384real name: (null) 385directory: @TMPDIR@/home 386shell: (null) 387group name: (null) 388system user name: user 389system directory: @TMPDIR@/home 390domain: local.dom 391mailbox path: @TMPDIR@/home 392END_OF_TEST_RESULTS 393 394vecho "Running test tests/qmail-lookup 'user-addr' 'local.dom'" 395run_compare_test tests/qmail-lookup 'user-addr' 'local.dom' <<END_OF_TEST_RESULTS 396user name: user 397user ID: @UID@ 398group ID: @GID@ 399real name: (null) 400directory: @TMPDIR@/home 401shell: (null) 402group name: (null) 403system user name: user 404system directory: @TMPDIR@/home 405domain: local.dom 406mailbox path: @TMPDIR@/home 407END_OF_TEST_RESULTS 408 409vecho "Running test tests/qmail-lookup 'user-addr-x' 'local.dom'" 410run_compare_test tests/qmail-lookup 'user-addr-x' 'local.dom' <<END_OF_TEST_RESULTS 411cvm-testclient: Authentication failed, error #100 (Credentials rejected) 412out of scope: 0 413END_OF_TEST_RESULTS 414 415vecho "Running test tests/qmail-lookup 'user-wild' 'local.dom'" 416run_compare_test tests/qmail-lookup 'user-wild' 'local.dom' <<END_OF_TEST_RESULTS 417cvm-testclient: Authentication failed, error #100 (Credentials rejected) 418out of scope: 0 419END_OF_TEST_RESULTS 420 421vecho "Running test tests/qmail-lookup 'user-wild-x' 'local.dom'" 422run_compare_test tests/qmail-lookup 'user-wild-x' 'local.dom' <<END_OF_TEST_RESULTS 423user name: user 424user ID: @UID@ 425group ID: @GID@ 426real name: (null) 427directory: @TMPDIR@/home 428shell: (null) 429group name: (null) 430system user name: user 431system directory: @TMPDIR@/home 432domain: local.dom 433mailbox path: @TMPDIR@/home 434END_OF_TEST_RESULTS 435 436vecho "Running test tests/qmail-lookup 'user-wild-x-y-z' 'local.dom'" 437run_compare_test tests/qmail-lookup 'user-wild-x-y-z' 'local.dom' <<END_OF_TEST_RESULTS 438user name: user 439user ID: @UID@ 440group ID: @GID@ 441real name: (null) 442directory: @TMPDIR@/home 443shell: (null) 444group name: (null) 445system user name: user 446system directory: @TMPDIR@/home 447domain: local.dom 448mailbox path: @TMPDIR@/home 449END_OF_TEST_RESULTS 450 451vecho "Running test tests/qmail-lookup 'alias' 'local.dom'" 452run_compare_test tests/qmail-lookup 'alias' 'local.dom' <<END_OF_TEST_RESULTS 453user name: alias 454user ID: @UID@ 455group ID: @GID@ 456real name: (null) 457directory: @TMPDIR@/alias 458shell: (null) 459group name: (null) 460system user name: alias 461system directory: @TMPDIR@/alias 462domain: local.dom 463mailbox path: @TMPDIR@/alias 464END_OF_TEST_RESULTS 465 466vecho "Running test tests/qmail-lookup 'alias-x' 'local.dom'" 467run_compare_test tests/qmail-lookup 'alias-x' 'local.dom' <<END_OF_TEST_RESULTS 468cvm-testclient: Authentication failed, error #100 (Credentials rejected) 469out of scope: 0 470END_OF_TEST_RESULTS 471 472vecho "Running test tests/qmail-lookup 'awild' 'local.dom'" 473run_compare_test tests/qmail-lookup 'awild' 'local.dom' <<END_OF_TEST_RESULTS 474cvm-testclient: Authentication failed, error #100 (Credentials rejected) 475out of scope: 0 476END_OF_TEST_RESULTS 477 478vecho "Running test tests/qmail-lookup 'awild-x' 'local.dom'" 479run_compare_test tests/qmail-lookup 'awild-x' 'local.dom' <<END_OF_TEST_RESULTS 480user name: alias 481user ID: @UID@ 482group ID: @GID@ 483real name: (null) 484directory: @TMPDIR@/alias 485shell: (null) 486group name: (null) 487system user name: alias 488system directory: @TMPDIR@/alias 489domain: local.dom 490mailbox path: @TMPDIR@/alias 491END_OF_TEST_RESULTS 492 493vecho "Running test tests/qmail-lookup 'USER' 'local.dom'" 494run_compare_test tests/qmail-lookup 'USER' 'local.dom' <<END_OF_TEST_RESULTS 495user name: user 496user ID: @UID@ 497group ID: @GID@ 498real name: (null) 499directory: @TMPDIR@/home 500shell: (null) 501group name: (null) 502system user name: user 503system directory: @TMPDIR@/home 504domain: local.dom 505mailbox path: @TMPDIR@/home 506END_OF_TEST_RESULTS 507 508vecho "Running test tests/qmail-lookup 'user-ADDR' 'local.dom'" 509run_compare_test tests/qmail-lookup 'user-ADDR' 'local.dom' <<END_OF_TEST_RESULTS 510user name: user 511user ID: @UID@ 512group ID: @GID@ 513real name: (null) 514directory: @TMPDIR@/home 515shell: (null) 516group name: (null) 517system user name: user 518system directory: @TMPDIR@/home 519domain: local.dom 520mailbox path: @TMPDIR@/home 521END_OF_TEST_RESULTS 522 523vecho "Running test tests/qmail-lookup 'USER-ADDR' 'local.dom'" 524run_compare_test tests/qmail-lookup 'USER-ADDR' 'local.dom' <<END_OF_TEST_RESULTS 525user name: user 526user ID: @UID@ 527group ID: @GID@ 528real name: (null) 529directory: @TMPDIR@/home 530shell: (null) 531group name: (null) 532system user name: user 533system directory: @TMPDIR@/home 534domain: local.dom 535mailbox path: @TMPDIR@/home 536END_OF_TEST_RESULTS 537 538vecho "Running test tests/qmail-lookup 'user-dot.addr' 'local.dom'" 539run_compare_test tests/qmail-lookup 'user-dot.addr' 'local.dom' <<END_OF_TEST_RESULTS 540user name: user 541user ID: @UID@ 542group ID: @GID@ 543real name: (null) 544directory: @TMPDIR@/home 545shell: (null) 546group name: (null) 547system user name: user 548system directory: @TMPDIR@/home 549domain: local.dom 550mailbox path: @TMPDIR@/home 551END_OF_TEST_RESULTS 552 553vecho "Running test tests/qmail-lookup 'adot.addr' 'local.dom'" 554run_compare_test tests/qmail-lookup 'adot.addr' 'local.dom' <<END_OF_TEST_RESULTS 555user name: alias 556user ID: @UID@ 557group ID: @GID@ 558real name: (null) 559directory: @TMPDIR@/alias 560shell: (null) 561group name: (null) 562system user name: alias 563system directory: @TMPDIR@/alias 564domain: local.dom 565mailbox path: @TMPDIR@/alias 566END_OF_TEST_RESULTS 567 568 569##### Test tests/chain-client ##### 570 571runtest() { 572$src/cvm-testclient $src/cvm-pwfile,$src/cvm-vmailmgr pwfuser test.tld testpass 573echo 574$src/cvm-testclient $src/cvm-pwfile,$src/cvm-vmailmgr virt test.tld pass 575echo 576$src/cvm-testclient $src/cvm-pwfile,$src/cvm-vmailmgr notexist test.tld pass 577echo 578$src/cvm-testclient $src/cvm-pwfile,$src/cvm-vmailmgr notexist other.dom pass 579} 580vecho "Running test tests/chain-client " 581run_compare_test tests/chain-client <<END_OF_TEST_RESULTS 582user name: pwfuser 583user ID: 123 584group ID: 456 585real name: Gecos 586directory: /home/ftp 587shell: /bin/false 588group name: (null) 589system user name: (null) 590system directory: (null) 591domain: (null) 592mailbox path: (null) 593 594user name: virt 595user ID: @UID@ 596group ID: @GID@ 597real name: (null) 598directory: @TMPDIR@/home/virt 599shell: (null) 600group name: (null) 601system user name: user 602system directory: @TMPDIR@/home 603domain: test.tld 604mailbox path: @TMPDIR@/home/virt 605 606cvm-testclient: Authentication failed, error #100 (Credentials rejected) 607out of scope: 0 608 609cvm-testclient: Authentication failed, error #100 (Credentials rejected) 610out of scope: 1 611END_OF_TEST_RESULTS 612 613 614##### Test tests/command-bad-username ##### 615 616runtest() { 617make_pwfile 618$src/cvm-testclient $src/cvm-pwfile pxfuser '' testpass 619} 620vecho "Running test tests/command-bad-username " 621run_compare_test tests/command-bad-username <<END_OF_TEST_RESULTS 622cvm-testclient: Authentication failed, error #100 (Credentials rejected) 623END_OF_TEST_RESULTS 624 625 626##### Test tests/sasl-eof ##### 627 628runtest() { 629sasltest LOGIN </dev/null 630} 631vecho "Running test tests/sasl-eof " 632run_compare_test tests/sasl-eof <<END_OF_TEST_RESULTS 633sasl-auth-test: AUTH LOGIN PLAIN 634+ VXNlcm5hbWU6^M 635sasl-auth-test: SASL AUTH LOGIN failed 636sasl-auth-test: Fatal: sasl_auth1 failed: 8 637 535 End of file reached. 638END_OF_TEST_RESULTS 639 640 641##### Test tests/vmailmgr-xconvert ##### 642 643runtest() { 644env VMAILMGR_AUTOCONVERT=1 \ 645$src/cvm-testclient $src/cvm-vmailmgr virt test.tld pass 646echo 647$src/cvm-testclient $src/cvm-vmailmgr virt test.tld pass 648echo 649cdbget virt <$home/passwd.cdb | xxd 650} 651vecho "Running test tests/vmailmgr-xconvert " 652run_compare_test tests/vmailmgr-xconvert <<END_OF_TEST_RESULTS 653user name: virt 654user ID: @UID@ 655group ID: @GID@ 656real name: (null) 657directory: @TMPDIR@/home/virt 658shell: (null) 659group name: (null) 660system user name: user 661system directory: @TMPDIR@/home 662domain: test.tld 663mailbox path: @TMPDIR@/home/virt 664 665user name: virt 666user ID: @UID@ 667group ID: @GID@ 668real name: (null) 669directory: @TMPDIR@/home/virt 670shell: (null) 671group name: (null) 672system user name: user 673system directory: @TMPDIR@/home 674domain: test.tld 675mailbox path: @TMPDIR@/home/virt 676 6770000000: 020a 0108 0100 2430 2470 6173 7300 2e2f ......\$0\$pass../ 6780000010: 7669 7274 0000 002d 002d 002d 002d 0031 virt...-.-.-.-.1 6790000020: 3031 3637 3331 3335 3800 2d00 016731358.-. 680END_OF_TEST_RESULTS 681 682 683##### Test tests/pwfile ##### 684 685runtest() { 686make_pwfile 687$src/cvm-testclient $src/cvm-pwfile pwfuser '' testpass 688} 689vecho "Running test tests/pwfile " 690run_compare_test tests/pwfile <<END_OF_TEST_RESULTS 691user name: pwfuser 692user ID: 123 693group ID: 456 694real name: Gecos 695directory: /home/ftp 696shell: /bin/false 697group name: (null) 698system user name: (null) 699system directory: (null) 700domain: (null) 701mailbox path: (null) 702END_OF_TEST_RESULTS 703 704 705##### Test tests/vmlookup-baddomain ##### 706 707runtest() { 708CVM_LOOKUP_SECRET=secret \ 709$src/cvm-testclient $tmp/cvm-vmailmgr-lookup virt other.tld 710} 711vecho "Running test tests/vmlookup-baddomain " 712run_compare_test tests/vmlookup-baddomain <<END_OF_TEST_RESULTS 713cvm-testclient: Authentication failed, error #100 (Credentials rejected) 714out of scope: 1 715END_OF_TEST_RESULTS 716 717 718##### Test tests/sasl-login2 ##### 719 720runtest() { 721sasltest LOGIN\ cHdmdXNlcg== <<EOF 722dGVzdHBhc3M= 723EOF 724} 725vecho "Running test tests/sasl-login2 " 726run_compare_test tests/sasl-login2 <<END_OF_TEST_RESULTS 727sasl-auth-test: AUTH LOGIN PLAIN 728+ UGFzc3dvcmQ6^M 729sasl-auth-test: SASL AUTH LOGIN username=pwfuser 730END_OF_TEST_RESULTS 731 732 733##### Test tests/command-case ##### 734 735runtest() { 736make_pwfile 737$src/cvm-testclient $src/cvm-pwfile PWFUser '' testpass 738} 739vecho "Running test tests/command-case " 740run_compare_test tests/command-case <<END_OF_TEST_RESULTS 741user name: pwfuser 742user ID: 123 743group ID: 456 744real name: Gecos 745directory: /home/ftp 746shell: /bin/false 747group name: (null) 748system user name: (null) 749system directory: (null) 750domain: (null) 751mailbox path: (null) 752END_OF_TEST_RESULTS 753 754 755##### Test tests/vmlookup-pass ##### 756 757runtest() { 758CVM_LOOKUP_SECRET=secret \ 759$src/cvm-testclient $tmp/cvm-vmailmgr-lookup virt test.tld 760} 761vecho "Running test tests/vmlookup-pass " 762run_compare_test tests/vmlookup-pass <<END_OF_TEST_RESULTS 763user name: virt 764user ID: @UID@ 765group ID: @GID@ 766real name: (null) 767directory: @TMPDIR@/home/virt 768shell: (null) 769group name: (null) 770system user name: user 771system directory: @TMPDIR@/home 772domain: test.tld 773mailbox path: @TMPDIR@/home/virt 774END_OF_TEST_RESULTS 775 776 777##### Test tests/vmailmgr-upper-pass ##### 778 779runtest() { 780$src/cvm-testclient $src/cvm-vmailmgr virt test.tld Pass 781} 782vecho "Running test tests/vmailmgr-upper-pass " 783run_compare_test tests/vmailmgr-upper-pass <<END_OF_TEST_RESULTS 784cvm-testclient: Authentication failed, error #100 (Credentials rejected) 785out of scope: 0 786END_OF_TEST_RESULTS 787 788 789##### Test tests/vmlookup-upper-domain ##### 790 791runtest() { 792CVM_LOOKUP_SECRET=secret \ 793$src/cvm-testclient $tmp/cvm-vmailmgr-lookup virt Test.TLD 794} 795vecho "Running test tests/vmlookup-upper-domain " 796run_compare_test tests/vmlookup-upper-domain <<END_OF_TEST_RESULTS 797user name: virt 798user ID: @UID@ 799group ID: @GID@ 800real name: (null) 801directory: @TMPDIR@/home/virt 802shell: (null) 803group name: (null) 804system user name: user 805system directory: @TMPDIR@/home 806domain: test.tld 807mailbox path: @TMPDIR@/home/virt 808END_OF_TEST_RESULTS 809 810 811##### Test tests/sasl-login1 ##### 812 813runtest() { 814sasltest LOGIN <<EOF 815cHdmdXNlcg== 816dGVzdHBhc3M= 817EOF 818} 819vecho "Running test tests/sasl-login1 " 820run_compare_test tests/sasl-login1 <<END_OF_TEST_RESULTS 821sasl-auth-test: AUTH LOGIN PLAIN 822+ VXNlcm5hbWU6^M 823+ UGFzc3dvcmQ6^M 824sasl-auth-test: SASL AUTH LOGIN username=pwfuser 825END_OF_TEST_RESULTS 826 827 828##### Test tests/sasl-plain1 ##### 829 830runtest() { 831sasltest PLAIN <<EOF 832cHdmdXNlcgBwd2Z1c2VyAHRlc3RwYXNz 833EOF 834} 835vecho "Running test tests/sasl-plain1 " 836run_compare_test tests/sasl-plain1 <<END_OF_TEST_RESULTS 837sasl-auth-test: AUTH LOGIN PLAIN 838+ ^M 839sasl-auth-test: SASL AUTH PLAIN username=pwfuser 840END_OF_TEST_RESULTS 841 842 843##### Test tests/sasl-plain-fail ##### 844 845runtest() { 846sasltest PLAIN\ cHdmdXNlcgBwd2Z1c2VyAHRlc3RwYXNZ </dev/null 847} 848vecho "Running test tests/sasl-plain-fail " 849run_compare_test tests/sasl-plain-fail <<END_OF_TEST_RESULTS 850sasl-auth-test: AUTH LOGIN PLAIN 851sasl-auth-test: SASL AUTH PLAIN failed 852sasl-auth-test: Fatal: sasl_auth1 failed: 1 853 501 Authentication failed. 854END_OF_TEST_RESULTS 855 856 857##### Test tests/qmail-lookup-baddomain ##### 858 859runtest() { 860env CVM_LOOKUP_SECRET=secret \ 861$src/cvm-testclient $tmp/cvm-qmail-lookup user other.dom 862} 863vecho "Running test tests/qmail-lookup-baddomain " 864run_compare_test tests/qmail-lookup-baddomain <<END_OF_TEST_RESULTS 865cvm-testclient: Authentication failed, error #100 (Credentials rejected) 866out of scope: 1 867END_OF_TEST_RESULTS 868 869 870##### Test tests/sasl-plain2 ##### 871 872runtest() { 873sasltest PLAIN\ cHdmdXNlcgBwd2Z1c2VyAHRlc3RwYXNz </dev/null 874} 875vecho "Running test tests/sasl-plain2 " 876run_compare_test tests/sasl-plain2 <<END_OF_TEST_RESULTS 877sasl-auth-test: AUTH LOGIN PLAIN 878sasl-auth-test: SASL AUTH PLAIN username=pwfuser 879END_OF_TEST_RESULTS 880 881 882##### Test tests/vmlookup-baduser ##### 883 884runtest() { 885CVM_LOOKUP_SECRET=secret \ 886$src/cvm-testclient $tmp/cvm-vmailmgr-lookup missing test.tld 887} 888vecho "Running test tests/vmlookup-baduser " 889run_compare_test tests/vmlookup-baduser <<END_OF_TEST_RESULTS 890cvm-testclient: Authentication failed, error #100 (Credentials rejected) 891out of scope: 0 892END_OF_TEST_RESULTS 893 894 895##### Test tests/vmlookup-badpass ##### 896 897runtest() { 898$src/cvm-testclient $src/cvm-vmailmgr virt test.tld 'xpass' 899} 900vecho "Running test tests/vmlookup-badpass " 901run_compare_test tests/vmlookup-badpass <<END_OF_TEST_RESULTS 902cvm-testclient: Authentication failed, error #100 (Credentials rejected) 903out of scope: 0 904END_OF_TEST_RESULTS 905 906 907##### Test tests/vmailmgr-upper-virt ##### 908 909runtest() { 910$src/cvm-testclient $src/cvm-vmailmgr Virt test.tld pass 911} 912vecho "Running test tests/vmailmgr-upper-virt " 913run_compare_test tests/vmailmgr-upper-virt <<END_OF_TEST_RESULTS 914user name: virt 915user ID: @UID@ 916group ID: @GID@ 917real name: (null) 918directory: @TMPDIR@/home/virt 919shell: (null) 920group name: (null) 921system user name: user 922system directory: @TMPDIR@/home 923domain: test.tld 924mailbox path: @TMPDIR@/home/virt 925END_OF_TEST_RESULTS 926 927 928##### Test tests/command-no-prefix ##### 929 930runtest() { 931make_pwfile 932$src/cvm-testclient $src/cvm-pwfile pwfuser '' testpass 933} 934vecho "Running test tests/command-no-prefix " 935run_compare_test tests/command-no-prefix <<END_OF_TEST_RESULTS 936user name: pwfuser 937user ID: 123 938group ID: 456 939real name: Gecos 940directory: /home/ftp 941shell: /bin/false 942group name: (null) 943system user name: (null) 944system directory: (null) 945domain: (null) 946mailbox path: (null) 947END_OF_TEST_RESULTS 948 949 950##### Test tests/vmailmgr-upper-domain ##### 951 952runtest() { 953$src/cvm-testclient $src/cvm-vmailmgr virt Test.TLD pass 954} 955vecho "Running test tests/vmailmgr-upper-domain " 956run_compare_test tests/vmailmgr-upper-domain <<END_OF_TEST_RESULTS 957user name: virt 958user ID: @UID@ 959group ID: @GID@ 960real name: (null) 961directory: @TMPDIR@/home/virt 962shell: (null) 963group name: (null) 964system user name: user 965system directory: @TMPDIR@/home 966domain: test.tld 967mailbox path: @TMPDIR@/home/virt 968END_OF_TEST_RESULTS 969 970 971##### Test tests/pwfile-bad-password ##### 972 973runtest() { 974make_pwfile 975$src/cvm-testclient $src/cvm-pwfile pwfuser '' testpaxx 976} 977vecho "Running test tests/pwfile-bad-password " 978run_compare_test tests/pwfile-bad-password <<END_OF_TEST_RESULTS 979cvm-testclient: Authentication failed, error #100 (Credentials rejected) 980END_OF_TEST_RESULTS 981 982 983##### Test tests/vmailmgr-normal ##### 984 985runtest() { 986$src/cvm-testclient $src/cvm-vmailmgr virt test.tld pass 987echo 988$src/cvm-testclient $src/cvm-vmailmgr missing test.tld pass 989} 990vecho "Running test tests/vmailmgr-normal " 991run_compare_test tests/vmailmgr-normal <<END_OF_TEST_RESULTS 992user name: virt 993user ID: @UID@ 994group ID: @GID@ 995real name: (null) 996directory: @TMPDIR@/home/virt 997shell: (null) 998group name: (null) 999system user name: user 1000system directory: @TMPDIR@/home 1001domain: test.tld 1002mailbox path: @TMPDIR@/home/virt 1003 1004cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1005out of scope: 0 1006END_OF_TEST_RESULTS 1007 1008 1009##### Test tests/qmail-lookup-nodomain ##### 1010 1011runtest() { 1012CVM_LOOKUP_SECRET=secret \ 1013$src/cvm-testclient $tmp/cvm-qmail-lookup addr '' 1014} 1015vecho "Running test tests/qmail-lookup-nodomain " 1016run_compare_test tests/qmail-lookup-nodomain <<END_OF_TEST_RESULTS 1017user name: user 1018user ID: @UID@ 1019group ID: @GID@ 1020real name: (null) 1021directory: @TMPDIR@/home 1022shell: (null) 1023group name: (null) 1024system user name: user 1025system directory: @TMPDIR@/home 1026domain: noathost 1027mailbox path: @TMPDIR@/home 1028END_OF_TEST_RESULTS 1029 1030 1031##### Test tests/qmail-lookup-perms ##### 1032 1033runtest() { 1034doit() { 1035 echo "$1" >$tmp/.qmail-lookaside-default 1036 $src/cvm-testclient $tmp/cvm-qmail-lookup lookaside-someone test.tld 1037} 1038 1039export CVM_LOOKUP_SECRET=secret 1040export CVM_QMAIL_CHECK_PERMS=0 1041 1042$src/cvm-testclient $tmp/cvm-qmail-lookup addr test.tld 1043 1044chmod 000 $home 1045echo 1046$src/cvm-testclient $tmp/cvm-qmail-lookup addr test.tld 1047 1048export CVM_QMAIL_CHECK_PERMS=- 1049echo 1050$src/cvm-testclient $tmp/cvm-qmail-lookup addr test.tld 1051 1052chmod 755 $home 1053 1054unset CVM_LOOKUP_SECRET 1055unset CVM_QMAIL_CHECK_PERMS 1056} 1057vecho "Running test tests/qmail-lookup-perms " 1058run_compare_test tests/qmail-lookup-perms <<END_OF_TEST_RESULTS 1059user name: user 1060user ID: @UID@ 1061group ID: @GID@ 1062real name: (null) 1063directory: @TMPDIR@/home 1064shell: (null) 1065group name: (null) 1066system user name: user 1067system directory: @TMPDIR@/home 1068domain: test.tld 1069mailbox path: @TMPDIR@/home 1070 1071cvm-testclient: Authentication failed, error #4 (Input/Output error) 1072 1073cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1074out of scope: 0 1075END_OF_TEST_RESULTS 1076 1077 1078##### Test tests/v1lookup ##### 1079 1080runtest() { 1081local secret="$1" 1082 1083make_pwfile 1084cat <<EOF >$tmp/cvmlookup 1085#!/bin/sh 1086CVM_LOOKUP_SECRET=$secret 1087export CVM_LOOKUP_SECRET 1088exec $src/cvm-pwfile 1089EOF 1090chmod +x $tmp/cvmlookup 1091 1092$src/cvm-v1testclient $tmp/cvmlookup pwfuser '' 1093$src/cvm-v1testclient $tmp/cvmlookup pwfuser '' '' 1094$src/cvm-v1testclient $tmp/cvmlookup pwfuser '' secret 1095 1096rm -f $tmp/cvmlookup 1097} 1098vecho "Running test tests/v1lookup ''" 1099run_compare_test tests/v1lookup '' <<END_OF_TEST_RESULTS 1100user name: pwfuser 1101user ID: 123 1102group ID: 456 1103real name: Gecos 1104directory: /home/ftp 1105shell: /bin/false 1106group name: (null) 1107system user name: (null) 1108system directory: (null) 1109domain: (null) 1110mailbox path: (null) 1111user name: pwfuser 1112user ID: 123 1113group ID: 456 1114real name: Gecos 1115directory: /home/ftp 1116shell: /bin/false 1117group name: (null) 1118system user name: (null) 1119system directory: (null) 1120domain: (null) 1121mailbox path: (null) 1122user name: pwfuser 1123user ID: 123 1124group ID: 456 1125real name: Gecos 1126directory: /home/ftp 1127shell: /bin/false 1128group name: (null) 1129system user name: (null) 1130system directory: (null) 1131domain: (null) 1132mailbox path: (null) 1133END_OF_TEST_RESULTS 1134 1135vecho "Running test tests/v1lookup 'secret'" 1136run_compare_test tests/v1lookup 'secret' <<END_OF_TEST_RESULTS 1137cvm-v1testclient: Fatal: Authentication failed, error #7 (Credential missing in data from module) 1138cvm-v1testclient: Fatal: Authentication failed, error #7 (Credential missing in data from module) 1139user name: pwfuser 1140user ID: 123 1141group ID: 456 1142real name: Gecos 1143directory: /home/ftp 1144shell: /bin/false 1145group name: (null) 1146system user name: (null) 1147system directory: (null) 1148domain: (null) 1149mailbox path: (null) 1150END_OF_TEST_RESULTS 1151 1152 1153##### Test tests/qmail-lookup-lookaside ##### 1154 1155runtest() { 1156doit() { 1157 echo "$1" >$home/.qmail-lookaside-default 1158 $src/cvm-testclient $tmp/cvm-qmail-lookup lookaside-someone test.tld 1159} 1160 1161export CVM_LOOKUP_SECRET=secret 1162export CVM_QMAIL_LOOKASIDE='/bin/program1 /bin/program2 /bin/program3' 1163 1164doit '| /bin/program foo' 1165echo 1166doit '| /bin/program1 foo' 1167echo 1168doit '| /bin/program2 foo' 1169echo 1170doit '| /bin/program3 foo' 1171echo 1172doit ' |/bin/program1' 1173echo 1174doit $'#before\n|/bin/program2\n#after' 1175 1176unset CVM_LOOKUP_SECRET 1177unset CVM_QMAIL_LOOKASIDE 1178} 1179vecho "Running test tests/qmail-lookup-lookaside " 1180run_compare_test tests/qmail-lookup-lookaside <<END_OF_TEST_RESULTS 1181user name: user 1182user ID: @UID@ 1183group ID: @GID@ 1184real name: (null) 1185directory: @TMPDIR@/home 1186shell: (null) 1187group name: (null) 1188system user name: user 1189system directory: @TMPDIR@/home 1190domain: test.tld 1191mailbox path: @TMPDIR@/home 1192 1193cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1194out of scope: 1 1195 1196cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1197out of scope: 1 1198 1199cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1200out of scope: 1 1201 1202cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1203out of scope: 1 1204 1205cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1206out of scope: 1 1207END_OF_TEST_RESULTS 1208 1209 1210##### Test tests/lookup ##### 1211 1212runtest() { 1213local secret="$1" 1214 1215make_pwfile 1216cat <<EOF >$tmp/cvmlookup 1217#!/bin/sh 1218CVM_LOOKUP_SECRET=$secret 1219export CVM_LOOKUP_SECRET 1220exec $src/cvm-pwfile 1221EOF 1222chmod +x $tmp/cvmlookup 1223 1224$src/cvm-testclient $tmp/cvmlookup pwfuser '' 1225env CVM_LOOKUP_SECRET='' \ 1226$src/cvm-testclient $tmp/cvmlookup pwfuser '' 1227env CVM_LOOKUP_SECRET=$secret \ 1228$src/cvm-testclient $tmp/cvmlookup pwfuser '' 1229 1230rm -f $tmp/cvmlookup 1231} 1232vecho "Running test tests/lookup ''" 1233run_compare_test tests/lookup '' <<END_OF_TEST_RESULTS 1234user name: pwfuser 1235user ID: 123 1236group ID: 456 1237real name: Gecos 1238directory: /home/ftp 1239shell: /bin/false 1240group name: (null) 1241system user name: (null) 1242system directory: (null) 1243domain: (null) 1244mailbox path: (null) 1245user name: pwfuser 1246user ID: 123 1247group ID: 456 1248real name: Gecos 1249directory: /home/ftp 1250shell: /bin/false 1251group name: (null) 1252system user name: (null) 1253system directory: (null) 1254domain: (null) 1255mailbox path: (null) 1256user name: pwfuser 1257user ID: 123 1258group ID: 456 1259real name: Gecos 1260directory: /home/ftp 1261shell: /bin/false 1262group name: (null) 1263system user name: (null) 1264system directory: (null) 1265domain: (null) 1266mailbox path: (null) 1267END_OF_TEST_RESULTS 1268 1269vecho "Running test tests/lookup 'secret'" 1270run_compare_test tests/lookup 'secret' <<END_OF_TEST_RESULTS 1271cvm-testclient: Authentication failed, error #7 (Credential missing in data from module) 1272cvm-testclient: Authentication failed, error #7 (Credential missing in data from module) 1273user name: pwfuser 1274user ID: 123 1275group ID: 456 1276real name: Gecos 1277directory: /home/ftp 1278shell: /bin/false 1279group name: (null) 1280system user name: (null) 1281system directory: (null) 1282domain: (null) 1283mailbox path: (null) 1284END_OF_TEST_RESULTS 1285 1286 1287##### Test tests/chain-module ##### 1288 1289runtest() { 1290CVM_CHAIN0=$src/cvm-pwfile 1291CVM_CHAIN1=$src/cvm-vmailmgr 1292export CVM_CHAIN0 CVM_CHAIN1 1293 1294$src/cvm-testclient $src/cvm-chain pwfuser test.tld testpass 1295echo 1296$src/cvm-testclient $src/cvm-chain virt test.tld pass 1297echo 1298$src/cvm-testclient $src/cvm-chain notexist test.tld pass 1299echo 1300$src/cvm-testclient $src/cvm-chain notexist other.dom pass 1301 1302unset CVM_CHAIN0 CVM_CHAIN1 1303} 1304vecho "Running test tests/chain-module " 1305run_compare_test tests/chain-module <<END_OF_TEST_RESULTS 1306user name: pwfuser 1307user ID: 123 1308group ID: 456 1309real name: Gecos 1310directory: /home/ftp 1311shell: /bin/false 1312group name: (null) 1313system user name: (null) 1314system directory: (null) 1315domain: (null) 1316mailbox path: (null) 1317 1318user name: virt 1319user ID: @UID@ 1320group ID: @GID@ 1321real name: (null) 1322directory: @TMPDIR@/home/virt 1323shell: (null) 1324group name: (null) 1325system user name: user 1326system directory: @TMPDIR@/home 1327domain: test.tld 1328mailbox path: @TMPDIR@/home/virt 1329 1330cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1331out of scope: 0 1332 1333cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1334out of scope: 1 1335END_OF_TEST_RESULTS 1336 1337 1338##### Test tests/sasl-nomech ##### 1339 1340runtest() { 1341sasltest BOGUS </dev/null 1342} 1343vecho "Running test tests/sasl-nomech " 1344run_compare_test tests/sasl-nomech <<END_OF_TEST_RESULTS 1345sasl-auth-test: AUTH LOGIN PLAIN 1346sasl-auth-test: SASL AUTH BOGUS failed 1347sasl-auth-test: Fatal: sasl_auth1 failed: 2 1348 504 Unrecognized authentication mechanism. 1349END_OF_TEST_RESULTS 1350 1351 1352##### Test tests/command-bad-password ##### 1353 1354runtest() { 1355make_pwfile 1356$src/cvm-testclient $src/cvm-pwfile pwfuser '' testpassx 1357} 1358vecho "Running test tests/command-bad-password " 1359run_compare_test tests/command-bad-password <<END_OF_TEST_RESULTS 1360cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1361END_OF_TEST_RESULTS 1362 1363 1364##### Test tests/split ##### 1365 1366runtest() { 1367local dom1="$1" 1368local dom2="$2" 1369$src/cvm-testclient $src/cvm-vmailmgr virt$dom1 "$dom2" pass 1370} 1371vecho "Running test tests/split '' ''" 1372run_compare_test tests/split '' '' <<END_OF_TEST_RESULTS 1373user name: virt 1374user ID: @UID@ 1375group ID: @GID@ 1376real name: (null) 1377directory: @TMPDIR@/home/virt 1378shell: (null) 1379group name: (null) 1380system user name: user 1381system directory: @TMPDIR@/home 1382domain: noathost 1383mailbox path: @TMPDIR@/home/virt 1384END_OF_TEST_RESULTS 1385 1386vecho "Running test tests/split '' 'test.tld'" 1387run_compare_test tests/split '' 'test.tld' <<END_OF_TEST_RESULTS 1388user name: virt 1389user ID: @UID@ 1390group ID: @GID@ 1391real name: (null) 1392directory: @TMPDIR@/home/virt 1393shell: (null) 1394group name: (null) 1395system user name: user 1396system directory: @TMPDIR@/home 1397domain: test.tld 1398mailbox path: @TMPDIR@/home/virt 1399END_OF_TEST_RESULTS 1400 1401vecho "Running test tests/split '' 'other.tld'" 1402run_compare_test tests/split '' 'other.tld' <<END_OF_TEST_RESULTS 1403cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1404out of scope: 1 1405END_OF_TEST_RESULTS 1406 1407vecho "Running test tests/split '@test.tld' ''" 1408run_compare_test tests/split '@test.tld' '' <<END_OF_TEST_RESULTS 1409user name: virt 1410user ID: @UID@ 1411group ID: @GID@ 1412real name: (null) 1413directory: @TMPDIR@/home/virt 1414shell: (null) 1415group name: (null) 1416system user name: user 1417system directory: @TMPDIR@/home 1418domain: test.tld 1419mailbox path: @TMPDIR@/home/virt 1420END_OF_TEST_RESULTS 1421 1422vecho "Running test tests/split '@test.tld' 'test.tld'" 1423run_compare_test tests/split '@test.tld' 'test.tld' <<END_OF_TEST_RESULTS 1424user name: virt 1425user ID: @UID@ 1426group ID: @GID@ 1427real name: (null) 1428directory: @TMPDIR@/home/virt 1429shell: (null) 1430group name: (null) 1431system user name: user 1432system directory: @TMPDIR@/home 1433domain: test.tld 1434mailbox path: @TMPDIR@/home/virt 1435END_OF_TEST_RESULTS 1436 1437vecho "Running test tests/split '@test.tld' 'other.tld'" 1438run_compare_test tests/split '@test.tld' 'other.tld' <<END_OF_TEST_RESULTS 1439user name: virt 1440user ID: @UID@ 1441group ID: @GID@ 1442real name: (null) 1443directory: @TMPDIR@/home/virt 1444shell: (null) 1445group name: (null) 1446system user name: user 1447system directory: @TMPDIR@/home 1448domain: test.tld 1449mailbox path: @TMPDIR@/home/virt 1450END_OF_TEST_RESULTS 1451 1452vecho "Running test tests/split '@other.tld' ''" 1453run_compare_test tests/split '@other.tld' '' <<END_OF_TEST_RESULTS 1454cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1455out of scope: 1 1456END_OF_TEST_RESULTS 1457 1458vecho "Running test tests/split '@other.tld' 'test.tld'" 1459run_compare_test tests/split '@other.tld' 'test.tld' <<END_OF_TEST_RESULTS 1460cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1461out of scope: 1 1462END_OF_TEST_RESULTS 1463 1464vecho "Running test tests/split '@other.tld' 'other.tld'" 1465run_compare_test tests/split '@other.tld' 'other.tld' <<END_OF_TEST_RESULTS 1466cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1467out of scope: 1 1468END_OF_TEST_RESULTS 1469 1470 1471##### Test tests/command-prefix ##### 1472 1473runtest() { 1474make_pwfile 1475$src/cvm-testclient cvm-command:$src/cvm-pwfile pwfuser '' testpass 1476} 1477vecho "Running test tests/command-prefix " 1478run_compare_test tests/command-prefix <<END_OF_TEST_RESULTS 1479user name: pwfuser 1480user ID: 123 1481group ID: 456 1482real name: Gecos 1483directory: /home/ftp 1484shell: /bin/false 1485group name: (null) 1486system user name: (null) 1487system directory: (null) 1488domain: (null) 1489mailbox path: (null) 1490END_OF_TEST_RESULTS 1491 1492 1493##### Test tests/start-pwfile-local ##### 1494 1495runtest() { 1496$src/cvm-pwfile cvm-local:$tmp/socket >$tmp/log & 1497echo $! >$tmp/pid 1498sleep 1 1499cat $tmp/log 1500} 1501vecho "Running test tests/start-pwfile-local " 1502run_compare_test tests/start-pwfile-local <<END_OF_TEST_RESULTS 1503Starting. 1504END_OF_TEST_RESULTS 1505 1506 1507##### Test tests/v1local ##### 1508 1509runtest() { 1510make_pwfile 1511$src/cvm-v1testclient cvm-local:$tmp/socket pwfuser '' testpass 1512tail -n 1 $tmp/log 1513} 1514vecho "Running test tests/v1local " 1515run_compare_test tests/v1local <<END_OF_TEST_RESULTS 1516user name: pwfuser 1517user ID: 123 1518group ID: 456 1519real name: Gecos 1520directory: /home/ftp 1521shell: /bin/false 1522group name: (null) 1523system user name: (null) 1524system directory: (null) 1525domain: (null) 1526mailbox path: (null) 1527+ pwfuser 1528END_OF_TEST_RESULTS 1529 1530 1531##### Test tests/pwfile-local ##### 1532 1533runtest() { 1534make_pwfile 1535$src/cvm-testclient cvm-local:$tmp/socket pwfuser '' testpass 1536tail -n 1 $tmp/log 1537} 1538vecho "Running test tests/pwfile-local " 1539run_compare_test tests/pwfile-local <<END_OF_TEST_RESULTS 1540user name: pwfuser 1541user ID: 123 1542group ID: 456 1543real name: Gecos 1544directory: /home/ftp 1545shell: /bin/false 1546group name: (null) 1547system user name: (null) 1548system directory: (null) 1549domain: (null) 1550mailbox path: (null) 1551+ pwfuser 1552END_OF_TEST_RESULTS 1553 1554 1555##### Test tests/pwfile-local-bad-password ##### 1556 1557runtest() { 1558make_pwfile 1559$src/cvm-testclient cvm-local:$tmp/socket pwfuser '' testpaxx 1560tail -n 1 $tmp/log 1561} 1562vecho "Running test tests/pwfile-local-bad-password " 1563run_compare_test tests/pwfile-local-bad-password <<END_OF_TEST_RESULTS 1564cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1565- pwfuser 1566END_OF_TEST_RESULTS 1567 1568 1569##### Test tests/stop-pwfile-local ##### 1570 1571runtest() { 1572kill `cat $tmp/pid` 1573rm -f $tmp/pid 1574sleep 1 1575tail -n 1 $tmp/log 1576echo `cat $tmp/log | wc` 1577rm -f $tmp/log 1578test -e $tmp/socket || echo Socket was removed. 1579} 1580vecho "Running test tests/stop-pwfile-local " 1581run_compare_test tests/stop-pwfile-local <<END_OF_TEST_RESULTS 1582Stopping. 15835 8 50 1584Socket was removed. 1585END_OF_TEST_RESULTS 1586 1587 1588##### Test tests/start-pwfile-udp ##### 1589 1590runtest() { 1591$src/cvm-pwfile cvm-udp:127.1.2.3:12345 >$tmp/log & 1592echo $! >$tmp/pid 1593sleep 1 1594cat $tmp/log 1595} 1596vecho "Running test tests/start-pwfile-udp " 1597run_compare_test tests/start-pwfile-udp <<END_OF_TEST_RESULTS 1598Starting. 1599END_OF_TEST_RESULTS 1600 1601 1602##### Test tests/v1udp ##### 1603 1604runtest() { 1605make_pwfile 1606$src/cvm-v1testclient cvm-udp:127.1.2.3:12345 pwfuser '' testpass 1607tail -n 1 $tmp/log 1608} 1609vecho "Running test tests/v1udp " 1610run_compare_test tests/v1udp <<END_OF_TEST_RESULTS 1611user name: pwfuser 1612user ID: 123 1613group ID: 456 1614real name: Gecos 1615directory: /home/ftp 1616shell: /bin/false 1617group name: (null) 1618system user name: (null) 1619system directory: (null) 1620domain: (null) 1621mailbox path: (null) 1622+ pwfuser 1623END_OF_TEST_RESULTS 1624 1625 1626##### Test tests/pwfile-udp ##### 1627 1628runtest() { 1629make_pwfile 1630$src/cvm-testclient cvm-udp:127.1.2.3:12345 pwfuser '' testpass 1631tail -n 1 $tmp/log 1632} 1633vecho "Running test tests/pwfile-udp " 1634run_compare_test tests/pwfile-udp <<END_OF_TEST_RESULTS 1635user name: pwfuser 1636user ID: 123 1637group ID: 456 1638real name: Gecos 1639directory: /home/ftp 1640shell: /bin/false 1641group name: (null) 1642system user name: (null) 1643system directory: (null) 1644domain: (null) 1645mailbox path: (null) 1646+ pwfuser 1647END_OF_TEST_RESULTS 1648 1649 1650##### Test tests/pwfile-udp-bad-password ##### 1651 1652runtest() { 1653make_pwfile 1654$src/cvm-testclient cvm-udp:127.1.2.3:12345 pwfuser '' testpaxx 1655tail -n 1 $tmp/log 1656} 1657vecho "Running test tests/pwfile-udp-bad-password " 1658run_compare_test tests/pwfile-udp-bad-password <<END_OF_TEST_RESULTS 1659cvm-testclient: Authentication failed, error #100 (Credentials rejected) 1660- pwfuser 1661END_OF_TEST_RESULTS 1662 1663 1664##### Test tests/stop-pwfile-udp ##### 1665 1666runtest() { 1667kill `cat $tmp/pid` 1668rm -f $tmp/pid 1669sleep 1 1670tail -n 1 $tmp/log 1671echo `cat $tmp/log | wc` 1672rm -f $tmp/log 1673} 1674vecho "Running test tests/stop-pwfile-udp " 1675run_compare_test tests/stop-pwfile-udp <<END_OF_TEST_RESULTS 1676Stopping. 16775 8 50 1678END_OF_TEST_RESULTS 1679 1680 1681rm -rf $tmp 1682echo $tests_count tests executed, $tests_failed failures 1683if [ $tests_failed != 0 ]; then exit 1; fi 1684