public void ValidateRequiredMicrosoftIdentityOptions( string clientId, string instance, string tenantid, string signUpSignInPolicyId, string domain, string optionsName, MissingParam missingParam = MissingParam.None) { _microsoftIdentityOptions = new MicrosoftIdentityOptions { ClientId = clientId, Instance = instance, TenantId = tenantid, }; if (optionsName == AzureAdB2C) { _microsoftIdentityOptions.SignUpSignInPolicyId = signUpSignInPolicyId; _microsoftIdentityOptions.Domain = domain; } MicrosoftIdentityOptionsValidation microsoftIdentityOptionsValidation = new MicrosoftIdentityOptionsValidation(); ValidateOptionsResult result = microsoftIdentityOptionsValidation.Validate(optionsName, _microsoftIdentityOptions); CheckReturnValueAgainstExpectedMissingParam(missingParam, result); }
private void CheckReturnValueAgainstExpectedMissingParam(MissingParam missingParam, ValidateOptionsResult result) { if (result.Failed) { string message = string.Format(CultureInfo.InvariantCulture, IDWebErrorMessage.ConfigurationOptionRequired, missingParam); Assert.Equal(message, result.FailureMessage); } else { Assert.True(result.Succeeded); } }
private void CheckReturnValueAgainstExpectedMissingParam(MissingParam missingParam, ValidateOptionsResult result) { if (result.Failed == true) { string msg = string.Format(CultureInfo.InvariantCulture, "The '{0}' option must be provided.", missingParam); Assert.Equal(msg, result.FailureMessage); } else { Assert.True(result.Succeeded); } }
public void ValidateRequiredMicrosoftIdentityOptions( string clientId, string instance, string tenantid, string signUpSignInPolicyId, string domain, string optionsName, MissingParam missingParam = MissingParam.None) { if (optionsName == AzureAdB2C) { _microsoftIdentityOptionsMonitor = new TestOptionsMonitor <MicrosoftIdentityOptions>(new MicrosoftIdentityOptions { SignUpSignInPolicyId = signUpSignInPolicyId, Domain = domain, ClientId = clientId, Instance = instance, TenantId = tenantid, }); } else { _microsoftIdentityOptionsMonitor = new TestOptionsMonitor <MicrosoftIdentityOptions>(new MicrosoftIdentityOptions { ClientId = clientId, Instance = instance, TenantId = tenantid, }); } BuildTheRequiredServices(); MergedOptions mergedOptions = _provider.GetRequiredService <IOptionsMonitor <MergedOptions> >().Get(OpenIdConnectDefaults.AuthenticationScheme); MergedOptions.UpdateMergedOptionsFromMicrosoftIdentityOptions(_microsoftIdentityOptionsMonitor.Get(OpenIdConnectDefaults.AuthenticationScheme), mergedOptions); if (missingParam != MissingParam.None) { var exception = Assert.Throws <ArgumentNullException>(() => MergedOptionsValidation.Validate(mergedOptions)); CheckReturnValueAgainstExpectedMissingParam(missingParam, exception); } else { MergedOptionsValidation.Validate(mergedOptions); } }
private void CheckReturnValueAgainstExpectedMissingParam(MissingParam missingParam, ArgumentNullException exception) { Assert.Equal(string.Format(CultureInfo.InvariantCulture, IDWebErrorMessage.ConfigurationOptionRequired, missingParam), exception.Message); }