Ejemplo n.º 1
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndAddPowerBIWorkspaceUserOrganizationScope()
        {
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspaceInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var emailAddress = "*****@*****.**";
                var parameters   = new Dictionary <string, object>()
                {
                    { nameof(AddPowerBIWorkspaceUser.Scope), PowerBIUserScope.Organization },
                    { nameof(AddPowerBIWorkspaceUser.Id), workspace.Id },
                    { nameof(AddPowerBIWorkspaceUser.UserPrincipalName), emailAddress },
                    { nameof(AddPowerBIWorkspaceUser.AccessRight), WorkspaceUserAccessRight.Member }
                };
                ps.AddCommand(Cmdlet).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                var updatedWorkspace = WorkspacesTestUtilities.GetWorkspace(ps, PowerBIUserScope.Organization, workspace.Id);
                Assert.IsTrue(updatedWorkspace.Users
                              .Any(x => x.UserPrincipalName.Equals(emailAddress, StringComparison.OrdinalIgnoreCase) &&
                                   x.AccessRight == WorkspaceUserAccessRight.Member.ToString()));
            }
        }
Ejemplo n.º 2
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndSetWorkspaceOrganizationScopeWorkspaceParameterSet()
        {
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspaceInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var updatedName        = TestUtilities.GetRandomString();
                var updatedDescription = TestUtilities.GetRandomString();
                workspace.Name        = updatedName;
                workspace.Description = updatedDescription;
                var parameters = new Dictionary <string, object>
                {
                    { nameof(SetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(SetPowerBIWorkspace.Workspace), workspace }
                };
                ps.AddCommand(Cmdlet).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                var updatedWorkspace = WorkspacesTestUtilities.GetWorkspace(ps, PowerBIUserScope.Organization, workspace.Id);
                Assert.AreEqual(updatedName, updatedWorkspace.Name);
                Assert.AreEqual(updatedDescription, updatedWorkspace.Description);
            }
        }
Ejemplo n.º 3
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndGetWorkspacesOrganizationScopeAndDeleted()
        {
            /*
             * Test requires at least one deleted workspace and login as an administrator
             */
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var deletedWorkspace = WorkspacesTestUtilities.GetFirstDeletedWorkspaceInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(deletedWorkspace);
                var parameters = new Dictionary <string, object>()
                {
                    { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(GetPowerBIWorkspace.Deleted), true }
                };
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                if (!results.Any())
                {
                    Assert.Inconclusive("No workspaces returned. Verify you have workspaces in your organization.");
                }

                var deletedWorkspaces = results.Select(x => (Workspace)x.BaseObject);
                Assert.IsTrue(deletedWorkspaces.Any(x => x.Id == deletedWorkspace.Id));
            }
        }
Ejemplo n.º 4
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndRestoreWorkspaceOrganizationScopeWorkspaceParameterSet()
        {
            /*
             * Test requires a deleted preview workspace (v2) to exist and login as an administrator
             */
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstDeletedWorkspaceInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var updatedName  = TestUtilities.GetRandomString();
                var emailAddress = "*****@*****.**"; //change to valid test user email
                var parameters   = new Dictionary <string, object>
                {
                    { nameof(RestorePowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(RestorePowerBIWorkspace.RestoredName), updatedName },
                    { nameof(RestorePowerBIWorkspace.AdminUserPrincipalName), emailAddress },
                    { nameof(RestorePowerBIWorkspace.Workspace), workspace },
                };
                ps.AddCommand(Cmdlet).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                var updatedWorkspace = WorkspacesTestUtilities.GetWorkspace(ps, PowerBIUserScope.Organization, workspace.Id);
                Assert.AreEqual(updatedName, updatedWorkspace.Name);
                Assert.IsTrue(updatedWorkspace.Users
                              .Any(x => x.UserPrincipalName.Equals(emailAddress, StringComparison.OrdinalIgnoreCase) &&
                                   x.AccessRight == WorkspaceUserAccessRight.Admin.ToString()));
            }
        }
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndSetWorkspaceOrganizationScopeCapacityParameterSet()
        {
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspaceInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var capacityId = WorkspacesTestUtilities.GetFirstCapacityInOrganization(ps);

                var parameters = new Dictionary <string, object>
                {
                    { nameof(SetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(SetPowerBIWorkspace.Id), workspace.Id },
                    { nameof(SetPowerBIWorkspace.CapacityId), capacityId }
                };
                ps.AddCommand(Cmdlet).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
            }
        }
Ejemplo n.º 6
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndGetWorkspacesOrganizationScopeAndUser()
        {
            /*
             * Test requires a preview workspace (v2) to exist and login as an administrator
             */
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspaceWithUsersInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var userEmailAddress = workspace.Users.FirstOrDefault().UserPrincipalName;
                var parameters       = new Dictionary <string, object>()
                {
                    { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(GetPowerBIWorkspace.User), userEmailAddress }
                };
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                Assert.IsTrue(results.Any());

                // Arrange
                ps.Commands.Clear();
                parameters[nameof(GetPowerBIWorkspace.User)] = TestUtilities.GetRandomString();
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters);

                // Act
                results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                Assert.IsFalse(results.Any());
            }
        }
Ejemplo n.º 7
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndGetWorkspacesOrganizationScopeAndFilter()
        {
            /*
             * Test requires at least one workspace (group or preview workspace) and login as an administrator
             */
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspace(ps, PowerBIUserScope.Organization);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var filterQuery = string.Format("name eq '{0}'", workspace.Name);
                var parameters  = new Dictionary <string, object>()
                {
                    { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(GetPowerBIWorkspace.Filter), filterQuery }
                };
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                Assert.IsTrue(results.Any());

                // Arrange
                ps.Commands.Clear();
                parameters[nameof(GetPowerBIWorkspace.Filter)] = string.Format("name eq '{0}'", TestUtilities.GetRandomString());
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters);

                // Act
                results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);
                Assert.IsFalse(results.Any());
            }
        }
Ejemplo n.º 8
0
        [TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing
        public void EndToEndGetWorkspacesAllAndOrganizationScopeAndUser()
        {
            /*
             * Test requires at least one workspace (group or preview workspace) with the given user and login as an administrator
             */
            using (var ps = System.Management.Automation.PowerShell.Create())
            {
                // Arrange
                ProfileTestUtilities.ConnectToPowerBI(ps);
                var workspace = WorkspacesTestUtilities.GetFirstWorkspaceWithUsersInOrganization(ps);
                WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace);
                var userEmailAddress = workspace.Users.FirstOrDefault().UserPrincipalName;
                var parameters       = new Dictionary <string, object>()
                {
                    { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization },
                    { nameof(GetPowerBIWorkspace.All), true },
                    { nameof(GetPowerBIWorkspace.User), userEmailAddress }
                };
                ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo)
                .AddParameters(parameters);

                // Act
                var results = ps.Invoke();

                // Assert
                TestUtilities.AssertNoCmdletErrors(ps);
                Assert.IsNotNull(results);

                if (!results.Any())
                {
                    Assert.Inconclusive("No workspaces returned. Verify you have workspaces with the specified user in your organization.");
                }

                Assert.IsNotNull(results.Select(x => (Workspace)x.BaseObject).FirstOrDefault(w => w.Id == workspace.Id));
            }
        }