Skip to content

Commit

Permalink
Fix for #4608- do not throw exception for ADFS + WithTenantId (#4753)
Browse files Browse the repository at this point in the history
Fix for #2509 - do not throw exception for ADFS + WithTenantId
  • Loading branch information
bgavrilMS committed May 13, 2024
1 parent 60b9bb2 commit be0ea5c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ internal T WithHttpManager(IHttpManager httpManager)
/// If both WithLogging apis are set, this one will override the other
/// </param>
/// <returns>The builder to chain the .With methods</returns>
/// <remarks>This is an experimental API. The method signature may change in the future without involving a major version upgrade.</remarks>
public T WithLogging(
IIdentityLogger identityLogger,
bool enablePiiLogging = false)
Expand Down Expand Up @@ -218,13 +217,6 @@ internal void ResolveAuthority()
// Both WithAuthority and WithTenant were used at app config level
if (!string.IsNullOrEmpty(Config.TenantId))
{
if (!Config.Authority.AuthorityInfo.CanBeTenanted)
{
throw new MsalClientException(
MsalError.TenantOverrideNonAad,
$"Cannot use WithTenantId(tenantId) in the application builder, because the authority {Config.Authority.AuthorityInfo.AuthorityType} doesn't support it.");
}

string tenantedAuthority = Config.Authority.GetTenantedAuthority(
Config.TenantId,
forceSpecifiedTenant: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,34 +175,6 @@ public void B2CAuthorityWithTenantAppLevel()
AuthorityHelpers.GetTenantId(new Uri(cca.Authority)));
}

[TestMethod]
public void GenericAuthorityWithTenant()
{
var ex = AssertException.Throws<MsalClientException>(() =>
ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithTenantId(TestConstants.TenantId2)
.WithOidcAuthority(TestConstants.GenericAuthority)
.Build()
);

Assert.AreEqual(ex.ErrorCode, MsalError.TenantOverrideNonAad);
}

[TestMethod]
public void AdfsAuthorityWithTenant()
{
var ex = AssertException.Throws<MsalClientException>(() =>
ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithTenantId(TestConstants.TenantId2)
.WithAuthority(TestConstants.ADFSAuthority)
.Build()
);

Assert.AreEqual(ex.ErrorCode, MsalError.TenantOverrideNonAad);
}

[TestMethod]
public void WithTenantId_B2C()
{
Expand Down

0 comments on commit be0ea5c

Please sign in to comment.