Ejemplo n.º 1
0
        public void GetWorkspace()
        {
            List <Workspace>           workspace  = null;
            GetAzureRemoteAppWorkspace mockCmdlet = SetUpTestCommon <GetAzureRemoteAppWorkspace>();

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultWorkspace(remoteAppManagementClientMock, ClientUrl, EndUserFeedName);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppWorkspace");

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppWorkspace returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            workspace = MockObject.ConvertList <Workspace>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(workspace);

            Assert.True(MockObject.HasExpectedResults <Workspace>(workspace, MockObject.ContainsExpectedWorkspace),
                        "The actual result does not match the expected."
                        );

            Log("The test for Get-AzureRemoteAppWorkspace completed successfully");
        }
Ejemplo n.º 2
0
        public void SetWorkspace()
        {
            List <TrackingResult> trackingIds     = null;
            string EndUserFeedName                = "MockAwesomeFeed";
            SetAzureRemoteAppWorkspace mockCmdlet = SetUpTestCommon <SetAzureRemoteAppWorkspace>();

            // Required parameters for this test
            mockCmdlet.WorkspaceName = EndUserFeedName;

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultWorkspace(remoteAppManagementClientMock, ClientUrl, EndUserFeedName);
            MockObject.SetUpDefaultEditWorkspace(remoteAppManagementClientMock, EndUserFeedName);
            mockCmdlet.ResetPipelines();

            Log("Calling Set-AzureRemoteAppWorkspace");

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Set-AzureRemoteAppWorkspace returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            trackingIds = MockObject.ConvertList <TrackingResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(trackingId);

            Assert.True(MockObject.HasExpectedResults <TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
                        "The actual result does not match the expected."
                        );

            Log("The test for Set-AzureRemoteAppWorkspace completed successfully");
        }
Ejemplo n.º 3
0
        public void RemoveVNetsThatDoExist()
        {
            List <TrackingResult>    trackingIds = null;
            RemoveAzureRemoteAppVNet mockCmdlet  = SetUpTestCommon <RemoveAzureRemoteAppVNet>();

            // Required parameters for this test
            mockCmdlet.VNetName = "vNetTest";

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppRemoveVNet(remoteAppManagementClientMock, mockCmdlet.VNetName);
            mockCmdlet.ResetPipelines();

            Log("Calling Remove-AzureRemoteAppVNet");

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Remove-AzureRemoteAppVNet returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            trackingIds = MockObject.ConvertList <TrackingResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(trackingIds);

            Assert.True(MockObject.HasExpectedResults <TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
                        "The actual result does not match the expected."
                        );

            Log("The test for Remove-AzureRemoteAppVNet completed successfully");
        }
        public void GetRegionList()
        {
            List <Region>             regionList = null;
            GetAzureRemoteAppLocation mockCmdlet = SetUpTestCommon <GetAzureRemoteAppLocation>();

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppRegionList(remoteAppManagementClientMock);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppRegionList");

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppRegionList returned the following error {0}.",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            regionList = MockObject.ConvertList <Region>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(regionList);

            Assert.True(MockObject.HasExpectedResults <Region>(regionList, MockObject.ContainsExpectedRegion),
                        "The actual result does not match the expected."
                        );

            Log("The test for Get-AzureRemoteAppRegionList");
        }
        public void RenameTemplate()
        {
            RenameAzureRemoteAppTemplateImage mockCmdlet = SetUpTestCommon <RenameAzureRemoteAppTemplateImage>();

            // Required parameters for this test
            mockCmdlet.ImageName = templateName;
            mockCmdlet.NewName   = "UpdatedTemplateImage";

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppTemplates(remoteAppManagementClientMock, mockCmdlet.ImageName, templateId);
            MockObject.SetUpDefaultRemoteAppRenameTemplate(remoteAppManagementClientMock, mockCmdlet.NewName, templateId);
            mockCmdlet.ResetPipelines();

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Rename-AzureRemoteAppTemplate returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            List <TemplateImage> templates = MockObject.ConvertList <TemplateImage>(mockCmdlet.runTime().OutputPipeline);

            Assert.NotNull(templates);

            Assert.True(MockObject.HasExpectedResults <TemplateImage>(templates, MockObject.ContainsExpectedTemplate),
                        "The actual result does not match the expected"
                        );

            Log("The test for Rename-AzureRemoteAppTemplate completed successfully");
        }
