Skip to content

Commit

Permalink
restore changes from corrupted branch feat-protocol-test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws committed Aug 16, 2023
1 parent 7ecab86 commit 20cbae8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class AwsGoDependency {
null, Versions.INTERNAL_SIGV4A, "v4a");
public static final GoDependency S3_INTERNAL_ARN = aws("service/internal/s3shared/arn", "s3arn");
public static final GoDependency AWS_ARN = aws("aws/arn", "awsarn");

public static final GoDependency AWS_PROTOCOL_TEST_HTTP_CLIENT = aws("internal/protocoltest", "protocoltesthttp");

public static final GoDependency REGEXP = SmithyGoDependency.stdlib("regexp");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.Set;
import java.util.TreeSet;

import software.amazon.smithy.aws.go.codegen.customization.AwsCustomGoDependency;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.SmithyGoDependency;
Expand Down Expand Up @@ -98,96 +100,12 @@ static void generateHttpProtocolTests(GenerationContext context) {
inputConfigValues.add(HttpProtocolUnitTestGenerator.ConfigValue.builder()
.name(AddAwsConfigFields.HTTP_CLIENT_CONFIG_NAME)
.value(writer -> {
writer.addUseImports(AwsGoDependency.AWS_HTTP_TRANSPORT);
writer.write("awshttp.NewBuildableClient(),");
writer.addUseImports(AwsGoDependency.AWS_PROTOCOL_TEST_HTTP_CLIENT);
writer.write("protocoltesthttp.NewClient(),");
})
.build());

Set<HttpProtocolUnitTestGenerator.SkipTest> inputSkipTests = new TreeSet<>(SetUtils.of(
// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
.operation(ShapeId.from("aws.protocoltests.restjson#EndpointOperation"))
.addTestName("RestJsonEndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restjson#RestJson"))
.operation(ShapeId.from("aws.protocoltests.restjson#EndpointWithHostLabelOperation"))
.addTestName("RestJsonEndpointTraitWithHostLabel")
.build(),

// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.ec2#AwsEc2"))
.operation(ShapeId.from("aws.protocoltests.ec2#EndpointOperation"))
.addTestName("Ec2QueryEndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.ec2#AwsEc2"))
.operation(ShapeId.from("aws.protocoltests.ec2#EndpointWithHostLabelOperation"))
.addTestName("Ec2QueryEndpointTraitWithHostLabel")
.build(),

// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.json#JsonProtocol"))
.operation(ShapeId.from("aws.protocoltests.json#EndpointOperation"))
.addTestName("AwsJson11EndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.json#JsonProtocol"))
.operation(ShapeId.from("aws.protocoltests.json#EndpointWithHostLabelOperation"))
.addTestName("AwsJson11EndpointTraitWithHostLabel")
.build(),

// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.json10#JsonRpc10"))
.operation(ShapeId.from("aws.protocoltests.json10#EndpointOperation"))
.addTestName("AwsJson10EndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.json10#JsonRpc10"))
.operation(ShapeId.from("aws.protocoltests.json10#EndpointWithHostLabelOperation"))
.addTestName("AwsJson10EndpointTraitWithHostLabel")
.build(),

// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.query#AwsQuery"))
.operation(ShapeId.from("aws.protocoltests.query#EndpointOperation"))
.addTestName("AwsQueryEndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.query#AwsQuery"))
.operation(ShapeId.from("aws.protocoltests.query#EndpointWithHostLabelOperation"))
.addTestName("AwsQueryEndpointTraitWithHostLabel")
.build(),

// Endpoint prefix serialization doesn't work with test runner's handling of request URLs.
// e.g. http://foo.127.0.0.1:59850/ dial fail
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restxml#RestXml"))
.operation(ShapeId.from("aws.protocoltests.restxml#EndpointOperation"))
.addTestName("RestXmlEndpointTrait")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restxml#RestXml"))
.operation(ShapeId.from("aws.protocoltests.restxml#EndpointWithHostLabelHeaderOperation"))
.addTestName("RestXmlEndpointTraitWithHostLabelAndHttpBinding")
.build(),
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restxml#RestXml"))
.operation(ShapeId.from("aws.protocoltests.restxml#EndpointWithHostLabelOperation"))
.addTestName("RestXmlEndpointTraitWithHostLabel")
.build()

));
Set<HttpProtocolUnitTestGenerator.SkipTest> inputSkipTests = new TreeSet<>(SetUtils.of());

Set<HttpProtocolUnitTestGenerator.SkipTest> outputSkipTests = new TreeSet<>(SetUtils.of(
// REST-JSON optional (SHOULD) test cases
Expand Down
26 changes: 26 additions & 0 deletions internal/protocoltest/mockHttpClient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package protocoltest

import (
"io/ioutil"
"net/http"
"strings"
)

// HTTPClient is a mock http client used by protocol test cases to
// respond success response back
type HTTPClient struct{}

// Do returns a mock success response to caller
func (*HTTPClient) Do(request *http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Header: request.Header,
Body: ioutil.NopCloser(strings.NewReader("")),
Request: request,
}, nil
}

// NewClient returns pointer of a new HTTPClient for protocol test client
func NewClient() *HTTPClient {
return &HTTPClient{}
}

0 comments on commit 20cbae8

Please sign in to comment.