Exemplo n.º 1
0
        public void CanProvisionObjects()
        {
#if !ONPREMISES
            var template = new ProvisioningTemplate {
                ParentHierarchy = new ProvisioningHierarchy()
            };

            foreach (var teamTemplate in _teamTemplates)
            {
                template.ParentHierarchy.Teams.TeamTemplates.Add(new TeamTemplate {
                    JsonTemplate = teamTemplate
                });
            }

            using (new PnPProvisioningContext((resource, scope) => Task.FromResult(TestCommon.AcquireTokenAsync(resource, scope))))
            {
                using (var ctx = TestCommon.CreateTenantClientContext())
                {
                    var tenant = new Tenant(ctx);
                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectTeams().ProvisionObjects(tenant, template.ParentHierarchy, null, parser, new ProvisioningTemplateApplyingInformation());
                }

                Assert.IsTrue(TeamsHaveBeenProvisioned());
            }
#else
            Assert.Inconclusive();
#endif
        }
Exemplo n.º 2
0
        public void CanProvisionObjects()
        {
#if !ONPREMISES
            if (TestCommon.AppOnlyTesting())
            {
                Assert.Inconclusive("This test requires a user credentials, cannot be run using app-only for now");
            }

            using (new PnPProvisioningContext((resource, scope) => Task.FromResult(TestCommon.AcquireTokenAsync(resource, scope))))
            {
                var template = new ProvisioningTemplate {
                    ParentHierarchy = new ProvisioningHierarchy()
                };

                template.ParentHierarchy.Teams.TeamTemplates.Add(new TeamTemplate {
                    JsonTemplate = _jsonTemplate
                });
                template.ParentHierarchy.Teams.Teams.Add(_team);

                Provision(template);

                // Wait for groups to be provisioned
                Thread.Sleep(5000);

                // Verify if Teams have been provisioned
                foreach (var teamName in _teamNames)
                {
                    var teams = GetTeamsByDisplayName(teamName);
                    Assert.IsTrue(teams.HasValues);
                }
            }
#else
            Assert.Inconclusive();
#endif
        }
Exemplo n.º 3
0
 private static void Provision(ProvisioningTemplate template)
 {
     using (new PnPProvisioningContext((resource, scope) => Task.FromResult(TestCommon.AcquireTokenAsync(resource, scope))))
     {
         using (var ctx = TestCommon.CreateTenantClientContext())
         {
             var tenant = new Tenant(ctx);
             var parser = new TokenParser(ctx.Web, template);
             new ObjectTeams().ProvisionObjects(tenant, template.ParentHierarchy, null, parser, new Core.Framework.Provisioning.Model.Configuration.ApplyConfiguration());
         }
     }
 }
        public void Initialize()
        {
            _accessToken = TestCommon.AcquireTokenAsync("https://graph.microsoft.com");

            TestCommon.FixAssemblyResolving("Newtonsoft.Json");

            var random = new Random();

            _groupId = UnifiedGroupsUtility.CreateUnifiedGroup("PnPDeletedUnifiedGroup test", "PnPDeletedUnifiedGroup test", $"pnp-unit-test-{random.Next(1, 1000)}", _accessToken, groupLogo: null).GroupId;

            UnifiedGroupsUtility.DeleteUnifiedGroup(_groupId, _accessToken);
        }
