コード例 #1
0
        public void CleanUp()
        {
            if (!TestCommon.AppOnlyTesting())
            {
                using (var clientContext = TestCommon.CreateTenantClientContext())
                {
                    var tenant = new Tenant(clientContext);

                    var communicationSiteUrl = $"{baseUrl}/sites/site{communicationSiteGuid}";
                    if (tenant.SiteExistsAnywhere(communicationSiteUrl) != SiteExistence.No)
                    {
#if !ONPREMISES
                        tenant.DeleteSiteCollection(communicationSiteUrl, false);
#else
                        tenant.DeleteSiteCollection(communicationSiteUrl);
#endif
                    }

                    var teamSiteUrl = $"{baseUrl}/sites/site{teamSiteGuid}";
                    if (tenant.SiteExistsAnywhere(teamSiteUrl) != SiteExistence.No)
                    {
#if !ONPREMISES
                        tenant.DeleteSiteCollection(teamSiteUrl, false);
#else
                        tenant.DeleteSiteCollection(teamSiteUrl);
#endif
                    }

                    // Commented this, first group cleanup needs to be implemented in this test case
                    //tenant.DeleteSiteCollection($"{baseUrl}/sites/site{teamSiteGuid}", false);
                    //TODO: Cleanup group
                }
            }
        }
コード例 #2
0
 public static void ClassCleanup()
 {
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         CleanupAllTestSiteCollections(tenantContext);
     }
 }
コード例 #3
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
        }
コード例 #4
0
        public void SetSiteLockStateTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var    tenant          = new Tenant(tenantContext);
                string devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                if (!tenant.SiteExists(siteToCreateUrl))
                {
                    siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                    var siteExists = tenant.SiteExists(siteToCreateUrl);
                    Assert.IsTrue(siteExists, "Site collection creation failed");
                }

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);
                var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties2);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                //Delete site collection, also
                tenant.DeleteSiteCollection(siteToCreateUrl, false);
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
            }
        }
コード例 #5
0
        public async Task CanMapAssociatedGroupsToExistingOnesInNewScriptSite()
        {
            if (TestCommon.AppOnlyTesting())
            {
                Assert.Inconclusive("Site creation requires owner, so this will not yet work in app-only");
            }

            var newCommSiteUrl = string.Empty;

            ProvisioningTemplate template = new ProvisioningTemplate();

            template.Security.AssociatedOwnerGroup   = "These names shouldn't matter";
            template.Security.AssociatedMemberGroup  = "Site Members";
            template.Security.AssociatedVisitorGroup = "Dummy Visitors";
            // note: there are explicitly no SiteGroups defined

            using (var clientContext = TestCommon.CreateClientContext())
            {
                newCommSiteUrl = await CreateCommunicationSite(clientContext, "Dummy", true);
            }

            try
            {
                using (var ctx = TestCommon.CreateClientContext(newCommSiteUrl))
                {
                    ctx.Load(ctx.Web,
                             w => w.AssociatedOwnerGroup.Id,
                             w => w.AssociatedMemberGroup.Id,
                             w => w.AssociatedVisitorGroup.Id);
                    ctx.ExecuteQuery();
                    var oldOwnerGroupId   = ctx.Web.AssociatedOwnerGroup.Id;
                    var oldMemberGroupId  = ctx.Web.AssociatedMemberGroup.Id;
                    var oldVisitorGroupId = ctx.Web.AssociatedVisitorGroup.Id;

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectSiteSecurity().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    ctx.Load(ctx.Web,
                             w => w.AssociatedOwnerGroup.Id,
                             w => w.AssociatedMemberGroup.Id,
                             w => w.AssociatedVisitorGroup.Id);
                    ctx.ExecuteQuery();
                    var newOwnerGroupId   = ctx.Web.AssociatedOwnerGroup.Id;
                    var newMemberGroupId  = ctx.Web.AssociatedMemberGroup.Id;
                    var newVisitorGroupId = ctx.Web.AssociatedVisitorGroup.Id;

                    Assert.AreEqual(oldOwnerGroupId, newOwnerGroupId, "Unexpected new associated owner group");
                    Assert.AreEqual(oldMemberGroupId, newMemberGroupId, "Unexpected new associated member group");
                    Assert.AreEqual(oldVisitorGroupId, newVisitorGroupId, "Unexpected new associated visitor group");
                }
            }
            finally
            {
                using (var clientContext = TestCommon.CreateTenantClientContext())
                {
                    var tenant = new Tenant(clientContext);
                    tenant.DeleteSiteCollection(newCommSiteUrl, false);
                }
            }
        }
