Skip getting default headers without token

the session creation will fail with certificate and without the token
so it is better to skip it.

Change-Id: I306a07d8a869735a0b011eef9e43453ab132f00d
This commit is contained in:
asarfaty 2020-07-09 10:44:09 +02:00
parent 4d4c8a5568
commit 4b2d0d5fb3
1 changed files with 6 additions and 1 deletions

View File

@ -256,7 +256,12 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
LOG.error("Session create failed for endpoint %s due to "
"error in retrieving JSON Web Token: %s",
provider.url, e)
elif not session.cert_provider:
elif session.cert_provider:
# Session create will fail without token_provider, returning 403
LOG.debug("Skipping get_default_headers due to missing "
"token_provider")
return
else:
# With client certificate authentication, username and password
# may not be provided.
# If provided, backend treats these credentials as authentication