authtest 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/ksh
  2. #
  3. # BEGIN COPYRIGHT BLOCK
  4. # This Program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation; version 2 of the License.
  7. #
  8. # This Program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  14. # Place, Suite 330, Boston, MA 02111-1307 USA.
  15. #
  16. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  17. # right to link the code of this Program with code not covered under the GNU
  18. # General Public License ("Non-GPL Code") and to distribute linked combinations
  19. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  20. # permitted under this exception must only link to the code of this Program
  21. # through those well defined interfaces identified in the file named EXCEPTION
  22. # found in the source code files (the "Approved Interfaces"). The files of
  23. # Non-GPL Code may instantiate templates or use macros or inline functions from
  24. # the Approved Interfaces without causing the resulting work to be covered by
  25. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  26. # additions to the list of Approved Interfaces. You must obey the GNU General
  27. # Public License in all respects for all of the Program code and other code used
  28. # in conjunction with the Program except the Non-GPL Code covered by this
  29. # exception. If you modify this file, you may extend this exception to your
  30. # version of the file, but you are not obligated to do so. If you do not wish to
  31. # provide this exception without modification, you must delete this exception
  32. # statement from your version and license this file solely under the GPL without
  33. # exception.
  34. #
  35. #
  36. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  37. # Copyright (C) 2005 Red Hat, Inc.
  38. # All rights reserved.
  39. # END COPYRIGHT BLOCK
  40. #
  41. # setup for test
  42. USERDN="cn=Harry Miller, ou=Human Resources, o=Ace Industry, c=US"
  43. USER2DN="cn=Sam Carter, ou=Accounting, o=Ace Industry, c=US"
  44. UID="hmiller"
  45. U2ID="scarter"
  46. GROUPDN="cn=Directory Administrators, o=Ace Industry, c=US"
  47. GROUPID="Directory Administrators"
  48. ATTRFILTER="[email protected]"
  49. ATTR2FILTER="[email protected]"
  50. function check_result {
  51. echo "\nStart of test: $1 $2 \"$3\" \"$4\""
  52. if ( `$1 $2 "$3" "$4"` ) then
  53. if [ $5 == "fail" ]; then
  54. echo "**** Test Failed ****";
  55. else
  56. echo "Test Succeeded";
  57. fi
  58. else
  59. if [ $5 == "fail" ]; then
  60. echo "Test Succeeded";
  61. else
  62. echo "**** Test Failed ****";
  63. fi
  64. fi
  65. }
  66. function must_fail {
  67. check_result $1 $2 "$3" "$4" "fail";
  68. }
  69. function must_succeed {
  70. check_result $1 $2 "$3" "$4" "success";
  71. }
  72. # test for <userdn> <groupdn>
  73. must_succeed ./auth 1 "${USERDN}" "${GROUPDN}"
  74. must_fail ./auth 1 "${USER2DN}" "${GROUPDN}"
  75. # test for <uid> <groupdn>
  76. must_succeed ./auth 2 "${UID}" "${GROUPDN}"
  77. must_fail ./auth 2 "${U2ID}" "${GROUPDN}"
  78. # test for <uid> <groupid>
  79. must_succeed ./auth 3 "${UID}" "${GROUPID}"
  80. must_fail ./auth 3 "${U2ID}" "${GROUPID}"
  81. # test for <userdn> <groupid>
  82. must_succeed ./auth 4 "${USERDN}" "${GROUPID}"
  83. must_fail ./auth 4 "${USER2DN}" "${GROUPID}"
  84. must_succeed ./auth 15 "${USERDN}" "${GROUPID}"
  85. must_fail ./auth 15 "${USER2DN}" "${GROUPID}"
  86. must_succeed ./auth 16 "{${USERDN}" "${GROUPID}"
  87. must_fail ./auth 16 "{${USER2DN}" "${GROUPID}"
  88. # test for <userdn> <attrFilter>
  89. must_succeed ./auth 5 "${USERDN}" "${ATTRFILTER}"
  90. must_fail ./auth 5 "${USERDN}" "${ATTR2FILTER}"
  91. must_fail ./auth 5 "${USER2DN}" "${ATTRFILTER}"
  92. # test for <uid> <attrFilter>
  93. must_succeed ./auth 6 "${UID}" "${ATTRFILTER}"
  94. must_fail ./auth 6 "${UID}" "${ATTR2FILTER}"
  95. must_fail ./auth 6 "${U2ID}" "${ATTRFILTER}"
  96. # test for <userdn> <password>
  97. must_succeed ./auth 7 "${USERDN}" "hillock"
  98. must_fail ./auth 7 "${USERDN}" "garbage"
  99. # test for <uid> <password>
  100. must_succeed ./auth 8 "${UID}" "hillock"
  101. must_fail ./auth 8 "${UID}" "garbage"
  102. #test for cert to ldap entry mapping
  103. must_succeed ./auth 9 "o=Ace Industry, c=US" "cn=Kirsten Vaughan, ou=Human Resources, o=Ace Industry, c=US"
  104. #must_fail ./auth 9 "default" "cn=Kirsten Vaughan, o=Ace Industry, c=US"
  105. # test for encode/decode bindpw
  106. must_succeed ./auth 10 "cn=Foo Bar, o=Fedora Project, c=US" "foobar"
  107. # test for reading dbnames from dbswitch.conf file
  108. must_succeed ./auth 11 dblist.conf ignore
  109. # test for saving certmap info
  110. must_succeed ./auth 12 certmap.new certmap.conf
  111. cat certmap.conf certmap.new 1>&2
  112. # test for delete certmap info
  113. must_succeed ./auth 13 certmap.new certmap.conf
  114. cat certmap.conf certmap.new 1>&2
  115. # test for add certmap info
  116. must_succeed ./auth 14 certmap.new certmap.conf
  117. cat certmap.conf certmap.new 1>&2