コード例 #6
0
        public void CreateDeleteSiteCollectionTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);

                //Create site collection test
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 1");
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 1.1");
                var siteExists = tenant.SiteExists(siteToCreateUrl);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 1.2");
                Assert.IsTrue(siteExists, "Site collection creation failed");

                //Delete site collection test: move to recycle bin
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 2");
                tenant.DeleteSiteCollection(siteToCreateUrl, true);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 2.1");
                bool recycled = tenant.CheckIfSiteExists(siteToCreateUrl, "Recycled");
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 2.2");
                Assert.IsTrue(recycled, "Site collection recycling failed");

                //Remove from recycle bin
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 3");
                tenant.DeleteSiteCollectionFromRecycleBin(siteToCreateUrl, true);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 3.1");
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 3.2");
                Assert.IsFalse(siteExists2, "Site collection deletion from recycle bin failed");
            }
        }
コード例 #7
0
        public void CreateDeleteCreateSiteCollectionTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);

                //Create site collection test
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                var    siteExists      = tenant.SiteExists(siteToCreateUrl);
                Assert.IsTrue(siteExists, "Site collection creation failed");

                //Delete site collection test: move to recycle bin
                tenant.DeleteSiteCollection(siteToCreateUrl, true);
                bool recycled = tenant.CheckIfSiteExists(siteToCreateUrl, "Recycled");
                Assert.IsTrue(recycled, "Site collection recycling failed");

                //Remove from recycle bin
                tenant.DeleteSiteCollectionFromRecycleBin(siteToCreateUrl, true);
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Assert.IsFalse(siteExists2, "Site collection deletion from recycle bin failed");

                //Create a site collection using the same url as the previously deleted site collection
                siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                siteExists      = tenant.SiteExists(siteToCreateUrl);
                Assert.IsTrue(siteExists, "Second site collection creation failed");
            }
        }
コード例 #8
0
        public static void ClassInitBase(TestContext context, bool noScriptSite = false)
        {
            // Drop all previously created site collections to keep the environment clean
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                if (!debugMode)
                {
                    CleanupAllTestSiteCollections(tenantContext);

                    // Each class inheriting from this base class gets a central test site collection, so let's create that one
                    var tenant = new Tenant(tenantContext);
                    centralSiteCollectionUrl = CreateTestSiteCollection(tenant, sitecollectionNamePrefix + Guid.NewGuid().ToString());

                    // Add a default sub site
                    centralSubSiteUrl = CreateTestSubSite(tenant, centralSiteCollectionUrl, centralSubSiteName);

#if !ONPREMISES
                    // Apply noscript setting
                    if (noScriptSite)
                    {
                        Console.WriteLine("Setting site {0} as NoScript", centralSiteCollectionUrl);
                        tenant.SetSiteProperties(centralSiteCollectionUrl, noScriptSite: true);
                    }
#endif
                }
            }
        }
