add ec2_query_no_input

This commit is contained in:
Emil Lerch 2023-08-28 13:10:16 -07:00
parent eafb62aee9
commit 6d3e820bd1
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
3 changed files with 123 additions and 6 deletions

View File

@ -1785,3 +1785,33 @@ test "rest_json_1_query_no_input: lambda listFunctions runtime" {
call.response.functions.?[12].function_name.?, call.response.functions.?[12].function_name.?,
); );
} }
test "rest_json_1_work_with_lambda: lambda multiple functions (blank test)" {
// Replicating this test would not provide additional coverage. It is
// here for completeness only
}
test "ec2_query_no_input: EC2 describe regions" {
const allocator = std.testing.allocator;
var test_harness = TestSetup.init(allocator, .{
.allocator = allocator,
.server_response = @embedFile("test_ec2_query_no_input.response"),
.server_response_headers = @constCast(&[_][2][]const u8{
.{ "Content-Type", "text/xml;charset=UTF-8" },
.{ "x-amzn-RequestId", "4cdbdd69-800c-49b5-8474-ae4c17709782" },
}),
});
defer test_harness.deinit();
const options = try test_harness.start();
const ec2 = (Services(.{.ec2}){}).ec2;
const call = try test_harness.client.call(ec2.describe_regions.Request{}, options);
defer call.deinit();
test_harness.stop();
// Request expectations
try std.testing.expectEqual(std.http.Method.POST, test_harness.request_options.request_method);
try std.testing.expectEqualStrings("/?Action=DescribeRegions&Version=2016-11-15", test_harness.request_options.request_target);
try std.testing.expectEqualStrings(
\\Action=DescribeRegions&Version=2016-11-15
, test_harness.request_options.request_body);
// Response expectations
try std.testing.expectEqualStrings("4cdbdd69-800c-49b5-8474-ae4c17709782", call.response_metadata.request_id);
try std.testing.expectEqual(@as(usize, 17), call.response.regions.?.len);
}

View File

@ -137,8 +137,6 @@ pub fn main() anyerror!void {
std.log.info("request id: {any}", .{call.response_metadata.request_id}); std.log.info("request id: {any}", .{call.response_metadata.request_id});
std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0}); std.log.info("account has clusters: {}", .{call.response.cluster_arns.?.len > 0});
}, },
// ^^ under test. vv stil in progress
// This has an issue with json.zig
.rest_json_1_query_with_input => { .rest_json_1_query_with_input => {
const call = try client.call(services.lambda.list_functions.Request{ const call = try client.call(services.lambda.list_functions.Request{
.max_items = 1, .max_items = 1,
@ -147,7 +145,6 @@ pub fn main() anyerror!void {
std.log.info("request id: {any}", .{call.response_metadata.request_id}); std.log.info("request id: {any}", .{call.response_metadata.request_id});
std.log.info("account has functions: {}", .{call.response.functions.?.len > 0}); std.log.info("account has functions: {}", .{call.response.functions.?.len > 0});
}, },
// This is skipped
.rest_json_1_query_no_input => { .rest_json_1_query_no_input => {
const call = try client.call(services.lambda.list_functions.Request{}, options); const call = try client.call(services.lambda.list_functions.Request{}, options);
defer call.deinit(); defer call.deinit();
@ -183,15 +180,14 @@ pub fn main() anyerror!void {
} }
}, },
.ec2_query_no_input => { .ec2_query_no_input => {
std.log.err("EC2 functions not yet working in 0.11", .{}); // Describe regions is a simpler request and easier to debug
// // Describe regions is a simpler request and easier to debug
const result = try client.call(services.ec2.describe_regions.Request{}, options); const result = try client.call(services.ec2.describe_regions.Request{}, options);
defer result.deinit(); defer result.deinit();
std.log.info("request id: {any}", .{result.response_metadata.request_id}); std.log.info("request id: {any}", .{result.response_metadata.request_id});
std.log.info("region count: {d}", .{result.response.regions.?.len}); std.log.info("region count: {d}", .{result.response.regions.?.len});
}, },
// ^^ under test. vv still in progress
.ec2_query_with_input => { .ec2_query_with_input => {
std.log.err("EC2 functions not yet working in 0.11", .{});
// Describe instances is more interesting // Describe instances is more interesting
const result = try client.call(services.ec2.describe_instances.Request{ .max_results = 6 }, options); const result = try client.call(services.ec2.describe_instances.Request{ .max_results = 6 }, options);
defer result.deinit(); defer result.deinit();

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>4cdbdd69-800c-49b5-8474-ae4c17709782</requestId>
<regionInfo>
<item>
<regionName>ap-south-1</regionName>
<regionEndpoint>ec2.ap-south-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>eu-north-1</regionName>
<regionEndpoint>ec2.eu-north-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>eu-west-3</regionName>
<regionEndpoint>ec2.eu-west-3.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>eu-west-2</regionName>
<regionEndpoint>ec2.eu-west-2.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>eu-west-1</regionName>
<regionEndpoint>ec2.eu-west-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ap-northeast-3</regionName>
<regionEndpoint>ec2.ap-northeast-3.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ap-northeast-2</regionName>
<regionEndpoint>ec2.ap-northeast-2.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ap-northeast-1</regionName>
<regionEndpoint>ec2.ap-northeast-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ca-central-1</regionName>
<regionEndpoint>ec2.ca-central-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>sa-east-1</regionName>
<regionEndpoint>ec2.sa-east-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ap-southeast-1</regionName>
<regionEndpoint>ec2.ap-southeast-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>ap-southeast-2</regionName>
<regionEndpoint>ec2.ap-southeast-2.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>eu-central-1</regionName>
<regionEndpoint>ec2.eu-central-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>us-east-1</regionName>
<regionEndpoint>ec2.us-east-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>us-east-2</regionName>
<regionEndpoint>ec2.us-east-2.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>us-west-1</regionName>
<regionEndpoint>ec2.us-west-1.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
<item>
<regionName>us-west-2</regionName>
<regionEndpoint>ec2.us-west-2.amazonaws.com</regionEndpoint>
<optInStatus>opt-in-not-required</optInStatus>
</item>
</regionInfo>
</DescribeRegionsResponse>