f5-auth-and-config 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. #
  3. # Copyright © 2021 Daniel Lenski
  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. srcdir=${srcdir:-.}
  22. top_builddir=${top_builddir:-..}
  23. . `dirname $0`/common.sh
  24. FINGERPRINT="--servercert=d66b507ae074d03b02eafca40d35f87dd81049d3"
  25. CERT=$certdir/server-cert.pem
  26. KEY=$certdir/server-key.pem
  27. echo "Testing F5 auth against fake server ..."
  28. OCSERV=${srcdir}/fake-f5-server.py
  29. launch_simple_sr_server $ADDRESS 443 $CERT $KEY > /dev/null 2>&1
  30. PID=$!
  31. wait_server $PID
  32. echo -n "Authenticating with username/password in the absence of an HTML login form... "
  33. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443/?no_html_login_form=1 -u test $FINGERPRINT --cookieonly >/dev/null 2>&1) ||
  34. fail $PID "Could not receive cookie from fake F5 server"
  35. echo ok
  36. echo -n "Authenticating with username/password... "
  37. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443 -u test $FINGERPRINT --cookieonly >/dev/null 2>&1) ||
  38. fail $PID "Could not receive cookie from fake F5 server"
  39. echo ok
  40. echo -n "Authenticating with username/password/authgroup... "
  41. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443/?domains=xyz,abc,def --authgroup=abc -u test $FINGERPRINT --cookieonly >/dev/null 2>&1) ||
  42. fail $PID "Could not receive cookie from fake F5 server"
  43. echo ok
  44. echo -n "Authenticating with username/password, then proceeding to tunnel stage... "
  45. echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443 -u test $FINGERPRINT >/dev/null 2>&1
  46. test $? = 2 || # what OpenConnect returns when server rejects cookie upon tunnel connection, as the fake server does
  47. fail $PID "Something went wrong in fake F5 server (other than the expected rejection of cookie)"
  48. echo ok
  49. cleanup
  50. exit 0