Skip to content

Updated the build to package AWSSDK.Extensions.CborProtocol and notice file updates. #3914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: muhamoth/DOTNET-8161-cbor-response-unmarshallers
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Notice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

** System.Text.Json
Expand Down Expand Up @@ -119,6 +120,34 @@ SOFTWARE.

----------------

** System.Formats.Cbor

The MIT License (MIT)

Copyright (c) .NET Foundation and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

** BouncyCastle.Cryptography

The MIT License (MIT)
Expand Down
30 changes: 30 additions & 0 deletions buildtools/NoticeForZips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

** System.Numerics.Vectors
Expand Down Expand Up @@ -116,6 +117,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

** System.Text.Json
Expand Down Expand Up @@ -146,6 +148,34 @@ SOFTWARE.

----------------

** System.Formats.Cbor

The MIT License (MIT)

Copyright (c) .NET Foundation and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

** BouncyCastle.Cryptography

The MIT License (MIT)
Expand Down
7 changes: 6 additions & 1 deletion buildtools/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
Command="$(powershell) -ExecutionPolicy Unrestricted -NoProfile -File create-nuget-packages.ps1 -PackageList "$(ServiceList)""/>
</Target>

<Target Name="package-extensions" DependsOnTargets="package-netcore-extensions;package-crt-extensions;package-cloudfront-extensions;package-ec2-extensions;package-meai-extensions;package-logging-extensions" />
<Target Name="package-extensions" DependsOnTargets="package-netcore-extensions;package-crt-extensions;package-cloudfront-extensions;package-ec2-extensions;package-meai-extensions;package-cborprotocol-extensions;package-logging-extensions" />

<Target Name="build-extensions" >
<!-- depends: restore-nuget;run-generator -->
Expand Down Expand Up @@ -509,6 +509,11 @@
<Exec Command="..\..\..\sdk\.nuget\NuGet.exe pack ./AWSSDK.Extensions.Bedrock.MEAI.nuspec -BasePath . -OutputDirectory ../../../Deployment/nuget" WorkingDirectory="../extensions/src/AWSSDK.Extensions.Bedrock.MEAI" />
</Target>

<Target Name="package-cborprotocol-extensions" DependsOnTargets="$(package-extensions-DependsOnTargets)">
<MakeDir Directories="../Deployment/nuget" />
<Exec Command="..\..\..\sdk\.nuget\NuGet.exe pack ./AWSSDK.Extensions.CborProtocol.nuspec -BasePath . -OutputDirectory ../../../Deployment/nuget" WorkingDirectory="../extensions/src/AWSSDK.Extensions.CborProtocol" />
</Target>

<Target Name="package-logging-extensions" DependsOnTargets="$(package-extensions-DependsOnTargets)">
<MakeDir Directories="../Deployment/nuget" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>AWSSDK.Extensions.CborProtocol</id>
<title>AWSSDK - Extensions for Cbor protocol support</title>
<version>4.0.0.0</version>
<authors>Amazon Web Services</authors>
<description>This package contains shared serialization and deserialization logic for services that use Cbor protocol in the AWS SDK for .NET.</description>
<language>en-US</language>
<license type="expression">Apache-2.0</license>
<projectUrl>https://github.com/aws/aws-sdk-net/</projectUrl>
<tags>AWS Amazon aws-sdk-v4</tags>
<icon>images\AWSLogo.png</icon>
<dependencies>
<group targetFramework="net472">
<dependency id="AWSSDK.Core" version="4.0.0.0" />
<dependency id="System.Formats.Cbor" version="9.0.5" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="AWSSDK.Core" version="4.0.0.0" />
<dependency id="System.Formats.Cbor" version="9.0.5" />
</group>
<group targetFramework="netcoreapp3.1">
<dependency id="AWSSDK.Core" version="4.0.0.0" />
<dependency id="System.Formats.Cbor" version="9.0.5" />
</group>
<group targetFramework="net8.0">
<dependency id="AWSSDK.Core" version="4.0.0.0" />
<dependency id="System.Formats.Cbor" version="9.0.5" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\..\..\sdk\nuget-content\AWSLogo.png" target="images\" />

<file src=".\bin\Release\net472\AWSSDK.Extensions.CborProtocol.dll" target="lib\net472" />
<file src=".\bin\Release\net472\AWSSDK.Extensions.CborProtocol.pdb" target="lib\net472" />
<file src=".\bin\Release\net472\AWSSDK.Extensions.CborProtocol.xml" target="lib\net472" />

<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.CborProtocol.dll" target="lib\netstandard2.0"/>
<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.CborProtocol.pdb" target="lib\netstandard2.0"/>
<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.CborProtocol.xml" target="lib\netstandard2.0" />

<file src=".\bin\Release\netcoreapp3.1\AWSSDK.Extensions.CborProtocol.dll" target="lib\netcoreapp3.1" />
<file src=".\bin\Release\netcoreapp3.1\AWSSDK.Extensions.CborProtocol.pdb" target="lib\netcoreapp3.1" />
<file src=".\bin\Release\netcoreapp3.1\AWSSDK.Extensions.CborProtocol.xml" target="lib\netcoreapp3.1" />