Ejemplo n.º 6
0
        public void AddVNetsThatDontExist()
        {
            List <TrackingResult> trackingIds = null;
            VNetParameter         vNetDetails = new VNetParameter()
            {
                Region            = region,
                VnetAddressSpaces = new List <string>()
                {
                    "10.0.0.0/16"
                },
                LocalAddressSpaces = new List <string>()
                {
                    "11.0.0.0/16"
                },
                DnsServers = new List <string>()
                {
                    "11.0.0.10"
                },
                VpnAddress  = "13.0.0.1",
                GatewayType = GatewayType.StaticRouting
            };
            int countOfAddedVNets            = 0;
            NewAzureRemoteAppVNet mockCmdlet = SetUpTestCommon <NewAzureRemoteAppVNet>();


            // Required parameters for this test
            mockCmdlet.VNetName = "vNetTest1";
            mockCmdlet.Location = vNetDetails.Region;
            mockCmdlet.VirtualNetworkAddressSpace = vNetDetails.VnetAddressSpaces.ToArray();
            mockCmdlet.LocalNetworkAddressSpace   = vNetDetails.LocalAddressSpaces.ToArray();
            mockCmdlet.DnsServerIpAddress         = vNetDetails.DnsServers.ToArray();
            mockCmdlet.VpnDeviceIpAddress         = vNetDetails.VpnAddress;
            mockCmdlet.GatewayType = vNetDetails.GatewayType;

            // Setup the environment for testing this cmdlet
            countOfAddedVNets = MockObject.SetUpDefaultRemoteAppAddVNet(remoteAppManagementClientMock, vNetDetails);
            mockCmdlet.ResetPipelines();

            Log("Calling Add-AzureRemoteAppVNet which should have {0} VNets", countOfAddedVNets);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Add-AzureRemoteAppVNet returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            trackingIds = MockObject.ConvertList <TrackingResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(trackingIds);

            Assert.True(MockObject.HasExpectedResults <TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
                        "The actual result does not match the expected."
                        );

            Log("The test for Add-AzureRemoteAppVNet completed successfully");
        }
        public void AddUsersToApp()
        {
            int countOfExistingUsers         = 0;
            int countOfNewUsers              = 0;
            AddAzureRemoteAppUser MockCmdlet = SetUpTestCommon <AddAzureRemoteAppUser>();

            // Required parameters for this test
            MockCmdlet.CollectionName = collectionName;
            MockCmdlet.Alias          = appAlias;
            MockCmdlet.Type           = PrincipalProviderType.OrgId;
            MockCmdlet.UserUpn        = new string[]
            {
                "testUser1",
                "testUser2",
            };

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
            countOfExistingUsers = MockObject.SetUpDefaultRemoteAppSecurityPrincipals(remoteAppManagementClientMock, collectionName, userName);
            countOfNewUsers      = MockObject.SetUpRemoteAppUserToAddForApp(remoteAppManagementClientMock, collectionName, appAlias, PrincipalProviderType.OrgId, MockCmdlet.UserUpn);
            MockCmdlet.ResetPipelines();

            Log("Calling Add-AzureRemoteAppOrgIDUser and adding {0} users.", countOfNewUsers);

            MockCmdlet.ExecuteCmdlet();
            if (MockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Add-AzureRemoteAppOrgIDUser returned the following error {0}.",
                                          MockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            List <SecurityPrincipalOperationsResult> status = MockObject.ConvertList <SecurityPrincipalOperationsResult>(MockCmdlet.runTime().OutputPipeline);

            Assert.NotNull(status);

            Assert.True(MockObject.HasExpectedResults <SecurityPrincipalOperationsResult>(status, MockObject.ContainsExpectedStatus),
                        "The actual result does not match the expected."
                        );

            Log("The test for Add-AzureRemoteAppOrgIDUser successfully added {0} users the new count is {1}.", countOfNewUsers, countOfExistingUsers + countOfNewUsers);
        }
Ejemplo n.º 8
0
        public void GetRemoteAppByName()
        {
            List <PublishedApplicationDetails> remoteApps = null;
            int countOfExpectedApps             = 0;
            GetAzureRemoteAppProgram mockCmdlet = SetUpTestCommon <GetAzureRemoteAppProgram>();

            // Required parameters for this test
            mockCmdlet.CollectionName = collectionName;
            mockCmdlet.Alias          = "1340fc";

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, mockCmdlet.CollectionName);
            countOfExpectedApps = MockObject.SetUpDefaultRemoteAppApplicationsByName(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.Alias);

            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppCollection which should have {0} collections.", countOfExpectedApps);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppCollection returned the following error {0}.",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            remoteApps = MockObject.ConvertList <PublishedApplicationDetails>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(remoteApps);

            Assert.True(remoteApps.Count == countOfExpectedApps,
                        String.Format("The expected number of collections returned {0} does not match the actual {1}.",
                                      countOfExpectedApps,
                                      remoteApps.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <PublishedApplicationDetails>(remoteApps, MockObject.ContainsExpectedApplication),
                        "The actual result does not match the expected."
                        );

            Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedApps);
        }
        public void GetResult()
        {
            List <OperationResult> operationResult = null;

            int countOfExpectedResults = 0;
            GetAzureRemoteAppOperationResult mockCmdlet = SetUpTestCommon <GetAzureRemoteAppOperationResult>();

            // Required parameters for this test
            mockCmdlet.TrackingId = "1234";

            // Setup the environment for testing this cmdlet
            countOfExpectedResults = MockObject.SetUpDefaultRemoteAppOperationResult(remoteAppManagementClientMock, mockCmdlet.TrackingId);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppOperationResult this tracking id ", mockCmdlet.TrackingId);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppCollection returned the following error {0}.",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            operationResult = MockObject.ConvertList <OperationResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(operationResult);

            Assert.True(operationResult.Count == countOfExpectedResults,
                        String.Format("The expected number of templates returned {0} does not match the actual {1}",
                                      countOfExpectedResults,
                                      operationResult.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <OperationResult>(operationResult, MockObject.ContainsExpectedOperationResult),
                        "The actual result does not match the expected."
                        );

            Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", mockCmdlet.TrackingId);
        }
        public void RemoveMSAUserThatExists()
        {
            int countOfExistingUsers            = 0;
            int countOfDeletedUsers             = 0;
            RemoveAzureRemoteAppUser MockCmdlet = SetUpTestCommon <RemoveAzureRemoteAppUser>();

            // Required parameters for this test
            MockCmdlet.CollectionName = collectionName;
            MockCmdlet.Type           = PrincipalProviderType.MicrosoftAccount;
            MockCmdlet.UserUpn        = new string[]
            {
                userName
            };

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
            countOfExistingUsers = MockObject.SetUpDefaultRemoteAppSecurityPrincipals(remoteAppManagementClientMock, collectionName, userName);
            countOfDeletedUsers  = MockObject.SetUpDefaultRemoteAppUserToRemove(remoteAppManagementClientMock, collectionName, PrincipalProviderType.MicrosoftAccount, MockCmdlet.UserUpn);
            MockCmdlet.ResetPipelines();

            Log("Calling Remove-AzureRemoteAppMSAUser and removing {0} users.", countOfDeletedUsers);

            MockCmdlet.ExecuteCmdlet();
            if (MockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Remove-AzureRemoteAppMSAUser returned the following error {0}.",
                                          MockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            List <SecurityPrincipalOperationsResult> status = MockObject.ConvertList <SecurityPrincipalOperationsResult>(MockCmdlet.runTime().OutputPipeline);

            Assert.NotNull(status);

            Assert.True(MockObject.HasExpectedResults <SecurityPrincipalOperationsResult>(status, MockObject.ContainsExpectedStatus),
                        "The actual result does not match the expected."
                        );

            Log("The test for Remove-AzureRemoteAppMSAUser successfully removed {0} users the new count is {1}.", countOfDeletedUsers, countOfExistingUsers - countOfDeletedUsers);
        }
Ejemplo n.º 11
0
        public void GetVNetsByName()
        {
            List <VNet>           vNets = null;
            int                   countOfExpectedVNets = 0;
            GetAzureRemoteAppVNet mockCmdlet           = SetUpTestCommon <GetAzureRemoteAppVNet>();

            // Required parameters for this test
            mockCmdlet.VNetName         = "vNetTest";
            mockCmdlet.IncludeSharedKey = true;

            // Setup the environment for testing this cmdlet
            countOfExpectedVNets = MockObject.SetUpDefaultRemoteAppVNetByName(remoteAppManagementClientMock, mockCmdlet.VNetName, mockCmdlet.IncludeSharedKey);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppVNet which should have {0} VNets", countOfExpectedVNets);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppVNet returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            vNets = MockObject.ConvertList <VNet>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(vNets);

            Assert.True(vNets.Count == countOfExpectedVNets,
                        String.Format("The expected number of VNets returned {0} does not match the actual {1}",
                                      countOfExpectedVNets,
                                      vNets.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <VNet>(vNets, MockObject.ContainsExpectedVNet),
                        "The actual result does not match the expected"
                        );

            Log("The test for Get-AzureRemoteAppVNet with {0} VNets completed successfully", countOfExpectedVNets);
        }
        public void AddCollection()
        {
            List <TrackingResult> trackingIds      = null;
            int countOfExpectedCollections         = 0;
            NewAzureRemoteAppCollection mockCmdlet = SetUpTestCommon <NewAzureRemoteAppCollection>();

            // Required parameters for this test
            mockCmdlet.CollectionName    = collectionName;
            mockCmdlet.Location          = region;
            mockCmdlet.Plan              = billingPlan;
            mockCmdlet.ImageName         = templateName;
            mockCmdlet.Description       = description;
            mockCmdlet.CustomRdpProperty = customRDPString;

            // Setup the environment for testing this cmdlet
            countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionCreate(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.Location, mockCmdlet.Plan, mockCmdlet.ImageName, mockCmdlet.Description, mockCmdlet.CustomRdpProperty, trackingId);
            mockCmdlet.ResetPipelines();

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("New-AzureRemoteAppCollection returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            trackingIds = MockObject.ConvertList <TrackingResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(trackingIds);

            Assert.True(trackingIds.Count == countOfExpectedCollections,
                        String.Format("The expected number of collections returned {0} does not match the actual {1}",
                                      countOfExpectedCollections,
                                      trackingIds.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
                        "The actual result does not match the expected."
                        );
        }
        public void GetTemplatesByName()
        {
            int countOfExpectedTemplates = 0;
            GetAzureRemoteAppTemplateImage mockCmdlet = SetUpTestCommon <GetAzureRemoteAppTemplateImage>();

            // Required parameters for this test
            mockCmdlet.ImageName = templateName;

            // Setup the environment for testing this cmdlet
            countOfExpectedTemplates = MockObject.SetUpDefaultRemoteAppTemplatesByName(remoteAppManagementClientMock, mockCmdlet.ImageName);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppTemplateImage which should have {0} templates", countOfExpectedTemplates);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppTemplateImage returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            List <TemplateImage> templates = MockObject.ConvertList <TemplateImage>(mockCmdlet.runTime().OutputPipeline);

            Assert.NotNull(templates);

            Assert.True(templates.Count == countOfExpectedTemplates,
                        String.Format("The expected number of templates returned {0} does not match the actual {1}",
                                      countOfExpectedTemplates,
                                      templates.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <TemplateImage>(templates, MockObject.ContainsExpectedTemplate),
                        "The actual result does not match the expected"
                        );

            Log("The test for Get-AzureRemoteAppTemplateImage with {0} templates completed successfully", countOfExpectedTemplates);
        }
        public void GetCollectionsByName()
        {
            int countOfExpectedCollections         = 1;
            GetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon <GetAzureRemoteAppCollection>();

            // Required parameters for this test
            mockCmdlet.CollectionName = collectionName;

            // Setup the environment for testing this cmdlet
            MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
            mockCmdlet.ResetPipelines();

            Log("Calling Get-AzureRemoteAppCollection to get this collection {0}.", mockCmdlet.CollectionName);

            mockCmdlet.ExecuteCmdlet();

            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Get-AzureRemoteAppUser returned the following error {0}.",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            List <Collection> collections = MockObject.ConvertList <Collection>(mockCmdlet.runTime().OutputPipeline);

            Assert.NotNull(collections);

            Assert.True(collections.Count == countOfExpectedCollections,
                        String.Format("The expected number of collections returned {0} does not match the actual {1}.",
                                      countOfExpectedCollections,
                                      collections.Count
                                      )
                        );

            Assert.True(MockObject.HasExpectedResults <Collection>(collections, MockObject.ContainsExpectedCollection),
                        "The actual result does not match the expected."
                        );
        }