コード例 #9
0
        public void PublishingFeatureActivationTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);

                //Create site collection test
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 1");
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                Console.WriteLine("CreateDeleteSiteCollectionTest: step 1.1");

                using (var clientContext = TestCommon.CreateClientContext(siteToCreateUrl))
                {
                    // Activate
                    clientContext.Site.ActivateFeature(Constants.FeatureId_Site_Publishing);
                    Assert.IsTrue(clientContext.Site.IsFeatureActive(Constants.FeatureId_Site_Publishing));
                    Console.WriteLine("2.1 Site publishing feature activated");

                    clientContext.Web.ActivateFeature(Constants.FeatureId_Web_Publishing);
                    Assert.IsTrue(clientContext.Web.IsFeatureActive(Constants.FeatureId_Web_Publishing));
                    Console.WriteLine("2.2 Web publishing feature activated");

                    // Finally deactivate again
                    clientContext.Web.DeactivateFeature(Constants.FeatureId_Web_Publishing);
                    Assert.IsFalse(clientContext.Web.IsFeatureActive(Constants.FeatureId_Web_Publishing));
                    Console.WriteLine("2.3 Web publishing feature deactivated");

                    clientContext.Site.DeactivateFeature(Constants.FeatureId_Site_Publishing);
                    Assert.IsFalse(clientContext.Site.IsFeatureActive(Constants.FeatureId_Site_Publishing));
                    Console.WriteLine("2.4 Site publishing feature deactivated");
                }
            }
        }
コード例 #10
0
        public void CanProvisionHierarchy()
        {
            XMLTemplateProvider provider =
                new XMLFileSystemTemplateProvider(
                    String.Format(@"{0}\..\..\Resources",
                                  AppDomain.CurrentDomain.BaseDirectory),
                    "Templates");

            var hierarchy = provider.GetHierarchy("ProvisioningSchema-2019-03-FullSample-01.xml");

            CanProvisionResult result = null;

            using (var pnpContext = new PnPProvisioningContext())
            {
                using (var tenantContext = TestCommon.CreateTenantClientContext())
                {
                    var applyingInformation = new ProvisioningTemplateApplyingInformation();
                    var tenant = new Tenant(tenantContext);
                    result = CanProvisionRulesManager.CanProvision(tenant, hierarchy, String.Empty, applyingInformation);
                }
            }

            Assert.IsNotNull(result);
            Assert.IsTrue(result.CanProvision);
        }
コード例 #11
0
 public void Initialize()
 {
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         //Ensure nothing was left behind before we run our tests
         CleanupCreatedTestSiteCollections(tenantContext);
     }
 }
コード例 #12
0
 public void CleanUp()
 {
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         //Cleanup after test run
         CleanupCreatedTestSiteCollections(tenantContext);
     }
 }
コード例 #13
0
 public void GetAppCatalogTest()
 {
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         var tenant = new Tenant(tenantContext);
         Assert.IsNotNull(tenant.GetAppCatalog());
     }
 }
コード例 #14
0
 private void AllowScripting(string absoluteUrl, bool allow)
 {
     using (var adminCtx = TestCommon.CreateTenantClientContext())
     {
         var tenant = new Tenant(adminCtx);
         tenant.SetSiteProperties(absoluteUrl, noScriptSite: !allow);
     }
 }
コード例 #15
0
 public void DeploySharePointFrameworkSolutionTest()
 {
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         var tenant = new Tenant(tenantContext);
         var app    = tenant.DeployApplicationPackageToAppCatalog("hello-world.sppkg", "../../Resources", true, true, true);
     }
 }
