Repository: getmoto/moto

Issue:
S3Control Access Points have different alias through create and get
When creating S3 Access Points, I do not have the same alias for the return value as from retrieving the alias through the get_access_point service.

Unit test that reproduces the issue:

```python
from moto import mock_s3control
import boto3

@mock_s3control
def test_access_point_alias():
    client = boto3.client("s3control")

    alias_from_create = client.create_access_point(
        AccountId="123456789012",
        Name="my-access-point",
        Bucket="MyBucket",
    )["Alias"]

    alias_from_get = client.get_access_point(
        AccountId="123456789012",
        Name="my-access-point",
    )["Alias"]

    assert alias_from_create == alias_from_get
```

Result of the test:

```
>       assert alias_from_create == alias_from_get
E       AssertionError: assert 'my-access-point' == 'my-access-point-0423644bbfcb450d25cff9902b19454dbb-s3alias'
```

I would expect this unit test to pass.

Version of Moto: 4.2.6
Version boto3: 1.28.2
Version of botocore: 1.31.2



Discussion:
Thanks for raising this @davidshay, that looks indeed like a bug.

Will raise a PR shortly.

Resolving patch:
diff --git a/moto/s3control/responses.py b/moto/s3control/responses.py
--- a/moto/s3control/responses.py
+++ b/moto/s3control/responses.py
@@ -159,7 +159,7 @@ def _get_accountid_and_name_from_policy(self, full_url: str) -> Tuple[str, str]:
   <ResponseMetadata>
     <RequestId>1549581b-12b7-11e3-895e-1334aEXAMPLE</RequestId>
   </ResponseMetadata>
-  <Alias>{{ access_point.name }}</Alias>
+  <Alias>{{ access_point.alias }}</Alias>
   <AccessPointArn>{{ access_point.arn }}</AccessPointArn>
 </CreateAccessPointResult>
 """


Test patch:
diff --git a/.github/workflows/tests_real_aws.yml b/.github/workflows/tests_real_aws.yml
--- a/.github/workflows/tests_real_aws.yml
+++ b/.github/workflows/tests_real_aws.yml
@@ -42,4 +42,4 @@ jobs:
       env:
         MOTO_TEST_ALLOW_AWS_REQUEST: ${{ true }}
       run: |
-        pytest -sv tests/test_dynamodb/ tests/test_ec2/ tests/test_lakeformation/ tests/test_ses/ tests/test_s3 -m aws_verified
+        pytest -sv tests/test_dynamodb/ tests/test_ec2/ tests/test_lakeformation/ tests/test_ses/ tests/test_s3* -m aws_verified
diff --git a/tests/test_s3/__init__.py b/tests/test_s3/__init__.py
--- a/tests/test_s3/__init__.py
+++ b/tests/test_s3/__init__.py
@@ -1,7 +1,7 @@
 import boto3
 import os
 from functools import wraps
-from moto import mock_s3
+from moto import mock_s3, mock_sts, mock_s3control
 from moto.s3.responses import DEFAULT_REGION_NAME
 from uuid import uuid4
 
@@ -33,7 +33,7 @@ def pagination_wrapper():
             print(f"Test {func} will create {bucket_name}")
             resp = create_bucket_and_test(bucket_name, client)
         else:
-            with mock_s3():
+            with mock_s3(), mock_sts(), mock_s3control():
                 resp = create_bucket_and_test(bucket_name, client)
         return resp
 
diff --git a/tests/test_s3control/test_s3control_access_points.py b/tests/test_s3control/test_s3control_access_points.py
--- a/tests/test_s3control/test_s3control_access_points.py
+++ b/tests/test_s3control/test_s3control_access_points.py
@@ -4,18 +4,9 @@
 import pytest
 
 from botocore.client import ClientError
+from uuid import uuid4
 from moto import mock_s3control
-
-
-@mock_s3control
-def test_create_access_point():
-    client = boto3.client("s3control", region_name="eu-west-1")
-    resp = client.create_access_point(
-        AccountId="111111111111", Name="ap_name", Bucket="mybucket"
-    )
-
-    assert "AccessPointArn" in resp
-    assert resp["Alias"] == "ap_name"
+from tests.test_s3 import s3_aws_verified
 
 
 @mock_s3control
@@ -96,17 +87,31 @@ def test_get_access_point_full():
     }
 
 
-@mock_s3control
-def test_delete_access_point():
-    client = boto3.client("s3control", region_name="ap-southeast-1")
+@pytest.mark.aws_verified
+@s3_aws_verified
+def test_delete_access_point(bucket_name=None):
+    sts = boto3.client("sts", "us-east-1")
+    account_id = sts.get_caller_identity()["Account"]
 
-    client.create_access_point(
-        AccountId="111111111111", Name="ap_name", Bucket="mybucket"
+    client = boto3.client("s3control", region_name="us-east-1")
+    ap_name = "ap-" + str(uuid4())[0:6]
+    expected_arn = f"arn:aws:s3:us-east-1:{account_id}:accesspoint/{ap_name}"
+
+    create = client.create_access_point(
+        AccountId=account_id, Name=ap_name, Bucket=bucket_name
     )
+    assert create["Alias"].startswith(ap_name)
+    assert create["Alias"].endswith("-s3alias")
+    assert create["AccessPointArn"] == expected_arn
 
-    client.delete_access_point(AccountId="111111111111", Name="ap_name")
+    get = client.get_access_point(AccountId=account_id, Name=ap_name)
+    assert get["Alias"] == create["Alias"]
+    assert get["AccessPointArn"] == expected_arn
+
+    client.delete_access_point(AccountId=account_id, Name=ap_name)
 
     with pytest.raises(ClientError) as exc:
-        client.get_access_point(AccountId="111111111111", Name="ap_name")
+        client.get_access_point(AccountId=account_id, Name=ap_name)
     err = exc.value.response["Error"]
     assert err["Code"] == "NoSuchAccessPoint"
+    assert err["Message"] == "The specified accesspoint does not exist"