public async Task TestAuthenticateAsync() { var options = new AadApplicationOptions(TestClientId, TestTenantId).WithClientSecret(TestClientSecret); var key = new AadAccessKey(options, TestEndpoint, TestPort); await key.UpdateAccessKeyAsync("serverId"); Assert.True(key.Authorized); Assert.NotNull(key.Id); Assert.NotNull(key.Value); }
public async Task TestAuthenticateAsync() { var options = new AadApplicationOptions(TestClientId, TestTenantId).WithClientSecret(TestClientSecret); var key = new AadAccessKey(options); await key.AuthorizeAsync("http://localhost", 8080, "serverId"); Assert.True(key.Authorized); Assert.NotNull(key.Id); Assert.NotNull(key.Value); }
public void TestBuildAuthority() { Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "An invalid tenant id")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", ".00000000-0000-0000-0000-000000000000")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "00000000-0000-0000-0000-000000000000.")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "00000000-0000-0000-θθθθ-000000000000")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "0000-0000-0000-θθθθθθθθ-000000000000")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "00000000-abcd-efgh-0000-000000000000")); Assert.Throws <FormatException>(() => new AadApplicationOptions("foo", "00000000-ABCD-EFGH-0000-000000000000")); AadApplicationOptions options; options = new AadApplicationOptions("foo", "00000000-0000-0000-0000-000000000000"); Assert.Equal("https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000", options.BuildAuthority().ToString()); options = new AadApplicationOptions("foo", "00000000-abcd-efab-cdef-000000000000"); options.WithDogfood(); Assert.Equal("https://login.windows-ppe.net/00000000-abcd-efab-cdef-000000000000", options.BuildAuthority().ToString()); }
public async Task TestAcquireAccessToken() { var options = new AadApplicationOptions(TestClientId, TestTenantId).WithClientSecret(TestClientSecret); var token = await options.AcquireAccessToken(); }