コード例 #16
0
        public async Task CanCreateNewAssociatedGroupsInNewScriptSite_AfterAsyncRename()
        {
            var newCommSiteUrl = string.Empty;
            var siteTitle      = "Dummy";

            ProvisioningTemplate template    = new ProvisioningTemplate();
            SiteGroup            ownersGroup = new SiteGroup()
            {
                // this should map to existing group
                Title = siteTitle + " Owners",
            };

            template.Security.SiteGroups.Add(ownersGroup);
            template.Security.AssociatedOwnerGroup = ownersGroup.Title;

            using (var clientContext = TestCommon.CreateClientContext())
            {
                newCommSiteUrl = await CreateCommunicationSite(clientContext, siteTitle, true);
            }

            try
            {
                using (var ctx = TestCommon.CreateClientContext(newCommSiteUrl))
                {
                    LoadAssociatedOwnerGroupsData(ctx);
                    var oldOwnerGroupId   = ctx.Web.AssociatedOwnerGroup.Id;
                    var oldMemberGroupId  = ctx.Web.AssociatedMemberGroup.Id;
                    var oldVisitorGroupId = ctx.Web.AssociatedVisitorGroup.Id;
                    var oldGroupCount     = ctx.Web.SiteGroups.Count;

                    var parser = new TokenParser(ctx.Web, template);
                    // wait for async rename
                    await WaitForAsyncGroupTitleChangeWithTimeout(ctx);

                    // now provision - new site titles are in place
                    new ObjectSiteSecurity().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    LoadAssociatedOwnerGroupsData(ctx);
                    var newOwnerGroupId   = ctx.Web.AssociatedOwnerGroup.Id;
                    var newMemberGroupId  = ctx.Web.AssociatedMemberGroup.Id;
                    var newVisitorGroupId = ctx.Web.AssociatedVisitorGroup.Id;
                    var newGroupCount     = ctx.Web.SiteGroups.Count;

                    Assert.AreEqual(oldOwnerGroupId, newOwnerGroupId, "Expected owners group to stay the same");
                    Assert.AreEqual(oldMemberGroupId, newMemberGroupId, "Expected members group to stay the same");
                    Assert.AreEqual(oldVisitorGroupId, newVisitorGroupId, "Expected visitors group to stay the same");
                    Assert.AreEqual(oldGroupCount, newGroupCount, "Expected no new groups to be created");
                }
            }
            finally
            {
                using (var clientContext = TestCommon.CreateTenantClientContext())
                {
                    var tenant = new Tenant(clientContext);
                    tenant.DeleteSiteCollection(newCommSiteUrl, false);
                }
            }
        }
コード例 #17
0
        public void CanProvisionHierarchy()
        {
            if (TestCommon.AppOnlyTesting())
            {
                Assert.Inconclusive("Template requires term store work, so this will not work in app-only");
            }

            XMLTemplateProvider provider =
                new XMLFileSystemTemplateProvider(
                    String.Format(@"{0}\..\..\..\Resources",
                                  AppDomain.CurrentDomain.BaseDirectory),
                    "Templates");

            var hierarchy = provider.GetHierarchy("ProvisioningSchema-2019-03-FullSample-01.xml");

            var applyingInformation = new ProvisioningTemplateApplyingInformation();

            if (TestCommon.AppOnlyTesting())
            {
                bool templateSupportsAppOnly = true;

                if (applyingInformation.HandlersToProcess.Has(PnP.Framework.Provisioning.Model.Handlers.TermGroups) ||
                    applyingInformation.HandlersToProcess.Has(PnP.Framework.Provisioning.Model.Handlers.SearchSettings))
                {
                    if (hierarchy.Templates.Count > 0)
                    {
                        foreach (var template in hierarchy.Templates)
                        {
                            templateSupportsAppOnly = this.IsTemplateSupportedForAppOnly(template);
                            if (!templateSupportsAppOnly)
                            {
                                break;
                            }
                        }
                    }
                }

                if (!templateSupportsAppOnly)
                {
                    Assert.Inconclusive("Taxonomy and SearchSettings tests are not supported when testing using app-only context.");
                }
            }

            CanProvisionResult result = null;

            using (var pnpContext = new PnPProvisioningContext())
            {
                using (var tenantContext = TestCommon.CreateTenantClientContext())
                {
                    var tenant = new Tenant(tenantContext);
                    result = CanProvisionRulesManager.CanProvision(tenant, hierarchy, String.Empty, applyingInformation);
                }
            }

            Assert.IsNotNull(result);
            Assert.IsTrue(result.CanProvision);
            Assert.IsTrue(result.CanProvision);
        }
