public void ShouldPatchiOSPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests"))
            {
                var    client       = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneiOSPolicy);
                var    payload      = DefaultiOSPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Modified properties to patch..
                    var appSharingFromLevelUpdated         = AppSharingType.allApps.ToString();
                    var accessRecheckOfflineTimeoutUpdated = new TimeSpan(24, 0, 0);
                    int pinNumRetryUpdated = 50;
                    client.Ios.PatchMAMPolicy(IntuneClientHelper.AsuHostName,
                                              policyName,
                                              new Models.IOSMAMPolicy
                    {
                        AppSharingFromLevel         = appSharingFromLevelUpdated,
                        AccessRecheckOfflineTimeout = accessRecheckOfflineTimeoutUpdated,
                        PinNumRetry = pinNumRetryUpdated
                    });

                    var policy = client.Ios.GetMAMPolicyByName(IntuneClientHelper.AsuHostName, policyName);

                    Assert.True(policy.Id.Contains(policyName));
                    Assert.Equal(policy.FriendlyName, friendlyName);

                    //Verify updated properties
                    Assert.Equal(policy.AppSharingFromLevel, appSharingFromLevelUpdated);
                    Assert.Equal(policy.AccessRecheckOfflineTimeout, accessRecheckOfflineTimeoutUpdated);
                    Assert.Equal(policy.PinNumRetry, pinNumRetryUpdated);

                    //Verify couple of properties that are not supposed to be updated.
                    Assert.Equal(policy.ManagedBrowser, ChoiceType.required.ToString());
                    Assert.Equal(policy.AccessRecheckOnlineTimeout, TimeSpan.FromMinutes(IntuneConstants.DefaultRecheckAccessTimeoutMinutes));
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
        public void ShouldCreateiOSPolicyWithDefaults()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests"))
            {
                var    client       = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneiOSPolicy);
                var    payload      = DefaultiOSPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    var policy = client.Ios.GetMAMPolicyByName(IntuneClientHelper.AsuHostName, policyName);
                    Assert.True(policy.Id.Contains(policyName));
                    Assert.Equal(policy.FriendlyName, friendlyName);

                    //Verify defaults
                    Assert.Equal(policy.AppSharingToLevel, AppSharingType.none.ToString());
                    Assert.Equal(policy.Description, Properties.Resources.AndroidPolicyDescription);
                    Assert.Equal(policy.AppSharingFromLevel, AppSharingType.none.ToString());
                    Assert.Equal(policy.Authentication, ChoiceType.required.ToString());
                    Assert.Equal(policy.ClipboardSharingLevel, ClipboardSharingLevelType.blocked.ToString());
                    Assert.Equal(policy.DataBackup, FilterType.allow.ToString());
                    Assert.Equal(policy.FileSharingSaveAs, FilterType.allow.ToString());
                    Assert.Equal(policy.Pin, ChoiceType.required.ToString());
                    Assert.Equal(policy.PinNumRetry, IntuneConstants.DefaultPinRetries);
                    Assert.Equal(policy.DeviceCompliance, OptionType.enable.ToString());
                    Assert.Equal(policy.ManagedBrowser, ChoiceType.required.ToString());
                    Assert.Equal(policy.AccessRecheckOfflineTimeout, TimeSpan.FromMinutes(IntuneConstants.DefaultRecheckAccessOfflineGraceperiodMinutes));
                    Assert.Equal(policy.AccessRecheckOnlineTimeout, TimeSpan.FromMinutes(IntuneConstants.DefaultRecheckAccessTimeoutMinutes));
                    Assert.Equal(policy.OfflineWipeTimeout, TimeSpan.FromDays(IntuneConstants.DefaultOfflineWipeIntervalDays));

                    //Verify iOS specific defaults
                    Assert.Equal(policy.FileEncryptionLevel, DeviceLockType.deviceLocked.ToString());
                    Assert.Equal(policy.TouchId, OptionType.enable.ToString());
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
예제 #3
0
        public void ShouldAddAndRemoveiOSMAMAppForPolicy()
        {
            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.IntuneiOSPolicy);
                var    payload       = DefaultiOSPolicy.GetPayload(friendlyName1);
                try
                {
                    var policyCreated1 = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

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

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

                    //Get Apps for the policy
                    var apps = client.Ios.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.Ios.DeleteAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, iosApps[0].Name);

                    //Get Apps for the policy
                    apps = client.Ios.GetAppForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(apps.Count == 0, string.Format("Expected apps.Count==0 and actual:{0}", apps.Count));
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
        public void ShouldGetMultipleiOSPolicies()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.PolicyScenarioTests"))
            {
                var    client      = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                string policyName1 = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy1").ToString();
                string policyName2 = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy2").ToString();
                try
                {
                    string friendlyName1         = TestUtilities.GenerateName(IntuneConstants.IntuneAndroidPolicy);
                    string friendlyName2         = TestUtilities.GenerateName(IntuneConstants.IntuneAndroidPolicy);
                    List <IOSMAMPolicy> policies = new List <IOSMAMPolicy>();
                    var payload1       = DefaultiOSPolicy.GetPayload(friendlyName1);
                    var policyCreated1 = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName1,
                        payload1);

                    policyName2 = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();

                    var payload2       = DefaultiOSPolicy.GetPayload(friendlyName1);
                    var policyCreated2 = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName2,
                        payload2);

                    policies = client.Ios.GetMAMPolicies(IntuneClientHelper.AsuHostName, null).ToList();
                    int cnt = 0;
                    policies.ForEach(p => { if (p.FriendlyName == friendlyName1 || p.FriendlyName == friendlyName2)
                                            {
                                                cnt++;
                                            }
                                     });
                    Assert.True(2 == cnt, "Less than 2 created policies returned");
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName1);
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName2);
                }
            }
        }
예제 #5
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);
                }
            }
        }