Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b362382
Create size-labeler.yml
rnetser Dec 18, 2024
3c6a875
Delete .github/workflows/size-labeler.yml
rnetser Dec 18, 2024
ccb63af
Merge branch 'main' of github.com:rnetser/opendatahub-tests
rnetser Dec 24, 2024
da0c898
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 25, 2024
94a82ec
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 26, 2024
c0c82dd
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 27, 2024
5feb447
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 30, 2024
19b9c56
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
e22ac1a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
56ab9c5
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
5a17f03
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
ef5fe65
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
1875a44
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 1, 2025
840d442
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 2, 2025
c0d4436
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 2, 2025
ba7971a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 3, 2025
fd73a94
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 7, 2025
bde0493
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 8, 2025
d3cd799
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 9, 2025
710befa
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 12, 2025
a662364
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 16, 2025
579c283
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 16, 2025
927cbb0
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 19, 2025
99e242e
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 22, 2025
5b83bab
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 24, 2025
4b5b007
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 27, 2025
b8e5dee
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 30, 2025
0039df0
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 30, 2025
17938d6
model mesh - add auth tests
rnetser Feb 2, 2025
44a3120
xx
rnetser Feb 2, 2025
a418727
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 3, 2025
d291c32
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 4, 2025
b6650d8
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 5, 2025
8b9f838
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 7, 2025
d53a04c
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 10, 2025
db89111
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 10, 2025
773d81a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 12, 2025
01be6e9
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 13, 2025
71df8d5
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 16, 2025
8896bd7
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 18, 2025
0eeb162
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 18, 2025
38e8a69
ci: on main upstream xxxxxxxxxxx
rnetser Feb 19, 2025
875f597
ci: reabsingxxxxxxxxxxxxxx
rnetser Feb 20, 2025
c90abf6
ci: reabsingxxxxxxxxxxxxxx
rnetser Feb 20, 2025
4a26346
ci: Merge branch 'main' of https://github.com/opendatahub-io/opendata…
rnetser Feb 24, 2025
8302ed1
ci: Merge branch 'main' of https://github.com/opendatahub-io/opendata…
rnetser Feb 25, 2025
ff1b155
ci: rebase on main
rnetser Mar 6, 2025
a04a3c4
ci: merge main branch
rnetser Mar 11, 2025
d1cb99b
ci: merge branch main
rnetser Mar 12, 2025
87faa7b
ci: merge branch main
rnetser Mar 17, 2025
dc8490d
ci: merge branch main
rnetser Mar 17, 2025
5856788
ci: merge main branch
rnetser Mar 18, 2025
a865aa8
ci: merge main branch
rnetser Mar 18, 2025
e8be67d
ci: merge main branch
rnetser Mar 18, 2025
e8c8b38
ci: merge main branch
rnetser Mar 20, 2025
667cb70
ci: merge main branch
rnetser Mar 20, 2025
a122d95
ci: merge main branch
rnetser Mar 20, 2025
defca5d
ci: merge main branch
rnetser Mar 21, 2025
d8879ae
ci: merge with main
rnetser Mar 24, 2025
a0477ca
ci: merge with main
rnetser Mar 24, 2025
0b37eb7
ci: merge with main
rnetser Mar 24, 2025
79b9288
ci: merge with main
rnetser Mar 24, 2025
3b9d6a1
ci: merge with main
rnetser Mar 25, 2025
a91c002
ci: merge with main
rnetser Mar 26, 2025
ba7a2a4
ci: merge main branch
rnetser Mar 27, 2025
7fd9c92
ci: merge main branch
rnetser Mar 27, 2025
96c2146
ci: merge main branch
rnetser Mar 31, 2025
dcdfc7a
ci: merge main branch
rnetser Mar 31, 2025
beaa1e5
ci: merge main branch
rnetser Apr 2, 2025
3c35249
ci: merge main branch
rnetser Apr 6, 2025
d40269a
ci: merge main branch
rnetser Apr 7, 2025
868df4c
fix: update unpriv client
rnetser Apr 7, 2025
9e1af2a
ci: merge main branch
rnetser Apr 7, 2025
b3b616d
fix: raise on un
rnetser Apr 8, 2025
326f00b
fix: raise on un
rnetser Apr 8, 2025
33f5da4
fix: remove test code
rnetser Apr 8, 2025
4091870
fix: fail on login
rnetser Apr 8, 2025
4bb5822
ci: merge main branch
rnetser Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from simple_logger.logger import get_logger

from utilities.data_science_cluster_utils import update_components_in_dsc
from utilities.exceptions import ClusterLoginError
from utilities.general import get_s3_secret_dict
from utilities.infra import (
create_ns,
Expand Down Expand Up @@ -246,33 +247,36 @@ def unprivileged_client(
non_admin_user_password: tuple[str, str],
) -> Generator[DynamicClient, Any, Any]:
"""
Provides none privileged API client. If non_admin_user_password is None, then it will yield admin_client.
Provides none privileged API client. If non_admin_user_password is None, then it will raise.
"""
if non_admin_user_password is None:
yield admin_client
raise ValueError("Unprivileged user not provisioned")

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

if login_with_user_password(
api_address=admin_client.configuration.host,
user=non_admin_user_password[0],
user=non_admin_user_name,
password=non_admin_user_password[1],
):
with open(kubconfig_filepath) as fd:
kubeconfig_content = yaml.safe_load(fd)

unprivileged_context = kubeconfig_content["current-context"]

unprivileged_client = get_client(config_file=kubconfig_filepath, context=unprivileged_context)

# Get back to admin account
login_with_user_password(
api_address=admin_client.configuration.host,
user=current_user.strip(),
)
yield get_client(config_file=kubconfig_filepath, context=unprivileged_context)
yield unprivileged_client

else:
yield admin_client
raise ClusterLoginError(user=non_admin_user_name)


@pytest.fixture(scope="session")
Expand Down
8 changes: 8 additions & 0 deletions utilities/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ class PodLogMissMatchError(Exception):

class ResourceMismatch(Exception):
pass


class ClusterLoginError(Exception):
def __init__(self, user: str):
self.user = user

def __str__(self) -> str:
return f"Failed to log in as user {self.user}."
12 changes: 9 additions & 3 deletions utilities/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from utilities.constants import ApiGroups, Labels, Timeout
from utilities.constants import KServeDeploymentType
from utilities.constants import Annotations
from utilities.exceptions import FailedPodsError
from utilities.exceptions import ClusterLoginError, FailedPodsError
from timeout_sampler import TimeoutExpiredError, TimeoutSampler, retry
import utilities.general

Expand Down Expand Up @@ -328,9 +328,15 @@ def login_with_user_password(api_address: str, user: str, password: str | None =
if password:
login_command += f" -p '{password}'"

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

return "Login successful" in out
if err and err.lower().startswith("error"):
raise ClusterLoginError(user=user)

if re.search(r"Login successful|Logged into", out):
return True

return False


@cache
Expand Down