コード例 #18
0
        public void SetSiteLockStateTest()
        {
            try
            {
                using (var tenantContext = TestCommon.CreateTenantClientContext())
                {
                    tenantContext.RequestTimeout = Timeout.Infinite;

                    var    tenant          = new Tenant(tenantContext);
                    string devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                    string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                    Console.WriteLine("SetSiteLockStateTest: step 1");
                    if (!tenant.SiteExists(siteToCreateUrl))
                    {
                        siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                        Console.WriteLine("SetSiteLockStateTest: step 1.1");
                        var siteExists = tenant.SiteExists(siteToCreateUrl);
                        Console.WriteLine("SetSiteLockStateTest: step 1.2");
                        Assert.IsTrue(siteExists, "Site collection creation failed");
                    }

                    Console.WriteLine("SetSiteLockStateTest: step 2");
                    // Set Lockstate NoAccess test
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);

                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    tenantContext.Load(siteProperties);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                    // Set Lockstate NoAccess test
                    Console.WriteLine("SetSiteLockStateTest: step 3");
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.1");
                    var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.2");
                    tenantContext.Load(siteProperties2);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                    //Delete site collection, also
                    Console.WriteLine("SetSiteLockStateTest: step 4");
                    tenant.DeleteSiteCollection(siteToCreateUrl, false);
                    Console.WriteLine("SetSiteLockStateTest: step 4.1");
                    var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                    Console.WriteLine("SetSiteLockStateTest: step 4.2");
                    Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToDetailedString());
                throw;
            }
        }
コード例 #19
0
 public void Initialize()
 {
     sitecollectionName = sitecollectionName + (new Random().Next(0, 9)).ToString();
     using (var tenantContext = TestCommon.CreateTenantClientContext())
     {
         //Ensure nothing was left behind before we run our tests
         CleanupCreatedTestSiteCollections(tenantContext);
     }
 }
コード例 #20
0
        public void GetOneDriveSiteCollectionsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant   = new Tenant(tenantContext);
                var siteCols = tenant.GetOneDriveSiteCollections();

                Assert.IsTrue(siteCols.Any());
            }
        }
コード例 #21
0
        public void SubSiteExistsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var    tenant     = new Tenant(tenantContext);
                string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                Console.WriteLine("SubSiteExistsTest: step 1");
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                Console.WriteLine("SubSiteExistsTest: step 1.1");
                string subSiteUrlGood  = "";
                string subSiteUrlWrong = "";

                Site site = tenant.GetSiteByUrl(siteToCreateUrl);
                tenant.Context.Load(site);
                tenant.Context.ExecuteQueryRetry();
                Web web = site.RootWeb;
                web.Context.Load(web);
                web.Context.ExecuteQueryRetry();
                Console.WriteLine("SubSiteExistsTest: step 1.2");

                //Create sub site
                SiteEntity sub = new SiteEntity()
                {
                    Title = "Test Sub", Url = "sub", Description = "Test"
                };
                web.CreateWeb(sub);
                siteToCreateUrl = UrlUtility.EnsureTrailingSlash(siteToCreateUrl);
                subSiteUrlGood  = String.Format("{0}{1}", siteToCreateUrl, sub.Url);
                subSiteUrlWrong = String.Format("{0}{1}", siteToCreateUrl, "8988980");

                // Check real sub site
                Console.WriteLine("SubSiteExistsTest: step 2");
                bool subSiteExists = tenant.SubSiteExists(subSiteUrlGood);
                Console.WriteLine("SubSiteExistsTest: step 2.1");
                Assert.IsTrue(subSiteExists);

                // check non existing sub site
                Console.WriteLine("SubSiteExistsTest: step 3");
                bool subSiteExists2 = tenant.SubSiteExists(subSiteUrlWrong);
                Console.WriteLine("SubSiteExistsTest: step 3.1");
                Assert.IsFalse(subSiteExists2);

                // check root site (= site collection). Will return true when existing
                Console.WriteLine("SubSiteExistsTest: step 4");
                bool subSiteExists3 = tenant.SubSiteExists(siteToCreateUrl);
                Console.WriteLine("SubSiteExistsTest: step 4.1");
                Assert.IsTrue(subSiteExists3);

                // check root site (= site collection) that does not exist. Will return false when non-existant
                Console.WriteLine("SubSiteExistsTest: step 5");
                bool subSiteExists4 = tenant.SubSiteExists(siteToCreateUrl + "8808809808");
                Console.WriteLine("SubSiteExistsTest: step 5.1");
                Assert.IsFalse(subSiteExists4);
            }
        }
