예제 #1
0
        public void ShouldAddAndRemoveAndroidMAMGroupsForPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests"))
            {
                //Initialize aadClient if the test mode is not Playback
                AADClientHelper aadClient = null;
                if (HttpMockServer.Mode != HttpRecorderMode.Playback)
                {
                    aadClient = new AADClientHelper();
                }

                var client = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                //Create a policy
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneAndroidPolicy);
                var    payload      = DefaultAndroidPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated1 = client.Android.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Get groups for tenant
                    var adGroup = TestContextHelper.GetAdGroupFromTestContext("adGroup");

                    //Add group for the policy
                    var groupPayload1 = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(client, LinkType.GroupType, adGroup);
                    client.Android.AddGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup, groupPayload1);

                    //Get groups for the policy
                    var groups = client.Android.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 1, string.Format("Expected groups.Count == 1 and actual:{0}", groups.Count));

                    //Remove groups from the policy
                    client.Android.DeleteGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup);

                    //Get groups for the policy & verify groups are removed.
                    groups = client.Android.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 0, string.Format("Expected groups.Count == 0 but actual groups.Count = {0}", groups.Count));
                }
                finally
                {
                    client.Android.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
예제 #2
0
        public void ShouldAddAndRemoveAndroidMAMAppForPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.AppScenarioTests"))
            {
                var client = IntuneClientHelper.GetIntuneResourceManagementClient(context);

                //Create a policy
                string policyName    = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName1 = TestUtilities.GenerateName(IntuneConstants.IntuneAndroidPolicy);
                var    payload       = DefaultAndroidPolicy.GetPayload(friendlyName1);
                try
                {
                    var policyCreated1 = client.Android.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Get apps for Android
                    string filter      = string.Format(IntuneConstants.PlatformTypeQuery, PlatformType.Android.ToString().ToLower());
                    var    androidApps = client.GetApps(IntuneClientHelper.AsuHostName, filter).ToList();
                    Assert.True(androidApps.Count >= 1, string.Format("Expected androidApps.Count>=1 and actual:{0}", androidApps.Count));

                    //Add app for the policy
                    var appPayload1 = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(client, LinkType.AppType, androidApps[0].Name);
                    client.Android.AddAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, androidApps[0].Name, appPayload1);

                    //Get Apps for the policy
                    var apps = client.Android.GetAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(apps.Count == 1, string.Format("Expected apps.Count==1 and actual:{0}", apps.Count));

                    //Remove Apps for the policy
                    client.Android.DeleteAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, androidApps[0].Name);

                    //Get Apps for the policy
                    apps = client.Android.GetAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(apps.Count == 0, string.Format("Expected apps.Count==0 and actual:{0}", apps.Count));
                }
                finally
                {
                    client.Android.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
예제 #3
0
        public void ShouldAddAndRemoveiOSMAMGroupsForPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests"))
            {
                var client = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                //Create a policy
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneiOSPolicy);
                var    payload      = DefaultiOSPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated1 = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Get groups for tenant
                    var adGroup = TestContextHelper.GetAdGroupFromTestContext("adGroup");

                    //Add group for the policy
                    var groupPayload1 = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(client, LinkType.GroupType, adGroup);
                    client.Ios.AddGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup, groupPayload1);

                    //Get groups for the policy
                    var groups = client.Ios.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 1, string.Format("Expected groups.Count == 1 and actual:{0}", groups.Count));

                    //Remove groups for the policy
                    client.Ios.DeleteGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup);

                    //Get groups for the policy & verify unlinking
                    groups = client.Ios.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 0, string.Format("Expected groups.Count == 0 and actual:{0}", groups.Count));
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }