Skip to content

Commit 24f1619

Browse files
authored
Service specific protocol tests (#3049)
1 parent f1b85a9 commit 24f1619

File tree

13 files changed

+724
-52
lines changed

13 files changed

+724
-52
lines changed

gems/aws-sdk-apigateway/spec/client_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Aws
66
module APIGateway
77
describe Client do
88

9-
let(:client) { Client.new(stub_responses:true) }
9+
let(:client) { Client.new(stub_responses: true) }
1010

1111
it 'supports maps for querystrings' do
1212
resp = client.get_sdk({
@@ -21,9 +21,7 @@ module APIGateway
2121
})
2222

2323
expect(resp.context.http_request.endpoint.to_s).to match(/\?abc=xyz&key=value&string=string$/)
24-
2524
end
26-
2725
end
2826
end
2927
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'spec_helper'
4+
5+
module Aws
6+
module APIGateway
7+
describe Client do
8+
9+
let(:client) { Client.new(stub_responses: true) }
10+
11+
# {
12+
# id: "ApiGatewayAccept",
13+
# documentation: "API Gateway requires that this Accept header is set on all requests.",
14+
# protocol: restJson1,
15+
# method: "GET",
16+
# uri: "/restapis",
17+
# headers: {
18+
# "Accept": "application/json",
19+
# },
20+
# body: "",
21+
# params: {},
22+
# }
23+
it 'ApiGatewayAccept' do
24+
resp = client.get_rest_apis
25+
request = resp.context.http_request
26+
expect(request.headers['accept']).to eq('application/json')
27+
end
28+
end
29+
end
30+
end

gems/aws-sdk-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Fix trailing slash in endpoint URLs for rest-json and rest-xml services.
5+
46
3.197.1 (2024-06-19)
57
------------------
68

gems/aws-sdk-core/lib/aws-sdk-core/rest/request/endpoint.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def uri(base_uri, params)
3030
private
3131

3232
def apply_path_params(uri, params)
33-
path = uri.path.sub(%r{/$}, '') + @path_pattern.split('?')[0]
33+
path = uri.path.sub(%r{/$}, '')
34+
# handle trailing slash
35+
path += @path_pattern.split('?')[0] if path.empty? || @path_pattern != '/'
3436
uri.path = path.gsub(/{.+?}/) do |placeholder|
3537
param_value_for_placeholder(placeholder, params)
3638
end

gems/aws-sdk-glacier/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Require `account_id` to be non-empty and set it to the default.
5+
46
1.62.0 (2024-06-05)
57
------------------
68

gems/aws-sdk-glacier/lib/aws-sdk-glacier/plugins/account_id.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ class AccountId < Seahorse::Client::Plugin
1414
your `:credentials` belong to.
1515
DOCS
1616

17-
handle_request(step: :initialize) do |context|
18-
context.params[:account_id] ||= context.config.account_id
17+
class Handler < Seahorse::Client::Handler
18+
def call(context)
19+
context.params[:account_id] ||= context.config.account_id
20+
if context.params[:account_id].empty?
21+
context.params[:account_id] = '-'
22+
end
23+
@handler.call(context)
24+
end
1925
end
2026

27+
handler(Handler, step: :initialize)
28+
2129
end
2230
end
2331
end

gems/aws-sdk-glacier/lib/aws-sdk-glacier/plugins/api_version.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ module Plugins
77
class ApiVersion < Seahorse::Client::Plugin
88

99
class Handler < Seahorse::Client::Handler
10-
1110
def call(context)
1211
version = context.config.api.version
1312
context.http_request.headers['x-amz-glacier-version'] = version
1413
@handler.call(context)
1514
end
16-
1715
end
1816

1917
handler(Handler)

gems/aws-sdk-glacier/spec/client_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,8 @@ module Glacier
3939
)
4040
end
4141

42-
describe 'api verison' do
43-
44-
it 'sends the API version as a header' do
45-
resp = client.list_vaults
46-
expect(resp.context.http_request.headers['x-amz-glacier-version']).to eq('2012-06-01')
47-
end
48-
49-
end
5042

5143
describe 'errors' do
52-
5344
it 'extracts the error code form the header' do
5445
client.handle(step: :send) do |context|
5546
context.http_response.signal_headers(409, {})
@@ -67,11 +58,9 @@ module Glacier
6758
client.list_vaults(account_id: '12345')
6859
}.to raise_error(Errors::AccessDeniedException)
6960
end
70-
7161
end
7262

