From d807d15f65e7a01dfb61e95a6cb20fd32ec00e81 Mon Sep 17 00:00:00 2001 From: David Douard Date: Fri, 30 Aug 2019 10:30:12 +0200 Subject: [PATCH] phabricator: randomly select the API token in the provided list instead of picking the first one, so this behavior is consistent with ListerHttpTransport's one. --- swh/lister/phabricator/lister.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swh/lister/phabricator/lister.py b/swh/lister/phabricator/lister.py index 83f4763..5fc750b 100644 --- a/swh/lister/phabricator/lister.py +++ b/swh/lister/phabricator/lister.py @@ -3,6 +3,7 @@ # See top-level LICENSE file for more information import logging +import random import urllib.parse @@ -49,11 +50,11 @@ class PhabricatorLister(IndexingHttpLister): password: """ - instance_creds = self.request_instance_credentials() - if not instance_creds: + creds = self.request_instance_credentials() + if not creds: raise ValueError( 'Phabricator forge needs authentication credential to list.') - api_token = instance_creds[0]['password'] + api_token = random.choice(creds)['password'] return {'headers': self.request_headers() or {}, 'params': {'api.token': api_token}}