From b348f993e721daff479f4cf71ec18b13cd40e990 Mon Sep 17 00:00:00 2001 From: Craig Treasure Date: Fri, 29 Jan 2021 12:47:48 -0800 Subject: [PATCH 1/2] Ignore sample tests --- .../tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs b/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs index 274a2aa0e320a..f948bda26252b 100644 --- a/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs +++ b/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs @@ -12,6 +12,7 @@ namespace Azure.MixedReality.Authentication.Tests.Samples { + [Ignore("Don't run sample tests since they require extra curricular account setup.")] public class MixedRealityStsClientSamples : SamplesBase { [Test] From 067e91410e08ac3352de562c2ef07f23112bff96 Mon Sep 17 00:00:00 2001 From: Craig Treasure Date: Fri, 29 Jan 2021 15:41:45 -0800 Subject: [PATCH 2/2] Remove sample tests --- ...MixedRealityStsClientSamples.HelloWorld.cs | 137 ------------------ 1 file changed, 137 deletions(-) delete mode 100644 sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs diff --git a/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs b/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs deleted file mode 100644 index f948bda26252b..0000000000000 --- a/sdk/mixedreality/Azure.MixedReality.Authentication/tests/Samples/MixedRealityStsClientSamples.HelloWorld.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.TestFramework; -using Azure.Identity; -using NUnit.Framework; - -namespace Azure.MixedReality.Authentication.Tests.Samples -{ - [Ignore("Don't run sample tests since they require extra curricular account setup.")] - public class MixedRealityStsClientSamples : SamplesBase - { - [Test] - public void GetTokenUsingAccountKeyCredential() - { - string mixedRealityAccountDomain = TestEnvironment.AccountDomain; - string mixedRealityAccountId = TestEnvironment.AccountId; - string mixedRealityAccountKey = TestEnvironment.AccountKey; - - #region Snippet:GetTokenUsingAccountKeyCredential - - MixedRealityStsClient client = new MixedRealityStsClient(mixedRealityAccountId, mixedRealityAccountDomain, new AzureKeyCredential(mixedRealityAccountKey)); - - AccessToken token = client.GetToken(); - - Console.WriteLine($"My access token ({token.Token}) expires on {token.ExpiresOn}."); - - #endregion Snippet:GetTokenUsingAccountKeyCredential - } - - [Test] - public void GetTokenUsingClientSecretCredential() - { - string clientId = TestEnvironment.ClientId; - string clientSecret = TestEnvironment.ClientSecret; - string tenantId = TestEnvironment.TenantId; - string mixedRealityAccountDomain = TestEnvironment.AccountDomain; - string mixedRealityAccountId = TestEnvironment.AccountId; - - #region Snippet:GetTokenUsingClientSecretCredential - - TokenCredential clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret, new TokenCredentialOptions - { - AuthorityHost = new Uri($"https://login.microsoftonline.com/{tenantId}") - }); - - MixedRealityStsClient client = new MixedRealityStsClient(mixedRealityAccountId, mixedRealityAccountDomain, clientSecretCredential); - - AccessToken token = client.GetToken(); - - Console.WriteLine($"My access token ({token.Token}) expires on {token.ExpiresOn}."); - - #endregion Snippet:GetTokenUsingClientSecretCredential - } - - [Test] - public void GetTokenUsingDefaultAzureCredential() - { - string mixedRealityAccountDomain = TestEnvironment.AccountDomain; - string mixedRealityAccountId = TestEnvironment.AccountId; - - #region Snippet:GetTokenUsingDefaultAzureCredential - - MixedRealityStsClient client = new MixedRealityStsClient(mixedRealityAccountId, mixedRealityAccountDomain, new DefaultAzureCredential()); - - AccessToken token = client.GetToken(); - - Console.WriteLine($"My access token ({token.Token}) expires on {token.ExpiresOn}."); - - #endregion Snippet:GetTokenUsingDefaultAzureCredential - } - - [Test] - public void GetTokenUsingDeviceCodeCredential() - { - string tenantId = TestEnvironment.TenantId; - string clientId = TestEnvironment.ClientId; - string mixedRealityAccountDomain = TestEnvironment.AccountDomain; - string mixedRealityAccountId = TestEnvironment.AccountId; - - #region Snippet:GetTokenUsingDefaultAzureCredential - - string authority = $"https://login.microsoftonline.com/{tenantId}"; - - Task deviceCodeCallback(DeviceCodeInfo deviceCodeInfo, CancellationToken cancellationToken) - { - Debug.WriteLine(deviceCodeInfo.Message); - Console.WriteLine(deviceCodeInfo.Message); - return Task.FromResult(0); - } - - TokenCredential deviceCodeCredential = new DeviceCodeCredential(deviceCodeCallback, tenantId, clientId, new TokenCredentialOptions - { - AuthorityHost = new Uri(authority), - }); - - MixedRealityStsClient client = new MixedRealityStsClient(mixedRealityAccountId, mixedRealityAccountDomain, deviceCodeCredential); - - AccessToken token = client.GetToken(); - - Console.WriteLine($"My access token ({token.Token}) expires on {token.ExpiresOn}."); - - #endregion Snippet:GetTokenUsingDefaultAzureCredential - } - - [Test] - public void GetTokenUsingVisualStudioCredential() - { - string tenantId = TestEnvironment.TenantId; - string mixedRealityAccountDomain = TestEnvironment.AccountDomain; - string mixedRealityAccountId = TestEnvironment.AccountId; - - #region Snippet:GetTokenUsingVisualStudioCredential - - string authority = $"https://login.microsoftonline.com/{tenantId}"; - - VisualStudioCredential visualStudioCredential = new VisualStudioCredential(new VisualStudioCredentialOptions - { - AuthorityHost = new Uri(authority), - TenantId = tenantId, - }); - - MixedRealityStsClient client = new MixedRealityStsClient(mixedRealityAccountId, mixedRealityAccountDomain, visualStudioCredential); - - AccessToken token = client.GetToken(); - - Console.WriteLine($"My access token ({token.Token}) expires on {token.ExpiresOn}."); - - #endregion Snippet:GetTokenUsingVisualStudioCredential - } - } -}