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);
                }
            }
        }
Beispiel #2
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);
                }
            }
        }
        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);
                }
            }
        }
Beispiel #4
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);
                }
            }
        }
        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);
                }
            }
        }
Beispiel #6
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);
                }
            }
        }