#131 Fix updating an OpenID Connect client and add test case to make sure it won't break
Merged 7 years ago by puiterwijk. Opened 7 years ago by puiterwijk.
puiterwijk/ipsilon fix-oidcupdate  into  master

@@ -106,7 +106,7 @@ 

                                     (name, value), severity=logging.DEBUG)

                  new_db_values[name] = value

  

-         client_id = kwargs['Client ID']

+         client_id = kwargs.get('Client ID')

          if self.new_client and client_id:

              if re.search(INVALID_IN_CLIENT_ID, client_id):

                  message = 'Invalid character in client ID'

@@ -62,8 +62,8 @@ 

              del client['ipsilon_internal']['client_id']

  

          info = {}

-         for key, datum in client:

-             info[key] = json.loads(datum)

+         for key in client:

+             info[key] = json.dumps(client[key])

  

          if client_id.startswith('D-'):

              # This is a dynamically registered client
@@ -71,7 +71,7 @@ 

              self.save_unique_data('client', {client_id: info})

          else:

              # This is a statically configured client

-             self.static_store.save_options('client', {client_id: info})

+             self.static_store.save_options('client', client_id, info)

Just above save_unique_data seems to take a dict, so is this expected?

Yes, this is a difference in API between save_unique_data and save_options.

  

      def getDynamicClients(self):

          clients = {}

file modified
+24
@@ -475,6 +475,30 @@ 

          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 'alert alert-success' not 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.

file modified
+11
@@ -262,6 +262,17 @@ 

          sys.exit(1)

      print " SUCCESS"

  

+     print "openidc: Update first SP client name ...",

+     try:

+         sess.update_options(

+             idpname,

+             'providers/openidc/admin/client/%s' % reg_resp['client_id'],

+             {'Client Name': 'Test suite client updated'})

+     except ValueError, e:

+         print >> sys.stderr, " ERROR: %s" % repr(e)

+         sys.exit(1)

+     print " SUCCESS"

+ 

      print "openidc: Retrieving token info ...",

      try:

          # Testing token without client auth

no initial comment

rebased

7 years ago

rebased

7 years ago

Just above save_unique_data seems to take a dict, so is this expected?

Yes, this is a difference in API between save_unique_data and save_options.

rebased

7 years ago

Pull-Request has been merged by puiterwijk

7 years ago