コード例 #22
0
        public void CleanUp()
        {
            using (var clientContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(clientContext);
                tenant.DeleteSiteCollection($"{baseUrl}/sites/site{communicationSiteGuid}", false);
                tenant.DeleteSiteCollection($"{baseUrl}/sites/site{teamSiteGuid}", false);

                //TODO: Cleanup group
            }
        }
コード例 #23
0
 public void CleanUp()
 {
     using (var clientContext = TestCommon.CreateTenantClientContext())
     {
         var tenant = new Tenant(clientContext);
         tenant.DeleteSiteCollection($"{baseUrl}/sites/site{communicationSiteGuid}", false);
         // Commented this, first group cleanup needs to be implemented in this test case
         //tenant.DeleteSiteCollection($"{baseUrl}/sites/site{teamSiteGuid}", false);
         //TODO: Cleanup group
     }
 }
コード例 #24
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());
         }
     }
 }
コード例 #25
0
        public void GetUserProfileServiceClientTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext()) {
                var tenant        = new Tenant(tenantContext);
                var serviceClient = tenant.GetUserProfileServiceClient();
                tenantContext.Load(tenantContext.Web, w => w.CurrentUser);
                tenantContext.ExecuteQueryRetry();

                var profile = serviceClient.GetUserProfileByName(tenantContext.Web.CurrentUser.LoginName);

                Assert.IsNotNull(profile);
            }
        }
コード例 #26
0
        public void GetOneDriveSiteCollectionsTest()
        {
            if (TestCommon.AppOnlyTesting())
            {
                Assert.Inconclusive("Web service tests are not supported when testing using app-only");
            }

            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant   = new Tenant(tenantContext);
                var siteCols = tenant.GetOneDriveSiteCollections();

                Assert.IsTrue(siteCols.Any());
            }
        }
コード例 #27
0
        public void SiteExistsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant          = new Tenant(tenantContext);
                var siteCollections = tenant.GetSiteCollections();

                var site        = siteCollections.First();
                var siteExists1 = tenant.SiteExists(site.Url);
                Assert.IsTrue(siteExists1);

                var siteExists2 = tenant.SiteExists(site.Url + "sites/aaabbbccc");
                Assert.IsFalse(siteExists2, "Invalid site returned as valid.");
            }
        }
コード例 #28
0
        public void CheckIfSiteExistsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext()) {
                var tenant          = new Tenant(tenantContext);
                var siteCollections = tenant.GetSiteCollections();

                var site        = siteCollections.First();
                var siteExists1 = tenant.CheckIfSiteExists(site.Url, "Active");
                Assert.IsTrue(siteExists1);

                try {
                    var siteExists2 = tenant.CheckIfSiteExists(site.Url + "sites/aaabbbccc", "Active");
                    Assert.IsFalse(siteExists2, "Invalid site returned as valid.");
                }
                catch (ServerException) { }
            }
        }
コード例 #29
0
        public void SiteExistsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant          = new Tenant(tenantContext);
                var siteCollections = tenant.GetSiteCollections();

                var site        = siteCollections.Last();
                var siteExists1 = tenant.SiteExists(site.Url);
                Assert.IsTrue(siteExists1);

                string devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, "aaabbbccc");
                var    siteExists2     = tenant.SiteExists(siteToCreateUrl);
                Assert.IsFalse(siteExists2, "Invalid site returned as valid.");
            }
        }
コード例 #30
0
        public void CreateDeleteSiteCollectionTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);

                //Create site collection test
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                var    siteExists      = tenant.Context.WebExistsFullUrl(siteToCreateUrl);
                Assert.IsTrue(siteExists, "Site collection creation failed");

                //Delete site collection test
                tenant.DeleteSiteCollection(siteToCreateUrl);
                siteExists = tenant.Context.WebExistsFullUrl(siteToCreateUrl);
                Assert.IsFalse(siteExists, "Site collection deletion failed");
            }
        }