Repository: getmoto/moto
Pull request #6472 (2023-07-01 21:50:19)

CF:create_distribution() - fix config with single alias
If there is only 1 alias, it would be serialized as a string (`"alias1"`), instead of as a list (`["alias1"]`). 

When generating the response, we expect a list of aliases to iterate over. So if we're iterating over a string instead, Moto would return `Aliases=["a", "l", "i", "a", "s"]` instead

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getmoto/moto/pull/6472?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) Report
> Merging [#6472](https://app.codecov.io/gh/getmoto/moto/pull/6472?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (e1f9b42) into [master](https://app.codecov.io/gh/getmoto/moto/commit/2d608ecd226f205de22d8b8d4f3e58639ba850af?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (2d608ec) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master    #6472   +/-   ##
=======================================
  Coverage   96.18%   96.18%           
=======================================
  Files         800      800           
  Lines       78523    78525    +2     
=======================================
+ Hits        75524    75526    +2     
  Misses       2999     2999           
```

| Flag | Coverage Δ | |
|---|---|---|
| servertests | `36.87% <0.00%> (-0.01%)` | :arrow_down: |
| unittests | `96.12% <100.00%> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://app.codecov.io/gh/getmoto/moto/pull/6472?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | |
|---|---|---|
| [moto/cloudfront/models.py](https://app.codecov.io/gh/getmoto/moto/pull/6472?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#diff-bW90by9jbG91ZGZyb250L21vZGVscy5weQ==) | `98.56% <100.00%> (+0.01%)` | :arrow_up: |



Patch:
diff --git a/moto/cloudfront/models.py b/moto/cloudfront/models.py
index 5f54f0cb9..18713890c 100644
--- a/moto/cloudfront/models.py
+++ b/moto/cloudfront/models.py
@@ -148,6 +148,8 @@ class DistributionConfig:
         self.aliases = ((config.get("Aliases") or {}).get("Items") or {}).get(
             "CNAME"
         ) or []
+        if isinstance(self.aliases, str):
+            self.aliases = [self.aliases]
         self.comment = config.get("Comment") or ""
         self.default_cache_behavior = DefaultCacheBehaviour(
             config["DefaultCacheBehavior"]


Test patch:
diff --git a/other_langs/tests_java/pom.xml b/other_langs/tests_java/pom.xml
index c97055aa9..34c24b111 100644
--- a/other_langs/tests_java/pom.xml
+++ b/other_langs/tests_java/pom.xml
@@ -22,7 +22,7 @@
     <dependency>
       <groupId>software.amazon.awssdk</groupId>
       <artifactId>bom</artifactId>
-      <version>2.20.77</version>
+      <version>2.20.97</version>
       <type>pom</type>
       <scope>import</scope>
     </dependency>
@@ -70,7 +70,7 @@
         <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
         <plugin>
           <artifactId>maven-clean-plugin</artifactId>
-          <version>3.2.0</version>
+          <version>3.3.1</version>
         </plugin>
         <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
         <plugin>
@@ -83,7 +83,7 @@
         </plugin>
         <plugin>
           <artifactId>maven-surefire-plugin</artifactId>
-          <version>3.1.0</version>
+          <version>3.1.2</version>
         </plugin>
         <plugin>
           <artifactId>maven-jar-plugin</artifactId>
@@ -104,7 +104,7 @@
         </plugin>
         <plugin>
           <artifactId>maven-project-info-reports-plugin</artifactId>
-          <version>3.4.4</version>
+          <version>3.4.5</version>
         </plugin>
       </plugins>
     </pluginManagement>
diff --git a/tests/test_cloudfront/test_cloudfront_distributions.py b/tests/test_cloudfront/test_cloudfront_distributions.py
index c35376900..962839823 100644
--- a/tests/test_cloudfront/test_cloudfront_distributions.py
+++ b/tests/test_cloudfront/test_cloudfront_distributions.py
@@ -287,12 +287,15 @@ def test_create_distribution_with_origins():
 @pytest.mark.parametrize("qs", [True, False])
 @pytest.mark.parametrize("smooth", [True, False])
 @pytest.mark.parametrize("ipv6", [True, False])
-def test_create_distribution_with_additional_fields(compress, qs, smooth, ipv6):
+@pytest.mark.parametrize("aliases", [["alias1", "alias2"], ["alias1"]])
+def test_create_distribution_with_additional_fields(
+    compress, qs, smooth, ipv6, aliases
+):
     client = boto3.client("cloudfront", region_name="us-west-1")
 
     config = scaffold.example_distribution_config("ref")
     config["IsIPV6Enabled"] = ipv6
-    config["Aliases"] = {"Quantity": 2, "Items": ["alias1", "alias2"]}
+    config["Aliases"] = {"Quantity": 2, "Items": aliases}
     config["DefaultCacheBehavior"]["ForwardedValues"]["Cookies"] = {
         "Forward": "whitelist",
         "WhitelistedNames": {"Quantity": 1, "Items": ["x-amz-header"]},
@@ -306,9 +309,7 @@ def test_create_distribution_with_additional_fields(compress, qs, smooth, ipv6):
     distribution = resp["Distribution"]
     distribution.should.have.key("DistributionConfig")
     config = distribution["DistributionConfig"]
-    config.should.have.key("Aliases").equals(
-        {"Items": ["alias1", "alias2"], "Quantity": 2}
-    )
+    assert config["Aliases"] == {"Items": aliases, "Quantity": len(aliases)}
 
     config.should.have.key("PriceClass").equals("PriceClass_100")
     config.should.have.key("IsIPV6Enabled").equals(ipv6)