7363
describe ':account_id' do
74-
7564
it 'defaults to -' do
7665
resp = client.list_vaults
7766
expect(resp.context.http_request.endpoint.path).to eq('/-/vaults')
@@ -88,7 +77,6 @@ module Glacier
8877
resp = client.list_vaults(account_id: 'xyz')
8978
expect(resp.context.http_request.endpoint.path).to eq('/xyz/vaults')
9079
end
91-
9280
end
9381
end
9482
end
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'spec_helper'
4+
5+
module Aws
6+
module Glacier
7+
describe Client do
8+
9+
let(:client) { Client.new(stub_responses: true) }
10+
11+
describe '#upload_archive' do
12+
# {
13+
# id: "GlacierVersionHeader",
14+
# documentation: "Glacier requires that a version header be set on all requests.",
15+
# protocol: restJson1,
16+
# method: "POST",
17+
# uri: "/foo/vaults/bar/archives",
18+
# headers: {
19+
# "X-Amz-Glacier-Version": "2012-06-01",
20+
# },
21+
# body: "",
22+
# params: {
23+
# accountId: "foo",
24+
# vaultName: "bar",
25+
# },
26+
# },
27+
it 'GlacierVersionHeader' do
28+
resp = client.upload_archive(
29+
account_id: 'foo',
30+
vault_name: 'bar'
31+
)
32+
request = resp.context.http_request
33+
expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01')
34+
end
35+
36+
# {
37+
# id: "GlacierChecksums",
38+
# documentation: "Glacier requires checksum headers that are cumbersome to provide.",
39+
# protocol: restJson1,
40+
# method: "POST",
41+
# uri: "/foo/vaults/bar/archives",
42+
# headers: {
43+
# "X-Amz-Glacier-Version": "2012-06-01",
44+
# "X-Amz-Content-Sha256": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
45+
# "X-Amz-Sha256-Tree-Hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
46+
# },
47+
# body: "hello world",
48+
# params: {
49+
# accountId: "foo",
50+
# vaultName: "bar",
51+
# body: "hello world"
52+
# },
53+
# appliesTo: "client",
54+
# },
55+
it 'GlacierChecksums' do
56+
resp = client.upload_archive(
57+
account_id: 'foo',
58+
vault_name: 'bar',
59+
body: 'hello world'
60+
)
61+
request = resp.context.http_request
62+
expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01')
63+
expect(request.headers['x-amz-content-sha256'])
64+
.to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9')
65+
expect(request.headers['x-amz-sha256-tree-hash'])
66+
.to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9')
67+
end
68+
69+
# {
70+
# id: "GlacierAccountId",
71+
# documentation: """
72+
# Glacier requires that the account id be set, but you can just use a
73+
# hyphen (-) to indicate the current account. This should be default
74+
# behavior if the customer provides a null or empty string.""",
75+
# protocol: restJson1,
76+
# method: "POST",
77+
# uri: "/-/vaults/bar/archives",
78+
# headers: {
79+
# "X-Amz-Glacier-Version": "2012-06-01",
80+
# },
81+
# body: "",
82+
# params: {
83+
# accountId: "",
84+
# vaultName: "bar",
85+
# },
86+
# appliesTo: "client",
87+
# }
88+
it 'GlacierAccountId' do
89+
resp = client.upload_archive(
90+
account_id: '',
91+
vault_name: 'bar'
92+
)
93+
request = resp.context.http_request
94+
expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01')
95+
expect(request.endpoint.path).to eq('/-/vaults/bar/archives')
96+
end
97+
end
98+
99+
describe '#upload_multipart_part' do
100+
# {
101+
# id: "GlacierMultipartChecksums",
102+
# documentation: "Glacier requires checksum headers that are cumbersome to provide.",
103+
# protocol: restJson1,
104+
# method: "PUT",
105+
# uri: "/foo/vaults/bar/multipart-uploads/baz",
106+
# headers: {
107+
# "X-Amz-Glacier-Version": "2012-06-01",
108+
# "X-Amz-Content-Sha256": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
109+
# "X-Amz-Sha256-Tree-Hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
110+
# },
111+
# body: "hello world",
112+
# params: {
113+
# accountId: "foo",
114+
# vaultName: "bar",
115+
# uploadId: "baz",
116+
# body: "hello world"
117+
# },
118+
# appliesTo: "client",
119+
# }
120+
it 'GlacierMultipartChecksums' do
121+
resp = client.upload_multipart_part(
122+
account_id: 'foo',
123+
vault_name: 'bar',
124+
upload_id: 'baz',
125+
body: 'hello world'
126+
)
127+
request = resp.context.http_request
128+
expect(request.headers['x-amz-glacier-version']).to eq('2012-06-01')
129+
expect(request.headers['x-amz-content-sha256'])
130+
.to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9')
131+
expect(request.headers['x-amz-sha256-tree-hash'])
132+
.to eq('b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9')
133+
end
134+
end
135+
end
136+
end
137+
end

gems/aws-sdk-machinelearning/spec/client_spec.rb

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)