Exemplo n.º 5
0
        public void CleanUp()
        {
            using (new PnPProvisioningContext((resource, scope) => Task.FromResult(TestCommon.AcquireTokenAsync(resource, scope))))
            {
                foreach (var teamName in _teamNames)
                {
                    var teams = GetTeamsByDisplayName(teamName);

                    foreach (var team in teams)
                    {
                        DeleteTeam(team["id"].ToString());
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void CanUpdateObjects()
        {
#if !ONPREMISES
            if (TestCommon.AppOnlyTesting())
            {
                Assert.Inconclusive("This test requires a user credentials, cannot be run using app-only for now");
            }

            using (new PnPProvisioningContext((resource, scope) => Task.FromResult(TestCommon.AcquireTokenAsync(resource, scope))))
            {
                // Prepare the hierarchy for provisioning
                var template = new ProvisioningTemplate {
                    ParentHierarchy = new ProvisioningHierarchy()
                };

                template.ParentHierarchy.Teams.Teams.Add(_team);

                // Initial provisioning of a Team
                Provision(template);

                // Get the just provisioned Team
                var provisionedTeam = GetTeamsByDisplayName(_team.DisplayName)?.FirstOrDefault();
                if (provisionedTeam != null && provisionedTeam.HasValues)
                {
                    // Store locally the just created Team ID
                    var teamId = provisionedTeam["id"].ToString();

                    // Now update the Team and test delta handling
                    template.ParentHierarchy.Teams.Teams[0].FunSettings.AllowGiphy =
                        !template.ParentHierarchy.Teams.Teams[0].FunSettings.AllowGiphy;
                    template.ParentHierarchy.Teams.Teams[0].GuestSettings.AllowCreateUpdateChannels =
                        !template.ParentHierarchy.Teams.Teams[0].GuestSettings.AllowCreateUpdateChannels;
                    template.ParentHierarchy.Teams.Teams[0].MemberSettings.AllowDeleteChannels =
                        !template.ParentHierarchy.Teams.Teams[0].MemberSettings.AllowDeleteChannels;
                    template.ParentHierarchy.Teams.Teams[0].MessagingSettings.AllowUserEditMessages =
                        !template.ParentHierarchy.Teams.Teams[0].MessagingSettings.AllowUserEditMessages;
                    template.ParentHierarchy.Teams.Teams[0].Channels[0].Description += " - Updated";
                    template.ParentHierarchy.Teams.Teams[0].Channels[0].Tabs.Add(new TeamTab
                    {
                        DisplayName = "OneNote Tab 2",
                        TeamsAppId  = "0d820ecd-def2-4297-adad-78056cde7c78"
                    });

                    template.ParentHierarchy.Teams.Teams[0].Security.AllowToAddGuests = true;

                    Provision(template);

                    var team             = GetTeamById(teamId);
                    var existingChannels = GetTeamChannels(teamId);
                    var existingTabs     = GetTeamChannelTabs(teamId, existingChannels[1]["id"].ToString());
                    var allowToAddGuests = GetAllowToAddGuests(teamId);

                    Assert.AreEqual(team["funSettings"]["allowGiphy"].Value <Boolean>(),
                                    template.ParentHierarchy.Teams.Teams[0].FunSettings.AllowGiphy);
                    Assert.AreEqual(team["guestSettings"]["allowCreateUpdateChannels"].Value <Boolean>(),
                                    template.ParentHierarchy.Teams.Teams[0].GuestSettings.AllowCreateUpdateChannels);
                    Assert.AreEqual(team["memberSettings"]["allowDeleteChannels"].Value <Boolean>(),
                                    template.ParentHierarchy.Teams.Teams[0].MemberSettings.AllowDeleteChannels);
                    Assert.AreEqual(team["messagingSettings"]["allowUserEditMessages"].Value <Boolean>(),
                                    template.ParentHierarchy.Teams.Teams[0].MessagingSettings.AllowUserEditMessages);
                    Assert.AreEqual(existingChannels[1]["description"],
                                    template.ParentHierarchy.Teams.Teams[0].Channels[0].Description);
                    Assert.IsTrue(existingTabs.Any(t => t["displayName"].ToString() == template.ParentHierarchy.Teams.Teams[0].Channels[0].Tabs[1].DisplayName));
                    Assert.IsTrue(allowToAddGuests);
                }
                else
                {
                    // If the Team wasn't created ... just fail
                    Assert.IsTrue(false);
                }
            }
#else
            Assert.Inconclusive();
#endif
        }