Skip to content

Commit

Permalink
review: Support overriding some URLSigner.Options default values.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-tarafa committed Mar 5, 2024
1 parent d6c01bd commit c83d0b6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void WithPort_Null()
}

[Fact]
public void WithDefultOverrides_NullOverrideValues()
public void WithDefaultOverrides_NullOverrideValues()
{
var options = Options.FromDuration(TimeSpan.FromMinutes(1));

Expand All @@ -256,7 +256,7 @@ public void WithDefultOverrides_NullOverrideValues()
}

[Fact]
public void WithDefultOverrides()
public void WithDefaultOverrides()
{
var options = Options.FromDuration(TimeSpan.FromMinutes(1));

Expand All @@ -269,7 +269,7 @@ public void WithDefultOverrides()
}

[Fact]
public void WithDefultOverrides_DoesNotOverrideExplicit()
public void WithDefaultOverrides_DoesNotOverrideExplicit()
{
var options = Options.FromDuration(TimeSpan.FromMinutes(1)).WithScheme("https").WithHost("explicitHost").WithPort(5678);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Gax;

namespace Google.Cloud.Storage.V1;
public sealed partial class UrlSigner
{
/// <summary>
/// Overrides for default values for some of the options in <see cref="Options"/>.
/// Useful for creating signers where signing options default to specific valued, for instance
/// for creating signers from a <see cref="StorageClient"/> where the host and scheme should
/// Useful for creating signers where signing options default to specific values, for instance
/// for creating signers from a <see cref="StorageClient"/> where the scheme, host and port should
/// default to that of the client.
/// </summary>
internal sealed class DefaultOptionsOverrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public sealed class Options
/// <summary>
/// The Scheme to use for the request. Only http or https supported.
/// This will never be null. If null is specified in <see cref="WithScheme(string)"/>
/// then https will be used.
/// Defaults to https.
/// an appropiate default value will be used.
/// </summary>
public string Scheme => ExplicitScheme ?? DefaultOptionsOverrides?.Scheme ?? DefaultScheme;

Expand All @@ -79,7 +78,7 @@ public sealed class Options
/// <summary>
/// The host to use for generating the signed URL.
/// This will never be null. If null is specified in <see cref="WithHost(string)"/>
/// then <see cref="DefaultStorageHost"/> will be used.
/// then the appropiate default value will be used.
/// Will be ignored if <see cref="UrlStyle"/> is set to <see cref="UrlStyle.BucketBoundHostname"/>.
/// </summary>
public string Host => ExplicitHost ?? DefaultOptionsOverrides?.Host ?? DefaultStorageHost;
Expand Down Expand Up @@ -121,7 +120,7 @@ public sealed class Options

/// <summary>
/// Values to be used as default for some options in case they are not set,
/// instead of the usual default values.May be null.
/// instead of the usual default values. May be null.
/// </summary>
internal DefaultOptionsOverrides DefaultOptionsOverrides { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static UrlSigner FromBlobSignerAsyncProvider(Func<Task<IBlobSigner>> sig
internal UrlSigner WithClock(IClock clock) => new UrlSigner(_blobSignerProvider, clock, _defaultOptionsOverrides);

/// <summary>
/// Returns a URL signer identical to this one, excepto for the default options overrides used for signing.
/// Returns a URL signer identical to this one, except for the default options overrides used for signing.
/// </summary>
internal UrlSigner WithDefaultOptionsOverride(DefaultOptionsOverrides optionsOverrides) =>
new UrlSigner(_blobSignerProvider, _clock, optionsOverrides);
Expand Down

0 comments on commit c83d0b6

Please sign in to comment.