]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
test multi-domain logins in F5 tests
authorDaniel Lenski <dlenski@gmail.com>
Tue, 23 Feb 2021 04:56:39 +0000 (20:56 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 29 Mar 2021 03:57:25 +0000 (20:57 -0700)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
tests/f5-auth-and-config
tests/fake-f5-server.py

index c70eeb7690ca2e70d499f622afec8f6e2db02f8c..fb900cc584bb1c9087d60642d0f9d9e5aab8ba13 100755 (executable)
@@ -41,6 +41,12 @@ echo -n "Authenticating with username/password... "
 
 echo ok
 
+echo -n "Authenticating with username/password/authgroup... "
+( 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) ||
+    fail $PID "Could not receive cookie from fake F5 server"
+
+echo ok
+
 echo -n "Authenticating with username/password, then proceeding to tunnel stage... "
 echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --protocol=f5 -q $ADDRESS:443 -u test $FINGERPRINT >/dev/null 2>&1
 test $? = 2 || # what OpenConnect returns when server rejects cookie upon tunnel connection, as the fake server does
index 88a5eb69a38cab3758e6fa302ab1f6945f8ca5df..b37b22a537a4bdad10726d289da43a017c7ee2f2 100755 (executable)
@@ -78,9 +78,11 @@ def check_form_against_session(*fields, use_query=False):
 ########################################
 
 # Respond to initial 'GET /' with a redirect to '/my.policy'
+# [Save list of domains/authgroups in the session for use later]
 @app.route('/')
 def root():
-    session.update(step='initial-GET')
+    domains = request.args.get('domains')
+    session.update(step='initial-GET', domains=domains and domains.split(','))
     # print(session)
     return redirect(url_for('get_policy'))
 
@@ -89,18 +91,29 @@ def root():
 @app.route('/my.policy')
 def get_policy():
     session.update(step='GET-login-form')
+    domains = session.get('domains')
+    sel = ''
+    if domains:
+        sel = '<select name="domain">%s</select>' % ''.join(
+            '<option value="%d">%s</option>' % nv for nv in enumerate(domains))
+
     return '''
 <html><body><form id="auth_form" method="post">
 <input type="text" name="username"/>
 <input type="password" name="password"/>
-</form></body></html>'''
+%s</form></body></html>''' % sel
 
 
 # Respond to 'POST /my.policy with a redirect response containing MRHSession and F5_ST
 # cookies (OpenConnect uses the combination of the two to detect successful authentication)
 @app.route('/my.policy', methods=['POST'])
 def post_policy():
-    session.update(step='POST-login', username=request.form.get('username'), credential=request.form.get('password'))
+    domains = session.get('domains')
+    if domains:
+        assert 0 <= int(request.form.get('domain',-1)) < len(domains)
+    session.update(step='POST-login', username=request.form.get('username'),
+                   credential=request.form.get('password'),
+                   domain=request.form.get('domain'))
     # print(session)
 
     resp = redirect(url_for('webtop'))