Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit dad0b1f

Browse files
committed
update fixture to allow for username input and update to wait for user to be created
1 parent 2417384 commit dad0b1f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

localstack-core/localstack/testing/pytest/fixtures.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
LocalAttribute,
3434
)
3535
from localstack.testing.aws.cloudformation_utils import load_template_file, render_template
36-
from localstack.testing.aws.util import get_lambda_logs, is_aws_cloud
36+
from localstack.testing.aws.util import get_lambda_logs, is_aws_cloud, wait_for_user
3737
from localstack.testing.config import (
3838
SECONDARY_TEST_AWS_ACCOUNT_ID,
3939
SECONDARY_TEST_AWS_REGION_NAME,
@@ -2396,13 +2396,15 @@ def _create_role_with_policy(
23962396

23972397

23982398
@pytest.fixture
2399-
def create_user_with_policy(create_policy_generated_document, create_user, aws_client):
2400-
def _create_user_with_policy(effect, actions, resource=None):
2399+
def create_user_with_policy(create_policy_generated_document, create_user, aws_client, region_name):
2400+
def _create_user_with_policy(effect, actions, resource=None, user_name=None):
24012401
policy_arn = create_policy_generated_document(effect, actions, resource=resource)
2402-
username = f"user-{short_uid()}"
2402+
username = user_name or f"user-{short_uid()}"
24032403
create_user(UserName=username)
24042404
aws_client.iam.attach_user_policy(UserName=username, PolicyArn=policy_arn)
24052405
keys = aws_client.iam.create_access_key(UserName=username)["AccessKey"]
2406+
2407+
wait_for_user(keys=keys, region_name=region_name)
24062408
return username, keys
24072409

24082410
return _create_user_with_policy

0 commit comments

Comments
 (0)