Skip to content

Commit

Permalink
Fix Null And Empty Headers Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrsongg committed Sep 10, 2024
1 parent d74b086 commit 0d9e73a
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,11 @@ private ProtocolTestCustomizations() {
"QueryQueryXmlMapsXmlName",
"QueryQueryFlattenedXmlMapWithXmlName",
"QueryQueryFlattenedXmlMapWithXmlNamespace",
"RestXmlXmlMapWithXmlNamespace",
// the .NET SDK will not support these tests as the service should be sending back valid xml in the response even if
// the response is empty. Net's built-in xml serializer throws an exception if no root element is present.
"QueryEmptyInputAndEmptyOutput",
"QueryNoInputAndNoOutput",
"QueryNoInputAndOutput",
"RestXmlXmlMapWithXmlNamespace",
// something in v4 broke the the test below. we should investigate and fix it.
"RestJsonNullAndEmptyHeaders",
"NullAndEmptyHeaders"
"QueryNoInputAndOutput"
);
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ namespace <#=this.Config.Namespace#>.Model
{
#>
return this.<#=member.VariableName#>.HasValue;
<#
}
else if (member.IsList && (member.MarshallLocation == MarshallLocation.Header || member.MarshallLocation == MarshallLocation.Headers))
{
// see protocol test https://github.com/smithy-lang/smithy/blob/8418149c69be6e6847dffae27e802730e8e40d49/smithy-aws-protocol-tests/model/restXml/http-headers.smithy#L369
// null or empty lists in headers should not be sent over the wire
#>
return this.<#=member.VariableName#> != null && this.<#=member.VariableName#>.Count > 0;
<#
}
else if (member.IsMap || member.IsList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ public class NullAndEmptyHeadersClient
/// Do not send null values, empty strings, or empty lists over the
/// wire in headers
/// </summary>
/*
* This test either requires a breaking change and will be addressed
* in V4, or has a backlog item to be fixed in the future. Please
* refer to the VNextTests list to see which it is.
* */
[Ignore]
[TestMethod]
[TestCategory("ProtocolTest")]
[TestCategory("RequestTest")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ public class NullAndEmptyHeadersClient
/// Do not send null values, empty strings, or empty lists over the
/// wire in headers
/// </summary>
/*
* This test either requires a breaking change and will be addressed
* in V4, or has a backlog item to be fixed in the future. Please
* refer to the VNextTests list to see which it is.
* */
[Ignore]
[TestMethod]
[TestCategory("ProtocolTest")]
[TestCategory("RequestTest")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<bool> HeaderBooleanList
// Check to see if HeaderBooleanList property is set
internal bool IsSetHeaderBooleanList()
{
return this._headerBooleanList != null && (this._headerBooleanList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerBooleanList != null && this._headerBooleanList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -127,7 +127,7 @@ public List<string> HeaderEnumList
// Check to see if HeaderEnumList property is set
internal bool IsSetHeaderEnumList()
{
return this._headerEnumList != null && (this._headerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerEnumList != null && this._headerEnumList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -202,7 +202,7 @@ public List<int> HeaderIntegerEnumList
// Check to see if HeaderIntegerEnumList property is set
internal bool IsSetHeaderIntegerEnumList()
{
return this._headerIntegerEnumList != null && (this._headerIntegerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerEnumList != null && this._headerIntegerEnumList.Count > 0;
}

/// <summary>
Expand All @@ -217,7 +217,7 @@ public List<int> HeaderIntegerList
// Check to see if HeaderIntegerList property is set
internal bool IsSetHeaderIntegerList()
{
return this._headerIntegerList != null && (this._headerIntegerList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerList != null && this._headerIntegerList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -277,7 +277,7 @@ public List<string> HeaderStringList
// Check to see if HeaderStringList property is set
internal bool IsSetHeaderStringList()
{
return this._headerStringList != null && (this._headerStringList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringList != null && this._headerStringList.Count > 0;
}

/// <summary>
Expand All @@ -292,7 +292,7 @@ public List<string> HeaderStringSet
// Check to see if HeaderStringSet property is set
internal bool IsSetHeaderStringSet()
{
return this._headerStringSet != null && (this._headerStringSet.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringSet != null && this._headerStringSet.Count > 0;
}

/// <summary>
Expand All @@ -307,7 +307,7 @@ public List<DateTime> HeaderTimestampList
// Check to see if HeaderTimestampList property is set
internal bool IsSetHeaderTimestampList()
{
return this._headerTimestampList != null && (this._headerTimestampList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerTimestampList != null && this._headerTimestampList.Count > 0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<bool> HeaderBooleanList
// Check to see if HeaderBooleanList property is set
internal bool IsSetHeaderBooleanList()
{
return this._headerBooleanList != null && (this._headerBooleanList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerBooleanList != null && this._headerBooleanList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -125,7 +125,7 @@ public List<string> HeaderEnumList
// Check to see if HeaderEnumList property is set
internal bool IsSetHeaderEnumList()
{
return this._headerEnumList != null && (this._headerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerEnumList != null && this._headerEnumList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -200,7 +200,7 @@ public List<int> HeaderIntegerEnumList
// Check to see if HeaderIntegerEnumList property is set
internal bool IsSetHeaderIntegerEnumList()
{
return this._headerIntegerEnumList != null && (this._headerIntegerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerEnumList != null && this._headerIntegerEnumList.Count > 0;
}

/// <summary>
Expand All @@ -215,7 +215,7 @@ public List<int> HeaderIntegerList
// Check to see if HeaderIntegerList property is set
internal bool IsSetHeaderIntegerList()
{
return this._headerIntegerList != null && (this._headerIntegerList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerList != null && this._headerIntegerList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -275,7 +275,7 @@ public List<string> HeaderStringList
// Check to see if HeaderStringList property is set
internal bool IsSetHeaderStringList()
{
return this._headerStringList != null && (this._headerStringList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringList != null && this._headerStringList.Count > 0;
}

/// <summary>
Expand All @@ -290,7 +290,7 @@ public List<string> HeaderStringSet
// Check to see if HeaderStringSet property is set
internal bool IsSetHeaderStringSet()
{
return this._headerStringSet != null && (this._headerStringSet.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringSet != null && this._headerStringSet.Count > 0;
}

/// <summary>
Expand All @@ -305,7 +305,7 @@ public List<DateTime> HeaderTimestampList
// Check to see if HeaderTimestampList property is set
internal bool IsSetHeaderTimestampList()
{
return this._headerTimestampList != null && (this._headerTimestampList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerTimestampList != null && this._headerTimestampList.Count > 0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<bool> HeaderBooleanList
// Check to see if HeaderBooleanList property is set
internal bool IsSetHeaderBooleanList()
{
return this._headerBooleanList != null && (this._headerBooleanList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerBooleanList != null && this._headerBooleanList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -125,7 +125,7 @@ public List<string> HeaderEnumList
// Check to see if HeaderEnumList property is set
internal bool IsSetHeaderEnumList()
{
return this._headerEnumList != null && (this._headerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerEnumList != null && this._headerEnumList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -185,7 +185,7 @@ public List<int> HeaderIntegerList
// Check to see if HeaderIntegerList property is set
internal bool IsSetHeaderIntegerList()
{
return this._headerIntegerList != null && (this._headerIntegerList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerList != null && this._headerIntegerList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -245,7 +245,7 @@ public List<string> HeaderStringList
// Check to see if HeaderStringList property is set
internal bool IsSetHeaderStringList()
{
return this._headerStringList != null && (this._headerStringList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringList != null && this._headerStringList.Count > 0;
}

/// <summary>
Expand All @@ -260,7 +260,7 @@ public List<string> HeaderStringSet
// Check to see if HeaderStringSet property is set
internal bool IsSetHeaderStringSet()
{
return this._headerStringSet != null && (this._headerStringSet.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringSet != null && this._headerStringSet.Count > 0;
}

/// <summary>
Expand All @@ -275,7 +275,7 @@ public List<DateTime> HeaderTimestampList
// Check to see if HeaderTimestampList property is set
internal bool IsSetHeaderTimestampList()
{
return this._headerTimestampList != null && (this._headerTimestampList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerTimestampList != null && this._headerTimestampList.Count > 0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public List<bool> HeaderBooleanList
// Check to see if HeaderBooleanList property is set
internal bool IsSetHeaderBooleanList()
{
return this._headerBooleanList != null && (this._headerBooleanList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerBooleanList != null && this._headerBooleanList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -123,7 +123,7 @@ public List<string> HeaderEnumList
// Check to see if HeaderEnumList property is set
internal bool IsSetHeaderEnumList()
{
return this._headerEnumList != null && (this._headerEnumList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerEnumList != null && this._headerEnumList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -183,7 +183,7 @@ public List<int> HeaderIntegerList
// Check to see if HeaderIntegerList property is set
internal bool IsSetHeaderIntegerList()
{
return this._headerIntegerList != null && (this._headerIntegerList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerIntegerList != null && this._headerIntegerList.Count > 0;
}

/// <summary>
Expand Down Expand Up @@ -243,7 +243,7 @@ public List<string> HeaderStringList
// Check to see if HeaderStringList property is set
internal bool IsSetHeaderStringList()
{
return this._headerStringList != null && (this._headerStringList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringList != null && this._headerStringList.Count > 0;
}

/// <summary>
Expand All @@ -258,7 +258,7 @@ public List<string> HeaderStringSet
// Check to see if HeaderStringSet property is set
internal bool IsSetHeaderStringSet()
{
return this._headerStringSet != null && (this._headerStringSet.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerStringSet != null && this._headerStringSet.Count > 0;
}

/// <summary>
Expand All @@ -273,7 +273,7 @@ public List<DateTime> HeaderTimestampList
// Check to see if HeaderTimestampList property is set
internal bool IsSetHeaderTimestampList()
{
return this._headerTimestampList != null && (this._headerTimestampList.Count > 0 || !AWSConfigs.InitializeCollections);
return this._headerTimestampList != null && this._headerTimestampList.Count > 0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<string> C
// Check to see if C property is set
internal bool IsSetC()
{
return this._c != null && (this._c.Count > 0 || !AWSConfigs.InitializeCollections);
return this._c != null && this._c.Count > 0;
}

}
Expand Down

0 comments on commit 0d9e73a

Please sign in to comment.