auth-username-pass 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2016 Red Hat, Inc.
  4. #
  5. # This file is part of openconnect.
  6. #
  7. # This is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public License
  9. # as published by the Free Software Foundation; either version 2.1 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>
  19. # This test uses LD_PRELOAD
  20. PRELOAD=1
  21. SERV="${SERV:-../src/ocserv}"
  22. srcdir=${srcdir:-.}
  23. top_builddir=${top_builddir:-..}
  24. . `dirname $0`/common.sh
  25. echo "Testing certificate auth..."
  26. launch_simple_sr_server -d 1 -f -c configs/test-user-pass.config
  27. PID=$!
  28. wait_server $PID
  29. echo -n "Connecting to obtain cookie... "
  30. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1) ||
  31. fail $PID "Could not receive cookie from server"
  32. echo ok
  33. echo -n "Connecting to obtain cookie with wrong password... "
  34. ( echo "tost" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1) &&
  35. fail $PID "Received cookie when we shouldn't"
  36. echo ok
  37. #test special characters
  38. echo -n "Connecting to obtain cookie... "
  39. ( echo "!@#$%^&*()<>" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u "sp@c/al" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) ||
  40. fail $PID "Could not receive cookie from server"
  41. echo ok
  42. echo -n "Connecting to obtain cookie with empty password... "
  43. ( echo "" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u "empty" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) ||
  44. fail $PID "Could not receive cookie from server"
  45. echo ok
  46. cleanup
  47. exit 0