Skip to content

Commit a4a24b3

Browse files
author
Matt Muller
committed
Fix rbs and PR feedback
1 parent 7c58f10 commit a4a24b3

5 files changed

Lines changed: 15 additions & 10 deletions

File tree

gems/smithy-client/lib/smithy-client/auth.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
module Smithy
44
module Client
5+
# The result of resolving the authentication scheme for a request.
6+
ResolvedAuth = Struct.new(:scheme_id, :signer, :signer_properties, :identity_provider, keyword_init: true)
7+
58
# @api private
69
module Auth
7-
ResolvedAuth = Struct.new(:scheme_id, :signer, :signer_properties, :identity_provider, keyword_init: true)
8-
910
class << self
1011
def resolve(context, endpoint_properties = {})
1112
if endpoint_properties.key?('authSchemes')
@@ -62,7 +63,7 @@ def prioritize_auth_options(auth_options, auth_scheme_preference)
6263
preferred_options.empty? ? auth_options : preferred_options
6364
end
6465

65-
def resolve_auth_scheme(auth_schemes, auth_options)
66+
def resolve_auth_scheme(auth_schemes, auth_options) # rubocop:disable Metrics/MethodLength
6667
raise 'No auth options were resolved' if auth_options.empty?
6768

6869
failures = []

gems/smithy-client/lib/smithy-client/plugins/resolve_auth.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ class ResolveAuth < Plugin
1717
:auth_scheme_preference,
1818
doc_type: 'Array<String>',
1919
rbs_type: 'Array[String]',
20-
docstring: 'A list of preferred authentication schemes to use when making a request.'
20+
docstring: <<~DOCS
21+
An ordered list of preferred authentication schemes to use when making a request.
22+
The items in the list must be a fully qualified scheme IDs, such as `smithy.api#httpBearerAuth`.
23+
DOCS
2124
) do
2225
[]
2326
end

gems/smithy-client/sig/smithy-client/handler_context.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Smithy
99
attr_accessor config: Struct[untyped]?
1010
attr_accessor http_request: Http::Request | untyped
1111
attr_accessor http_response: Http::Response | untyped
12-
attr_accessor auth: AuthScheme
12+
attr_accessor auth: ResolvedAuth
1313
attr_accessor retries: Integer
1414
attr_reader metadata: Hash[untyped, untyped]
1515
def []: (untyped) -> untyped
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module Smithy
22
module Client
3-
class AuthScheme
3+
class ResolvedAuth
44
def initialize: (?Hash[Symbol, untyped] options) -> void
55
attr_reader identity_provider: IdentityProvider?
66
attr_reader scheme_id: String
77
attr_reader signer: _Signer
8+
attr_reader signer_properties: Hash[String, String]
89
end
910
end
1011
end

gems/smithy-client/spec/smithy-client/plugins/resolve_auth_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,31 @@ module Plugins
3838

3939
it 'supports anonymous auth' do
4040
resp = client.operation
41-
expect(resp.context.auth).to be_a(Auth::ResolvedAuth)
41+
expect(resp.context.auth).to be_a(ResolvedAuth)
4242
expect(resp.context.auth.scheme_id).to eq('smithy.api#noAuth')
4343
end
4444

4545
it 'supports http api key auth' do
4646
shapes['smithy.ruby.tests#SampleClient']['traits']['smithy.api#httpApiKeyAuth'] = {}
4747
client_class.add_plugin(HttpApiKeyAuth)
4848
resp = client.operation
49-
expect(resp.context.auth).to be_a(Auth::ResolvedAuth)
49+
expect(resp.context.auth).to be_a(ResolvedAuth)
5050
expect(resp.context.auth.scheme_id).to eq('smithy.api#httpApiKeyAuth')
5151
end
5252

5353
it 'supports http basic auth' do
5454
shapes['smithy.ruby.tests#SampleClient']['traits']['smithy.api#httpBasicAuth'] = {}
5555
client_class.add_plugin(HttpBasicAuth)
5656
resp = client.operation
57-
expect(resp.context.auth).to be_a(Auth::ResolvedAuth)
57+
expect(resp.context.auth).to be_a(ResolvedAuth)
5858
expect(resp.context.auth.scheme_id).to eq('smithy.api#httpBasicAuth')
5959
end
6060

6161
it 'supports http bearer auth' do
6262
shapes['smithy.ruby.tests#SampleClient']['traits']['smithy.api#httpBearerAuth'] = {}
6363
client_class.add_plugin(HttpBearerAuth)
6464
resp = client.operation
65-
expect(resp.context.auth).to be_a(Auth::ResolvedAuth)
65+
expect(resp.context.auth).to be_a(ResolvedAuth)
6666
expect(resp.context.auth.scheme_id).to eq('smithy.api#httpBearerAuth')
6767
end
6868

0 commit comments

Comments
 (0)