diff --git a/sdk/src/Core/AWSConfigs.cs b/sdk/src/Core/AWSConfigs.cs index 938f7a29a6ec..c39f4116455c 100644 --- a/sdk/src/Core/AWSConfigs.cs +++ b/sdk/src/Core/AWSConfigs.cs @@ -79,9 +79,6 @@ public static partial class AWSConfigs // Deprecated configs internal static string _awsRegion = GetConfig(AWSRegionKey); - internal static LoggingOptions _logging = GetLoggingSetting(); - internal static ResponseLoggingOption _responseLogging = GetConfigEnum(ResponseLoggingKey); - internal static bool _logMetrics = GetConfigBool(LogMetricsKey); internal static string _awsProfileName = GetConfig(AWSProfileNameKey); internal static string _awsAccountsLocation = GetConfig(AWSProfilesLocationKey); internal static bool _useSdkCache = GetConfigBool(UseSdkCacheKey, defaultValue: true); @@ -121,9 +118,6 @@ public static TimeSpan? ManualClockCorrection /// by determining the correct server time and reissuing the /// request with the correct time. /// Default value of this field is True. - /// will be updated with the calculated - /// offset even if this field is set to false, though requests - /// will not be corrected or retried. /// Ignored if is set. /// public static bool CorrectForClockSkew @@ -131,23 +125,6 @@ public static bool CorrectForClockSkew get { return _rootConfig.CorrectForClockSkew; } set { _rootConfig.CorrectForClockSkew = value; } } - - /// - /// The calculated clock skew correction, if there is one. - /// This field will be set if a service call resulted in an exception - /// and the SDK has determined that there is a difference between local - /// and server times. - /// - /// If is set to true, this - /// value will be set to the correction, but it will not be used by the - /// SDK and clock skew errors will not be retried. - /// - [Obsolete("This value is deprecated in favor of IClientConfig.ClockOffset, use CorrectClockSkew.GetClockCorrectionForEndpoint(string endpoint) instead.")] - public static TimeSpan ClockOffset - { - get; - internal set; - } #endregion #region Region @@ -213,7 +190,6 @@ public static string AWSProfileName /// /// Key for the AWSProfilesLocation property. - /// /// public const string AWSProfilesLocationKey = "AWSProfilesLocation"; @@ -242,110 +218,6 @@ public static string AWSProfilesLocation #endregion - #region Logging - - /// - /// Key for the Logging property. - /// - /// - public const string LoggingKey = "AWSLogging"; - - /// - /// Configures how the SDK should log events, if at all. - /// Changes to this setting will only take effect in newly-constructed clients. - /// - /// The setting can be configured through App.config, for example: - /// - /// <appSettings> - /// <add key="AWSLogging" value="log4net"/> - /// </appSettings> - /// - /// - [Obsolete("This property is obsolete. Use LoggingConfig.LogTo instead.")] - public static LoggingOptions Logging - { - get { return _rootConfig.Logging.LogTo; } - set { _rootConfig.Logging.LogTo = value; } - } - - private static LoggingOptions GetLoggingSetting() - { - string value = GetConfig(LoggingKey); - if (string.IsNullOrEmpty(value)) - return LoggingOptions.None; - - string[] settings = value.Split(validSeparators, StringSplitOptions.RemoveEmptyEntries); - if (settings == null || settings.Length == 0) - return LoggingOptions.None; - - LoggingOptions totalSetting = LoggingOptions.None; - foreach (string setting in settings) - { - LoggingOptions l = ParseEnum(setting); - totalSetting |= l; - } - return totalSetting; - } - - #endregion - - #region Response Logging - - /// - /// Key for the ResponseLogging property. - /// - /// - /// - public const string ResponseLoggingKey = "AWSResponseLogging"; - - /// - /// Configures when the SDK should log service responses. - /// Changes to this setting will take effect immediately. - /// - /// The setting can be configured through App.config, for example: - /// - /// <appSettings> - /// <add key="AWSResponseLogging" value="OnError"/> - /// </appSettings> - /// - /// - [Obsolete("This property is obsolete. Use LoggingConfig.LogResponses instead.")] - public static ResponseLoggingOption ResponseLogging - { - get { return _rootConfig.Logging.LogResponses; } - set { _rootConfig.Logging.LogResponses = value; } - } - - #endregion - - #region Log Metrics - - /// - /// Key for the LogMetrics property. - /// - /// - public const string LogMetricsKey = "AWSLogMetrics"; - - /// - /// Configures if the SDK should log performance metrics. - /// This setting configures the default LogMetrics property for all clients/configs. - /// Changes to this setting will only take effect in newly-constructed clients. - /// - /// The setting can be configured through App.config, for example: - /// - /// <appSettings> - /// <add key="AWSLogMetrics" value="true"/> - /// </appSettings> - /// - /// - [Obsolete("This property is obsolete. Use LoggingConfig.LogMetrics instead.")] - public static bool LogMetrics - { - get { return _rootConfig.Logging.LogMetrics; } - set { _rootConfig.Logging.LogMetrics = value; } - } - - #endregion #region SDK Cache diff --git a/sdk/src/Core/AWSSDK.Core.NetStandard.csproj b/sdk/src/Core/AWSSDK.Core.NetStandard.csproj index 2af0a0429fbb..ca3d2cd81cb8 100644 --- a/sdk/src/Core/AWSSDK.Core.NetStandard.csproj +++ b/sdk/src/Core/AWSSDK.Core.NetStandard.csproj @@ -21,8 +21,10 @@ false $(NoWarn);CS1591;CA1822 - true - True + true + True + + true IL2026,IL2075 diff --git a/sdk/src/Core/Amazon.Auth/AccessControlPolicy/ConditionFactory.cs b/sdk/src/Core/Amazon.Auth/AccessControlPolicy/ConditionFactory.cs index 3fc36d9714f4..157d927f864a 100644 --- a/sdk/src/Core/Amazon.Auth/AccessControlPolicy/ConditionFactory.cs +++ b/sdk/src/Core/Amazon.Auth/AccessControlPolicy/ConditionFactory.cs @@ -237,23 +237,6 @@ public static Condition NewCondition(string key, bool value) return new Condition("Bool", key, value.ToString().ToLowerInvariant()); } - /// - /// This method is deprecated. Invoking this method results in non-UTC DateTimes - /// not being marshalled correctly. Use NewConditionUtc instead. - /// Constructs a new access policy condition that compares the current time - /// (on the AWS servers) to the specified date. - /// - /// The type of comparison to perform. For example, - /// DateComparisonType.DateLessThan will cause this policy - /// condition to evaluate to true if the current date is less than - /// the date specified in the second argument. - /// The date to compare against. - [Obsolete("Invoking this method results in non-UTC DateTimes not being marshalled correctly. Use NewConditionUtc instead.", false)] - public static Condition NewCondition(DateComparisonType type, DateTime date) - { - return new Condition(type.ToString(), CURRENT_TIME_CONDITION_KEY, date.ToString(AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture)); - } - /// /// Constructs a new access policy condition that compares the current time /// (on the AWS servers) to the specified date. diff --git a/sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs b/sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs index fb127f776db3..2e9739510d57 100644 --- a/sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs +++ b/sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs @@ -190,17 +190,6 @@ protected virtual void Initialize() #region Invoke methods - [Obsolete("Invoke taking marshallers is obsolete. Use Invoke taking InvokeOptionsBase instead.")] - protected TResponse Invoke(TRequest request, - IMarshaller marshaller, ResponseUnmarshaller unmarshaller) - where TRequest : AmazonWebServiceRequest - where TResponse : AmazonWebServiceResponse - { - var options = new InvokeOptions(); - options.RequestMarshaller = marshaller; - options.ResponseUnmarshaller = unmarshaller; - return Invoke(request, options); - } protected TResponse Invoke(AmazonWebServiceRequest request, InvokeOptionsBase options) where TResponse : AmazonWebServiceResponse @@ -227,21 +216,6 @@ protected TResponse Invoke(AmazonWebServiceRequest request, InvokeOpt #if AWS_ASYNC_API - [Obsolete("InvokeAsync taking marshallers is obsolete. Use InvokeAsync taking InvokeOptionsBase instead.")] - protected System.Threading.Tasks.Task InvokeAsync( - TRequest request, - IMarshaller marshaller, - ResponseUnmarshaller unmarshaller, - System.Threading.CancellationToken cancellationToken) - where TRequest: AmazonWebServiceRequest - where TResponse : AmazonWebServiceResponse, new() - { - var options = new InvokeOptions(); - options.RequestMarshaller = marshaller; - options.ResponseUnmarshaller = unmarshaller; - return InvokeAsync(request, options, cancellationToken); - } - protected System.Threading.Tasks.Task InvokeAsync( AmazonWebServiceRequest request, InvokeOptionsBase options, diff --git a/sdk/src/Core/Amazon.Runtime/CapacityManager.cs b/sdk/src/Core/Amazon.Runtime/CapacityManager.cs index dff0a29e9479..db09bb79171b 100644 --- a/sdk/src/Core/Amazon.Runtime/CapacityManager.cs +++ b/sdk/src/Core/Amazon.Runtime/CapacityManager.cs @@ -111,17 +111,7 @@ public bool TryAcquireCapacity(RetryCapacity retryCapacity, CapacityType capacit } } - /// - /// This method calls a method to release capacity back - /// based on whether it was a successful response or a successful retry response. This is invoked by a retry request response. - /// - /// if this request is a retry, use a different capacity cost - /// Contains the RetryCapacity object for the said ServiceURL. - [Obsolete("This method is no longer used in favor of allowing the caller to specify the type of capacity to release.")] - public void TryReleaseCapacity(bool isRetryRequest, RetryCapacity retryCapacity) - { - ReleaseCapacity(isRetryRequest ? CapacityType.Retry : CapacityType.Increment, retryCapacity); - } + /// /// This method calls a method to release capacity back diff --git a/sdk/src/Core/Amazon.Runtime/ClientConfig.cs b/sdk/src/Core/Amazon.Runtime/ClientConfig.cs index bb2800b336f2..e00b01c03a31 100644 --- a/sdk/src/Core/Amazon.Runtime/ClientConfig.cs +++ b/sdk/src/Core/Amazon.Runtime/ClientConfig.cs @@ -64,7 +64,6 @@ public abstract partial class ClientConfig : IClientConfig private string signatureVersion = "4"; private string clientAppId = null; private SigningAlgorithm signatureMethod = SigningAlgorithm.HmacSHA256; - private bool readEntireResponse = false; private bool logResponse = false; private int bufferSize = AWSSDKUtils.DefaultBufferSize; private long progressUpdateInterval = AWSSDKUtils.DefaultProgressUpdateInterval; @@ -379,15 +378,7 @@ public bool UseHttp set { this.useHttp = value; } } - /// - /// Given this client configuration, return a DNS suffix for service endpoint url. - /// - [Obsolete("This operation is obsoleted because as of version 3.7.100 endpoint is resolved using a newer system that uses request level parameters to resolve the endpoint, use the service-specific client.DetermineServiceOperationEndPoint method instead.")] - public virtual string DetermineDnsSuffix() - { - var endpoint = regionEndpoint.GetEndpointForService(this); - return endpoint.DnsSuffix; - } + internal static string GetUrl(IClientConfig config, RegionEndpoint regionEndpoint) { @@ -491,19 +482,7 @@ public bool LogResponse set { this.logResponse = value; } } - /// - /// Gets and sets the ReadEntireResponse property. - /// NOTE: This property does not effect response processing and is deprecated. - /// To enable response logging, the ClientConfig.LogResponse and AWSConfigs.LoggingConfig - /// properties can be used. - /// - [Obsolete("This property does not effect response processing and is deprecated." + - "To enable response logging, the ClientConfig.LogResponse and AWSConfigs.LoggingConfig.LogResponses properties can be used.")] - public bool ReadEntireResponse - { - get { return this.readEntireResponse; } - set { this.readEntireResponse = value; } - } + /// /// Gets and Sets the BufferSize property. @@ -941,31 +920,9 @@ public virtual void Validate() #endif } - /// - /// Returns the current UTC now after clock correction for AWSConfigs.ManualClockCorrection. - /// - [Obsolete("Please use CorrectClockSkew.GetCorrectedUtcNowForEndpoint(string endpoint) instead.", false)] - public DateTime CorrectedUtcNow - { - get - { - // Passing null will cause GetCorrectedUtcNowForEndpoint to skip calculating ClockSkew based on - // endpoint and only use ManualClockCorrection if is set. - return CorrectClockSkew.GetCorrectedUtcNowForEndpoint(null); - } - } - /// - /// Wrapper around - /// - [Obsolete("Please use CorrectClockSkew.GetClockCorrectionForEndpoint(string endpoint) instead.", false)] - public TimeSpan ClockOffset - { - get - { - return AWSConfigs.ManualClockCorrection.GetValueOrDefault(); - } - } + + /// /// Gets and sets the DisableHostPrefixInjection flag. If true, host prefix injection will be disabled for this client, the default value of this flag is false. diff --git a/sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs b/sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs index c6a6f359ae65..9b780effc1d1 100644 --- a/sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs +++ b/sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs @@ -127,9 +127,6 @@ internal static void SetClockCorrectionForEndpoint(string endpoint, TimeSpan cor try { clockCorrectionDictionary[endpoint] = correction; -#pragma warning disable CS0618 // Type or member is obsolete - AWSConfigs.ClockOffset = correction; -#pragma warning restore CS0618 // Type or member is obsolete } finally { diff --git a/sdk/src/Core/Amazon.Runtime/IClientConfig.cs b/sdk/src/Core/Amazon.Runtime/IClientConfig.cs index 0f0f46c0b385..b82c53f0433c 100644 --- a/sdk/src/Core/Amazon.Runtime/IClientConfig.cs +++ b/sdk/src/Core/Amazon.Runtime/IClientConfig.cs @@ -168,12 +168,7 @@ public partial interface IClientConfig /// bool LogResponse { get; } - /// - /// Gets the ReadEntireResponse. - /// If this property is set to true, the service response - /// is read in its entirety before being processed. - /// - bool ReadEntireResponse { get; } + /// @@ -297,11 +292,7 @@ public partial interface IClientConfig /// A Container class for parameters used for endpoint resolution. /// The resolved endpoint for the given request. Endpoint DetermineServiceOperationEndpoint(ServiceOperationEndpointParameters parameters); - /// - /// Given this client configuration, return a DNS suffix for service endpoint url. - /// - [Obsolete("This operation is obsoleted because as of version 3.7.100 endpoint is resolved using a newer system that uses request level parameters to resolve the endpoint, use the service-specific client.DetermineServiceOperationEndPoint method instead.")] - string DetermineDnsSuffix(); + /// /// Performs validation on this config object. @@ -310,16 +301,9 @@ public partial interface IClientConfig /// The timeout specified is null. void Validate(); - /// - /// Returns the clock skew adjusted utc now. This value is affected by AWSConfigs.ManualClockCorrection - /// - DateTime CorrectedUtcNow { get; } - /// - /// Returns the calculated clock skew value for this config's service endpoint. If AWSConfigs.CorrectForClockSkew is false, - /// this value won't be used to construct service requests. - /// - TimeSpan ClockOffset { get; } + + /// /// Gets the DisableHostPrefixInjection flag. If true, host prefix injection will be disabled for this client, the default value of this flag is false. diff --git a/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Unmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Unmarshaller.cs index 83470c76a547..46b6fce50c7a 100644 --- a/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Unmarshaller.cs +++ b/sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/Unmarshaller.cs @@ -102,7 +102,9 @@ private void Unmarshall(IExecutionContext executionContext) var unmarshaller = requestContext.Unmarshaller; try { - var readEntireResponse = _supportsResponseLogging; + var readEntireResponse = _supportsResponseLogging && + (requestContext.ClientConfig.LogResponse + || AWSConfigs.LoggingConfig.LogResponses != ResponseLoggingOption.Never); var context = unmarshaller.CreateContext(responseContext.HttpResponse, readEntireResponse, @@ -159,7 +161,7 @@ private async System.Threading.Tasks.Task UnmarshallAsync(IExecutionContext exec try { var readEntireResponse = _supportsResponseLogging && - (requestContext.ClientConfig.LogResponse || requestContext.ClientConfig.ReadEntireResponse + (requestContext.ClientConfig.LogResponse || AWSConfigs.LoggingConfig.LogResponses != ResponseLoggingOption.Never); var responseStream = await responseContext.HttpResponse. diff --git a/sdk/src/Core/Amazon.Util/AWSConfigs.Models.cs b/sdk/src/Core/Amazon.Util/AWSConfigs.Models.cs index 0367f315a1df..81841085698d 100644 --- a/sdk/src/Core/Amazon.Util/AWSConfigs.Models.cs +++ b/sdk/src/Core/Amazon.Util/AWSConfigs.Models.cs @@ -122,10 +122,7 @@ public LoggingOptions LogTo internal LoggingConfig() { - LogTo = AWSConfigs._logging; - LogResponses = AWSConfigs._responseLogging; LogResponsesSizeLimit = DefaultLogResponsesSizeLimit; - LogMetrics = AWSConfigs._logMetrics; } } diff --git a/sdk/src/Services/ImportExport/AWSSDK.ImportExport.NetStandard.csproj b/sdk/src/Services/ImportExport/AWSSDK.ImportExport.NetStandard.csproj index f09b275f8675..be4555e8c1bc 100644 --- a/sdk/src/Services/ImportExport/AWSSDK.ImportExport.NetStandard.csproj +++ b/sdk/src/Services/ImportExport/AWSSDK.ImportExport.NetStandard.csproj @@ -20,7 +20,8 @@ false false true - true + true + CA1822 diff --git a/sdk/src/Services/SecurityToken/Custom/_bcl/SAML/StoredProfileSAMLCredentials.cs b/sdk/src/Services/SecurityToken/Custom/_bcl/SAML/StoredProfileSAMLCredentials.cs index 011529ae93be..e83ebe23e5ba 100644 --- a/sdk/src/Services/SecurityToken/Custom/_bcl/SAML/StoredProfileSAMLCredentials.cs +++ b/sdk/src/Services/SecurityToken/Custom/_bcl/SAML/StoredProfileSAMLCredentials.cs @@ -248,7 +248,7 @@ private CredentialsRefreshState Authenticate(ICredentials userCredential, TimeSp using (var stsClient = new AmazonSecurityTokenServiceClient(new AnonymousAWSCredentials(), region)) { var credentials = assertion.GetRoleCredentials(stsClient, ProfileData.RoleArn, credentialDuration); - state = new CredentialsRefreshState(credentials, stsClient.Config.CorrectedUtcNow + credentialDuration); + state = new CredentialsRefreshState(credentials, CorrectClockSkew.GetCorrectedUtcNowForEndpoint(region.ToString()) + credentialDuration); } } catch (Exception e) diff --git a/sdk/test/Common/AWSSDK.CommonTest.NetStandard.csproj b/sdk/test/Common/AWSSDK.CommonTest.NetStandard.csproj new file mode 100644 index 000000000000..4122a51788ed --- /dev/null +++ b/sdk/test/Common/AWSSDK.CommonTest.NetStandard.csproj @@ -0,0 +1,43 @@ + + + netstandard2.0;netcoreapp3.1;net8.0 + $(DefineConstants);NETSTANDARD;AWS_ASYNC_API + portable + true + AWSSDK.CommonTest.NetStandard + AWSSDK.CommonTest.NetStandard + + false + false + false + false + false + false + false + false + false + false + CS1591,CS1570,NU1701 + true + True + + + + + ..\..\awssdk.dll.snk + + + + + $(AWSKeyFile) + + + + + + + + + + + \ No newline at end of file diff --git a/sdk/test/Common/Utils/AssertExtensions.cs b/sdk/test/Common/Utils/AssertExtensions.cs index ff3753ca8481..37302cd89620 100644 --- a/sdk/test/Common/Utils/AssertExtensions.cs +++ b/sdk/test/Common/Utils/AssertExtensions.cs @@ -142,7 +142,7 @@ public static void AssertEnumUnchanged(Type type, string expectedHash, string no private static void AssertStringListUnchanged(List list, string expectedHash, string whatChanged, string notes) { - SHA256CryptoServiceProvider provider = new SHA256CryptoServiceProvider(); + SHA256 provider = SHA256.Create(); // make sure string to hash is repeatable list.Sort(); var stringToHash = string.Join("::", list.ToArray()); @@ -170,7 +170,7 @@ public static void AssertSourceCodeUnchanged(List srcRelativeFilenames, { sourceCodeSB.Append(File.ReadAllText(Path.Combine(sourceRoot, srcRelativeFilename))); } - SHA256CryptoServiceProvider provider = new SHA256CryptoServiceProvider(); + SHA256 provider = SHA256.Create(); var actualHash = BitConverter.ToString(provider.ComputeHash(Encoding.Default.GetBytes(sourceCodeSB.ToString()))).Replace("-", ""); // compare the hash to the expected hash diff --git a/sdk/test/IntegrationTests/Tests/General.CommonUtilities.cs b/sdk/test/IntegrationTests/Tests/General.CommonUtilities.cs index ecb5daf9e868..e468e64d970d 100644 --- a/sdk/test/IntegrationTests/Tests/General.CommonUtilities.cs +++ b/sdk/test/IntegrationTests/Tests/General.CommonUtilities.cs @@ -23,10 +23,5 @@ private static void SetUtcNowSource(Func source) var field = typeof(AWSConfigs).GetField("utcNowSource", BindingFlags.Static | BindingFlags.NonPublic); field.SetValue(null, source); } - public static void SetClockSkewCorrection(TimeSpan value) - { - var property = typeof(AWSConfigs).GetProperty("ClockOffset", BindingFlags.Static | BindingFlags.Public); - property.SetValue(null, value); - } } } \ No newline at end of file diff --git a/sdk/test/IntegrationTests/Tests/General.cs b/sdk/test/IntegrationTests/Tests/General.cs index d5288e88f06b..f51254dbc869 100644 --- a/sdk/test/IntegrationTests/Tests/General.cs +++ b/sdk/test/IntegrationTests/Tests/General.cs @@ -28,6 +28,7 @@ using Amazon.DynamoDBv2; using Amazon.ElasticTranscoder; using System.Threading; +using AWSSDK_DotNet.CommonTest.Utils; namespace AWSSDK_DotNet.IntegrationTests.Tests { @@ -779,21 +780,23 @@ private static void TestServiceCallForClockSkew(ClockSkewTestContext context) try { AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); -#pragma warning disable CS0618 // Type or member is obsolete - Assert.IsTrue(AWSConfigs.ClockOffset == TimeSpan.Zero); + Assert.IsTrue(CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString()) == TimeSpan.Zero); - SetClockSkewCorrection(IncorrectPositiveClockSkewOffset); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), IncorrectPositiveClockSkewOffset}); context.TestAction(); -#pragma warning disable CS0618 // Type or member is obsolete - Assert.AreEqual(IncorrectPositiveClockSkewOffset, AWSConfigs.ClockOffset); - SetClockSkewCorrection(IncorrectNegativeClockSkewOffset); + Assert.AreEqual(IncorrectPositiveClockSkewOffset, CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString())); + + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), IncorrectNegativeClockSkewOffset }); context.TestAction(); -#pragma warning disable CS0618 // Type or member is obsolete - Assert.AreEqual(IncorrectNegativeClockSkewOffset, AWSConfigs.ClockOffset); + + Assert.AreEqual(IncorrectNegativeClockSkewOffset, CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString())); Console.WriteLine("Simulating positive clock skew"); SetUtcNowSource(() => DateTime.UtcNow + IncorrectPositiveClockSkewOffset); @@ -801,13 +804,16 @@ private static void TestServiceCallForClockSkew(ClockSkewTestContext context) AssertExtensions.ExpectException(context.TestAction); AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); Console.WriteLine("Simulating negative clock skew"); SetUtcNowSource(() => DateTime.UtcNow + IncorrectNegativeClockSkewOffset); AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); AWSConfigs.CorrectForClockSkew = false; @@ -860,8 +866,6 @@ private class ClientTest new ClientTest { Client = typeof(AmazonS3Client), Method = "ListBuckets" }, new ClientTest { Client = typeof(Amazon.Glacier.AmazonGlacierClient), Method = "ListVaults" }, new ClientTest { Client = typeof(Amazon.IdentityManagement.AmazonIdentityManagementServiceClient), Method = "ListGroups" }, - // ImportExport returns a 500. Investigating... - //new ClientTest { Client = typeof(Amazon.ImportExport.AmazonImportExportClient), Method = "ListJobs" }, }; // Reflection helpers diff --git a/sdk/test/IntegrationTests/Utils/RetryUtilities.cs b/sdk/test/IntegrationTests/Utils/RetryUtilities.cs index ee9dd91fb52f..3a6670ed751b 100644 --- a/sdk/test/IntegrationTests/Utils/RetryUtilities.cs +++ b/sdk/test/IntegrationTests/Utils/RetryUtilities.cs @@ -2,6 +2,7 @@ using Amazon.Runtime; using Amazon.Runtime.Internal; using Amazon.Runtime.Internal.Transform; +using AWSSDK_DotNet.CommonTest.Utils; using AWSSDK_DotNet.IntegrationTests.Tests; using System; using System.Collections.Generic; @@ -99,7 +100,8 @@ private static void SetIncorrectOffset() offset = General.IncorrectPositiveClockSkewOffset; else offset = General.IncorrectNegativeClockSkewOffset; - General.SetClockSkewCorrection(offset); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] {AWSConfigs.RegionEndpoint.ToString(), offset }); } #endregion diff --git a/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj b/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj index 022f99bc816f..20883b11bc45 100644 --- a/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj +++ b/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj @@ -13,6 +13,7 @@ + diff --git a/sdk/test/NetStandard/IntegrationTests/IntegrationTests/General.cs b/sdk/test/NetStandard/IntegrationTests/IntegrationTests/General.cs index 5a60652da8eb..34cc9df5e07c 100644 --- a/sdk/test/NetStandard/IntegrationTests/IntegrationTests/General.cs +++ b/sdk/test/NetStandard/IntegrationTests/IntegrationTests/General.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; using Xunit; using Amazon.DNXCore.IntegrationTests; - +using AWSSDK_DotNet.CommonTest.Utils; namespace Amazon.DNXCore.IntegrationTests { @@ -132,7 +132,7 @@ protected override CredentialsRefreshState GenerateNewCredentials() } } - //[Fact] + [Fact] public void TestManualClockCorrection() { TestClients(TestServiceCallForManualClockCorrection); @@ -141,7 +141,7 @@ public void TestManualClockCorrection() // This test verifies that all service clients are able to // correctly handle clock skew errors. // By default it only tests a small subset of services. - //[Fact] + [Fact] public void TestClockSkewCorrection() { TestClients(TestServiceCallForClockSkew); @@ -177,7 +177,7 @@ private static void TestServiceCallForManualClockCorrection(ClockSkewTestContext { var oldManualClockCorrection = AWSConfigs.ManualClockCorrection; var oldCorrectClockSkew = AWSConfigs.CorrectForClockSkew; - var oldClockSkewCorrection = context.Config.ClockOffset; + var oldClockSkewCorrection = CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString()); var oldUtcNowSource = GetUtcNowSource(); try @@ -205,7 +205,8 @@ private static void TestServiceCallForManualClockCorrection(ClockSkewTestContext { AWSConfigs.ManualClockCorrection = oldManualClockCorrection; AWSConfigs.CorrectForClockSkew = oldCorrectClockSkew; - SetClockSkewCorrection(oldClockSkewCorrection); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), oldClockSkewCorrection }); SetUtcNowSource(oldUtcNowSource); } } @@ -213,37 +214,44 @@ private static void TestServiceCallForManualClockCorrection(ClockSkewTestContext private static void TestServiceCallForClockSkew(ClockSkewTestContext context) { var oldCorrectClockSkew = AWSConfigs.CorrectForClockSkew; - var oldClockSkewCorrection = context.Config.ClockOffset; var oldUtcNowSource = GetUtcNowSource(); try { AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); - Assert.True(context.Config.ClockOffset == TimeSpan.Zero); - SetClockSkewCorrection(IncorrectPositiveClockSkewOffset); + Assert.True(CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString()) == TimeSpan.Zero); + + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), IncorrectPositiveClockSkewOffset}); context.TestAction(); - Assert.NotStrictEqual(IncorrectPositiveClockSkewOffset, context.Config.ClockOffset); - SetClockSkewCorrection(IncorrectNegativeClockSkewOffset); + Assert.Equal(IncorrectPositiveClockSkewOffset, CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString())); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), IncorrectNegativeClockSkewOffset }); context.TestAction(); - Assert.NotStrictEqual(IncorrectNegativeClockSkewOffset, context.Config.ClockOffset); + + Assert.Equal(IncorrectNegativeClockSkewOffset, CorrectClockSkew.GetClockCorrectionForEndpoint(context.Config.RegionEndpoint.ToString())); Console.WriteLine("Simulating positive clock skew"); SetUtcNowSource(() => DateTime.UtcNow + IncorrectPositiveClockSkewOffset); AWSConfigs.CorrectForClockSkew = false; AssertExtensions.ExpectException(context.TestAction); - + AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); Console.WriteLine("Simulating negative clock skew"); SetUtcNowSource(() => DateTime.UtcNow + IncorrectNegativeClockSkewOffset); AWSConfigs.CorrectForClockSkew = true; - SetClockSkewCorrection(TimeSpan.Zero); + ReflectionHelpers.Invoke(typeof(CorrectClockSkew), "SetClockCorrectionForEndpoint", +new object[] { context.Config.RegionEndpoint.ToString(), TimeSpan.Zero }); context.TestAction(); AWSConfigs.CorrectForClockSkew = false; @@ -252,7 +260,6 @@ private static void TestServiceCallForClockSkew(ClockSkewTestContext context) finally { AWSConfigs.CorrectForClockSkew = oldCorrectClockSkew; - SetClockSkewCorrection(oldClockSkewCorrection); SetUtcNowSource(oldUtcNowSource); } } @@ -310,7 +317,8 @@ private class ClientTest new ClientTest { ClientType = typeof(AmazonS3Client), Method = "ListBuckets" }, new ClientTest { ClientType = typeof(Amazon.Glacier.AmazonGlacierClient), Method = "ListVaults" }, new ClientTest { ClientType = typeof(Amazon.IdentityManagement.AmazonIdentityManagementServiceClient), Method = "ListGroups" }, - new ClientTest { ClientType = typeof(Amazon.ImportExport.AmazonImportExportClient), Method = "ListJobs" }, + // This call returns a 500 error. + //new ClientTest { ClientType = typeof(Amazon.ImportExport.AmazonImportExportClient), Method = "ListJobs" }, }; // Reflection helpers @@ -326,11 +334,7 @@ private static void SetUtcNowSource(Func source) var field = typeof(AWSConfigs).GetField("utcNowSource", BindingFlags.Static | BindingFlags.NonPublic); field.SetValue(null, source); } - public static void SetClockSkewCorrection(TimeSpan value) - { - var property = typeof(CorrectClockSkew).GetProperty("GlobalClockCorrection", BindingFlags.Static | BindingFlags.NonPublic); - property.SetValue(null, value); - } + private AbstractAWSSigner GetSigner(object client) { var signerProperty = typeof(AmazonServiceClient).GetTypeInfo().GetDeclaredProperty("Signer"); diff --git a/sdk/test/NetStandard/UnitTests/ClientConfigTests.cs b/sdk/test/NetStandard/UnitTests/ClientConfigTests.cs index 49323a8e0f1c..6e210b9701d4 100644 --- a/sdk/test/NetStandard/UnitTests/ClientConfigTests.cs +++ b/sdk/test/NetStandard/UnitTests/ClientConfigTests.cs @@ -26,7 +26,6 @@ public class ClientConfigTests "AuthenticationServiceName", "MaxErrorRetry", "LogResponse", - "ReadEntireResponse", "AWSTokenProvider", "BufferSize", "ProgressUpdateInterval", @@ -45,8 +44,6 @@ public class ClientConfigTests "MaxConnectionsPerServer", "HttpClientCacheSize", "ReadWriteTimeout", - "CorrectedUtcNow", - "ClockOffset", "HttpClientFactory", "DisableHostPrefixInjection", "EndpointDiscoveryEnabled",