From 6af1b82956f0d516cec7142d77d3d2c5b69c66a6 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Oct 11 2016 13:37:13 +0000 Subject: Add test helper for general settings updates Signed-off-by: Patrick Uiterwijk Reviewed-by: Pierre-Yves Chibon --- diff --git a/tests/helpers/http.py b/tests/helpers/http.py index 2fad577..6c5bf09 100755 --- a/tests/helpers/http.py +++ b/tests/helpers/http.py @@ -475,6 +475,30 @@ class HttpSessions(object): if r.status_code != 200: raise ValueError('Failed to post IDP data [%s]' % repr(r)) + def update_options(self, idp, relurl, options): + """ + Update options on a specific page. + + relurl must be the relative url to the admin page, not starting with /. + + options must be a dict of options to change. + """ + idpsrv = self.servers[idp] + idpuri = idpsrv['baseuri'] + + url = '%s%s/admin/%s' % ( + idpuri, self.get_idp_uri(idp), relurl) + headers = {'referer': url} + r = idpsrv['session'].post(url, data=options, headers=headers) + if r.status_code != 200: + raise ValueError('Failed to update settings [%s]' % repr(r)) + if not 'alert alert-success' in r.text: + raise Exception('No success message returned') + for key in options: + if options[key] not in r.text: + raise Exception('Option value %s (key %s) not found' % + (options[key], key)) + def enable_plugin(self, idp, plugtype, plugin): """ Enable a login stack plugin.