-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fd7108
commit 183092b
Showing
8 changed files
with
154 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
MAX_IAM_KEYS_PER_USER: 2 | ||
ARBORIST_URL: http://test-arborist-server | ||
TES_SERVER_URL: http://external-tes-server/tes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
from gen3workflow.aws_utils import get_iam_user_name | ||
from gen3workflow.config import config | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def reset_config_hostname(): | ||
original_hostname = config["HOSTNAME"] | ||
yield | ||
config["HOSTNAME"] = original_hostname | ||
|
||
|
||
def test_get_iam_user_name(reset_config_hostname): | ||
user_id = "asdfgh" | ||
|
||
# test a hostname with a `.`; it should be replaced by a `-` | ||
config["HOSTNAME"] = "qwert.qwert" | ||
escaped_shortened_hostname = "qwert-qwert" | ||
iam_user_id = get_iam_user_name(user_id) | ||
assert len(iam_user_id) < 64 | ||
assert iam_user_id == f"gen3wf-{escaped_shortened_hostname}-{user_id}" | ||
|
||
# test with a hostname that would result in a name longer than the max (64 chars) | ||
config["HOSTNAME"] = ( | ||
"qwertqwert.qwertqwert.qwertqwert.qwertqwert.qwertqwert.qwertqwert" | ||
) | ||
escaped_shortened_hostname = "qwertqwert-qwertqwert-qwertqwert-qwertqwert-qwertq" | ||
iam_user_id = get_iam_user_name(user_id) | ||
assert len(iam_user_id) == 64 | ||
assert iam_user_id == f"gen3wf-{escaped_shortened_hostname}-{user_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters