juniper-sso-auth 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh -efu
  2. #
  3. # Copyright © 2021 Joachim Kuebart <joachim.kuebart@gmail.com>
  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. FAKE_TOKEN="--token-mode=totp --token-secret=ABCD"
  28. echo "Testing Juniper SSO auth against fake server ..."
  29. ${srcdir}/fake-juniper-sso-server.py $ADDRESS 1443 $CERT $KEY >/dev/null 2>&1 &
  30. PID=$!
  31. wait_server $PID
  32. echo -n "Azure SSO with MFA. "
  33. (
  34. echo test |
  35. $OPENCONNECT \
  36. $FAKE_TOKEN \
  37. $FINGERPRINT \
  38. --cookieonly \
  39. --csd-wrapper ${srcdir}/fake-tncc.py \
  40. --protocol nc \
  41. --quiet \
  42. --user "test@example.com" \
  43. $ADDRESS:1443 \
  44. >/dev/null 2>&1
  45. ) ||
  46. fail $PID "Could not receive cookie from fake Juniper server"
  47. echo ok
  48. cleanup