Skip to content

Commit

Permalink
[6.15.z] Fix omitting credentials when CLI has already been instantia…
Browse files Browse the repository at this point in the history
…ted (#14880)

Fix omitting credentials when CLI has already been instantiated (#14449)

* Fix omitting credentials when CLI has already been instantiated

* Rework based on comments

* Set to False after yield

(cherry picked from commit 845ef03)

Co-authored-by: Lukáš Hellebrandt <[email protected]>
  • Loading branch information
Satellite-QE and lhellebr authored Apr 25, 2024
1 parent d318f96 commit f6e7f86
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,9 +1851,27 @@ def cli(self):

@contextmanager
def omit_credentials(self):
self.omitting_credentials = True
change = not self.omitting_credentials # if not already set to omit
if change:
self.omitting_credentials = True
# if CLI is already created
if self._cli._configured:
for name, obj in self._cli.__dict__.items():
with contextlib.suppress(
AttributeError
): # not everything has an mro method, we don't care about them
if Base in obj.mro():
getattr(self._cli, name).omitting_credentials = True
yield
self.omitting_credentials = False
if change:
self.omitting_credentials = False
if self._cli._configured:
for name, obj in self._cli.__dict__.items():
with contextlib.suppress(
AttributeError
): # not everything has an mro method, we don't care about them
if Base in obj.mro():
getattr(self._cli, name).omitting_credentials = False

@contextmanager
def ui_session(self, testname=None, user=None, password=None, url=None, login=True):
Expand Down

0 comments on commit f6e7f86

Please sign in to comment.