Example #1
0
        public void ClientSecretCredentialWithOptionsFailureTest(string tenantId, string clientId, string clientSecret, bool useHostString)
        {
            var options    = AzureOauthTokenAuthentication.GetOptions(useHostString ? AzureOauthTokenAuthentication.DefaultAuthorityHost : null);
            var credential = AzureOauthTokenAuthentication.GetOauthTokenCredentialFromClientSecret(tenantId, clientId, clientSecret, options);

            Assert.IsNotNull(credential, "Credential should not be null");
        }
Example #2
0
        public void ManagedIdentityBaseWithOptionsTest(bool useHostString)
        {
            var options    = AzureOauthTokenAuthentication.GetOptions(useHostString ? AzureOauthTokenAuthentication.DefaultAuthorityHost : null);
            var credential = AzureOauthTokenAuthentication.GetOauthTokenCredentialFromManagedIdentity(options);

            Assert.IsNotNull(credential, "Credential should not be null");
        }
Example #3
0
        public void ConfigureOptionRetries()
        {
            var options = AzureOauthTokenAuthentication.GetOptions();

            AzureOauthTokenAuthentication.ConfigureRetries(options, Azure.Core.RetryMode.Exponential, 100, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2));

            Assert.IsTrue(options.Retry.Delay == TimeSpan.FromSeconds(5), "Delay is not expected");
            Assert.IsTrue(options.Retry.MaxDelay == TimeSpan.FromMinutes(1), "MaximumDelay is not expected");
            Assert.IsTrue(options.Retry.NetworkTimeout == TimeSpan.FromMinutes(2), "Network Timeout is not expected");
            Assert.IsTrue(options.Retry.MaxRetries == 100, "Maximum retries is not expected");
        }
Example #4
0
        public void ConfigureOptionDiagnostics()
        {
            var options = AzureOauthTokenAuthentication.GetOptions();

            AzureOauthTokenAuthentication.ConfigureDiagnostics(options, "app1", true, true, true, true, 5000);

            Assert.IsTrue(options.Diagnostics.ApplicationId == "app1", "Application Id is not expected");
            Assert.IsTrue(options.Diagnostics.IsDistributedTracingEnabled, "DistributedTracingEnabled is not expected");
            Assert.IsTrue(options.Diagnostics.IsLoggingContentEnabled, "LoggingContentEnabled is not expected");
            Assert.IsTrue(options.Diagnostics.IsLoggingEnabled, "LoggingEnabled is not expected");
            Assert.IsTrue(options.Diagnostics.IsTelemetryEnabled, "LoggingEnabled is not expected");
            Assert.IsTrue(options.Diagnostics.LoggedContentSizeLimit == 5000, "LoggedContentSizeLimit is not expected");
            Assert.IsTrue(options.Diagnostics.LoggedHeaderNames.Count > 0, "LoggedHeaderNames is not expected");
            Assert.IsTrue(options.Diagnostics.LoggedQueryParameters.Count == 0, "LoggedQueryParameters is not expected");
        }