<file src=".\bin\Release\net8.0\AWSSDK.Extensions.CborProtocol.dll" target="lib\net8.0" />
<file src=".\bin\Release\net8.0\AWSSDK.Extensions.CborProtocol.pdb" target="lib\net8.0" />
<file src=".\bin\Release\net8.0\AWSSDK.Extensions.CborProtocol.xml" target="lib\net8.0" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void addServiceProtocolSpecificImports() {
writer.addImport(serviceName, "System.Xml");
writer.addImport(serviceName, "System.Xml.Linq");
} else if (this.serviceName.toLowerCase().contains("rpcv2")) {
writer.addImport(serviceName, "AWSSDK.Extensions.CborProtocol.Internal");
writer.addImport(serviceName, "AWSSDK.Extensions.CborProtocol.Internal.Transform");
}
}

Expand Down Expand Up @@ -151,7 +151,10 @@ private void arrangeResponseTestBlock(HttpResponseTestCase httpResponseTestCase)
for (var header : httpResponseTestCase.getHeaders().keySet()) {
writer.write("webResponseData.Headers[$S] = $S;", header, httpResponseTestCase.getHeaders().get(header));
}
writer.write("byte[] bytes = Encoding.ASCII.GetBytes($S);", httpResponseTestCase.getBody());
if (this.marshallerType.equals("Cbor"))
writer.write("byte[] bytes = Convert.FromBase64String($S);", httpResponseTestCase.getBody());
else
writer.write("byte[] bytes = Encoding.ASCII.GetBytes($S);", httpResponseTestCase.getBody());
writer.write("var stream = new MemoryStream(bytes);");
writer.write("var context = new $LUnmarshallerContext(stream,true,webResponseData);", marshallerType);
}
Expand Down Expand Up @@ -311,8 +314,7 @@ private void generateResponseTests(OperationShape operation) {
setMarshallerType(trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName());
}
for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()) || httpResponseTestCase.hasTag("defaults")
|| trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName().toLowerCase().contains("cbor")) // Skip CBOR response tests until the unmarshallers are ready
if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()) || httpResponseTestCase.hasTag("defaults"))
continue;
generateResponseTest(operation, httpResponseTestCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/*
* Do not modify this file. This file is generated.
*/
using AWSSDK.Extensions.CborProtocol.Internal;
using AWSSDK.Extensions.CborProtocol.Internal.Transform;
using AWSSDK.ProtocolTests;
using AWSSDK.ProtocolTests.Utils;
using AWSSDK_DotNet.UnitTests.TestTools;
Expand All @@ -31,6 +31,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace AWSSDK.ProtocolTests.RpcV2Protocol
Expand Down Expand Up @@ -72,5 +73,66 @@ public void empty_inputRequest()
Assert.IsFalse(marshalledRequest.Headers.ContainsKey("X-Amz-Target"));
}

/// <summary>
/// When output structure is empty we write CBOR equivalent of {}
/// </summary>
[TestMethod]
[TestCategory("ProtocolTest")]
[TestCategory("ResponseTest")]
[TestCategory("RpcV2Protocol")]
public void empty_outputResponse()
{
// Arrange
var webResponseData = new WebResponseData();
webResponseData.StatusCode = (HttpStatusCode)Enum.ToObject(typeof(HttpStatusCode), 200);
webResponseData.Headers["Content-Type"] = "application/cbor";
webResponseData.Headers["smithy-protocol"] = "rpc-v2-cbor";
byte[] bytes = Convert.FromBase64String("v/8=");
var stream = new MemoryStream(bytes);
var context = new CborUnmarshallerContext(stream,true,webResponseData);

// Act
var unmarshalledResponse = new EmptyInputOutputResponseUnmarshaller().Unmarshall(context);
var expectedResponse = new EmptyInputOutputResponse
{
};

// Assert
var actualResponse = (EmptyInputOutputResponse)unmarshalledResponse;
Comparer.CompareObjects<EmptyInputOutputResponse>(expectedResponse,actualResponse);
Assert.AreEqual((HttpStatusCode)Enum.ToObject(typeof(HttpStatusCode), 200), context.ResponseData.StatusCode);
}

/// <summary>
/// When output structure is empty the client should accept an empty
/// body
/// </summary>
[TestMethod]
[TestCategory("ProtocolTest")]
[TestCategory("ResponseTest")]
[TestCategory("RpcV2Protocol")]
public void empty_output_no_bodyResponse()
{
// Arrange
var webResponseData = new WebResponseData();
webResponseData.StatusCode = (HttpStatusCode)Enum.ToObject(typeof(HttpStatusCode), 200);
webResponseData.Headers["Content-Type"] = "application/cbor";
webResponseData.Headers["smithy-protocol"] = "rpc-v2-cbor";
byte[] bytes = Convert.FromBase64String("");
var stream = new MemoryStream(bytes);
var context = new CborUnmarshallerContext(stream,true,webResponseData);

// Act
var unmarshalledResponse = new EmptyInputOutputResponseUnmarshaller().Unmarshall(context);
var expectedResponse = new EmptyInputOutputResponse
{
};

// Assert
var actualResponse = (EmptyInputOutputResponse)unmarshalledResponse;
Comparer.CompareObjects<EmptyInputOutputResponse>(expectedResponse,actualResponse);
Assert.AreEqual((HttpStatusCode)Enum.ToObject(typeof(HttpStatusCode), 200), context.ResponseData.StatusCode);
}

}
}
Loading