Skip to content

Commit

Permalink
update token propagate test for new token generation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed Sep 12, 2024
1 parent de2ce3b commit 34d1f5b
Show file tree
Hide file tree
Showing 3 changed files with 2,095 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TestLevels(str, enum.Enum):
MAXIMAL = "maximal"


DEFAULT_LEVEL = TestLevels.UNIT
DEFAULT_LEVEL = TestLevels.LOCAL

TEST_LEVEL_HIERARCHY = {
TestLevels.UNIT: 0,
Expand Down
19 changes: 10 additions & 9 deletions tests/test_resources/test_clusters/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,28 +417,29 @@ def test_changing_name_and_saving_in_between(self, cluster):

@pytest.mark.level("local")
@pytest.mark.clustertest
def test_caller_token_propagated(self, cluster):
def test_caller_token_propagated(self, docker_cluster_pk_ssh_no_auth):
cluster = docker_cluster_pk_ssh_no_auth
remote_assume_caller_and_get_token = rh.function(
assume_caller_and_get_token
).to(cluster)

remote_assume_caller_and_get_token.share(
users=["info@run.house"], notify_users=False
)
current_username = rh.configs.username
current_den_token = rh.configs.token

with friend_account():
unassumed_token, assumed_token = remote_assume_caller_and_get_token()
# "Local token" is the token the cluster accesses in rh.configs.token; this is what will be used
# in subsequent rns_client calls
assert assumed_token == rh.globals.rns_client.cluster_token(
cluster.rns_address,
username=current_username,
den_token=current_den_token,
)
assert unassumed_token != rh.configs.token

# Both tokens should be valid for the cluster
assert rh.globals.rns_client.validate_cluster_token(
assumed_token, cluster.rns_address
)
assert rh.globals.rns_client.validate_cluster_token(
unassumed_token, cluster.rns_address
)

# Docker clusters are logged out, ondemand clusters are logged in
output = cluster.run("sed -n 's/.*token: *//p' ~/.rh/config.yaml")
# No config file
Expand Down
Loading

0 comments on commit 34d1f5b

Please sign in to comment.