Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Microsoft.Azure.Management.Intune.Tests.Helpers
/// <summary>
/// Types of environment in Intune
/// </summary>
internal enum EnvironmentType
public enum EnvironmentType
{
OneBox,
Dogfood,
Expand All @@ -38,7 +38,7 @@ internal enum EnvironmentType
/// <summary>
/// Azure Active directory related operations helper class.
/// </summary>
internal class AADClientHelper
public class AADClientHelper
{
public const string AadAuthDogfoodEnpoint = "https://login.windows-ppe.net/";

Expand Down Expand Up @@ -87,7 +87,25 @@ private set
}
}

public AADClientHelper(string userName, string password, EnvironmentType env)
public AADClientHelper()
{
var orgIdAuth = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");
var parts = orgIdAuth.Split(new char[] { ';' }).ToList();
var authParams = new Dictionary<string, string>();
parts.ForEach(a => { var splitVal = a.Split(new char[] { '=' }); authParams.Add(splitVal[0], splitVal[1]); });
EnvironmentType enType = EnvironmentType.Dogfood;
if (authParams["Environment"] == "Dogfood")
{
enType = EnvironmentType.Dogfood;
}
else if (authParams["Environment"] == "Prod")
{
enType = EnvironmentType.Prod;
}

InitializeAADClient(authParams["UserId"], authParams["Password"], enType);
}
private void InitializeAADClient(string userName, string password, EnvironmentType env)
{
this.userName = userName;
this.password = password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ internal static string AsuHostName
internal static void InitializeEnvironment()
{ //Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", "SubscriptionId=3e9e6f07-6225-4d10-8fd4-5f0236c28f5a;Environment=Dogfood;[email protected];Password=XXXXXXX");
//Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", "SubscriptionId=None;Environment=Dogfood;[email protected];Password=XXXXXX");
//Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", "SubscriptionId=None;Environment=Prod;[email protected];Password=XXXXXX");

//AZURE_TEST_MODE = None, Record, Playback
//Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback");
Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using Microsoft.Azure.Test.HttpRecorder;
using System.Linq;

namespace Microsoft.Azure.Management.Intune.Tests.Helpers
{
Expand Down Expand Up @@ -43,5 +44,60 @@ public static T GetValueFromTestContext<T>(Func<T> constructor, Func<string, T>

return retValue;
}

public static string GetAdGroupFromTestContext(string mockName)
{
string retValue = string.Empty;
if (HttpMockServer.Mode != HttpRecorderMode.Playback)
{
var aadClient = new AADClientHelper();
var adGroups = aadClient.GetUserGroups().GetAwaiter().GetResult();
var adGroupList = adGroups.Where(x => x.Keys.Contains("ID")).Select(x => x["ID"]).ToList();
if (adGroupList.Count >= 1)
{
retValue = HttpMockServer.Variables[mockName] = adGroupList.ElementAt(0);
}
else
{
throw new Exception(string.Format("Unexpected number of Groups. Expected: adGroupList.Count >= 1 but actual = {0}", adGroupList.Count));
}
}
else
{
if (HttpMockServer.Variables.ContainsKey(mockName))
{
retValue = HttpMockServer.Variables[mockName];
}
else
{
throw new Exception(string.Format("HttpMockServer.Variables does not have a value to retrieve for mockName={0}", mockName));
}
}

return retValue;
}

public static string GetAdUserFromTestContext(string mockName)
{
string retValue = string.Empty;
if (HttpMockServer.Mode != HttpRecorderMode.Playback)
{
var aadClient = new AADClientHelper();
retValue = HttpMockServer.Variables[mockName] = aadClient.UserId;
}
else
{
if (HttpMockServer.Variables.ContainsKey(mockName))
{
retValue = HttpMockServer.Variables[mockName];
}
else
{
throw new Exception(string.Format("HttpMockServer.Variables does not have a value to retrieve for mockName={0}", mockName));
}
}

return retValue;
}
}
}
47 changes: 33 additions & 14 deletions src/ResourceManagement/Intune/Intune.Tests/Intune.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<Import Project="..\..\..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\..\..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<Import Project="..\..\..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -152,8 +152,10 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScenarioTests\App.ScenarioTests.cs" />
<Compile Include="ScenarioTests\FlaggedUser.ScenarioTests.cs" />
<Compile Include="ScenarioTests\Group.ScenarioTests.cs" />
<Compile Include="ScenarioTests\Policy.ScenarioTests.cs" />
<Compile Include="ScenarioTests\Wipe.ScenarioTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Intune\Intune.csproj">
Expand All @@ -164,35 +166,52 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldAddAndRemoveAndroidMAMAppForPolicy.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldAddAndRemoveAndroidMAMAppForPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldAddAndRemoveiOSMAMAppForPolicy.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldAddAndRemoveiOSMAMAppForPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldGetAndroidMAMApps.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldGetAndroidMAMApps.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldGetiOSMAMApps.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests\ShouldGetiOSMAMApps.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests\ShouldAddAndRemoveiOSMAMGroupsForPolicy.json" />
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldCreateAndroidPolicyWithDefaults.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.FlaggedUserScenarioTests\ShouldGetDefaultStatuses.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldCreateiOSPolicyWithDefaults.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.FlaggedUserScenarioTests\ShouldGetFlaggedDevices.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldGetMultipleAndroidPolicies.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.FlaggedUserScenarioTests\ShouldGetFlaggedUsers.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldGetMultipleiOSPolicies.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests\ShouldAddAndRemoveAndroidMAMGroupsForPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldPatchAndroidPolicy.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests\ShouldAddAndRemoveiOSMAMGroupsForPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldPatchiOSPolicy.json">
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldCreateAndroidPolicyWithDefaults.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldCreateiOSPolicyWithDefaults.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldGetMultipleAndroidPolicies.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldGetMultipleiOSPolicies.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldPatchAndroidPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests\ShouldPatchiOSPolicy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Management.Intune.Tests.ScenarioTests.WipeScenarioTests\ShouldWipeDevices.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down Expand Up @@ -222,7 +241,7 @@
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

This file was deleted.

This file was deleted.

Loading