Skip to content

Commit 868df4c

Browse files
committed
fix: update unpriv client
1 parent d40269a commit 868df4c

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,29 @@ def unprivileged_client(
253253

254254
else:
255255
current_user = run_command(command=["oc", "whoami"])[1].strip()
256+
non_admin_user_name = non_admin_user_password[0]
256257

257258
if login_with_user_password(
258259
api_address=admin_client.configuration.host,
259-
user=non_admin_user_password[0],
260+
user=non_admin_user_name,
260261
password=non_admin_user_password[1],
261262
):
262263
with open(kubconfig_filepath) as fd:
263264
kubeconfig_content = yaml.safe_load(fd)
264265

265266
unprivileged_context = kubeconfig_content["current-context"]
266267

268+
unprivileged_client = get_client(config_file=kubconfig_filepath, context=unprivileged_context)
269+
267270
# Get back to admin account
268271
login_with_user_password(
269272
api_address=admin_client.configuration.host,
270273
user=current_user.strip(),
271274
)
272-
yield get_client(config_file=kubconfig_filepath, context=unprivileged_context)
275+
yield unprivileged_client
273276

274277
else:
278+
LOGGER.error(f"Failed to log in as user {non_admin_user_name}; logging in as admin user.")
275279
yield admin_client
276280

277281

utilities/infra.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def login_with_user_password(api_address: str, user: str, password: str | None =
330330

331331
_, out, _ = run_command(command=shlex.split(login_command), hide_log_command=True)
332332

333-
return "Login successful" in out
333+
if re.search(r"Login successful|Logged into", out):
334+
return True
335+
336+
return False
334337

335338

336339
@cache

0 commit comments

Comments
 (0)