Skip to content

Commit 1529c4b

Browse files
authored
Merge pull request #373 from ckadluba/azure-tennant-tests-fixes
Additional tests for Azure managed identity tennant Id.
2 parents 1d1f115 + 49fa409 commit 1529c4b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/AzureManagedServiceAuthenticatorStubTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void InitializeDoesNotThrowsIfUseAzureManagedIdentityIsFalse()
1818
public void InitializeThrowsIfUseAzureManagedIdentityIsTrue()
1919
{
2020
// Throws because operation is not supported on the target framework that uses stub implementation
21-
Assert.Throws<InvalidOperationException>(() => new AzureManagedServiceAuthenticator(true, "TestAccessToken"));
21+
Assert.Throws<InvalidOperationException>(() => new AzureManagedServiceAuthenticator(true, "TestAccessToken", "TestTennantId"));
2222
}
2323
}
2424
}

test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/AzureManagedServiceAuthenticatorTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,15 @@ public async Task GetAuthenticationTokenThrowsIfUseAzureManagedIdentityIsTrueAnd
5050
// Act + assert
5151
await Assert.ThrowsAsync<AzureServiceTokenProviderException>(() => sut.GetAuthenticationToken()).ConfigureAwait(false);
5252
}
53+
54+
[Fact]
55+
public async Task GetAuthenticationTokenThrowsIfUseAzureManagedIdentityIsTrueAndTennantInvalid()
56+
{
57+
// Arrange
58+
var sut = new AzureManagedServiceAuthenticator(true, "https://database.windows.net/", "TestTennantId");
59+
60+
// Act + assert
61+
await Assert.ThrowsAsync<AzureServiceTokenProviderException>(() => sut.GetAuthenticationToken()).ConfigureAwait(false);
62+
}
5363
}
5464
}

0 commit comments

Comments
 (0)