public async Task Test_AzureController_SecurityException_Fail() { //Arrange //Authorization Code absent AzureADAuthModel googleAuthModel = new AzureADAuthModel { APIKey = "<api key>" }; AzureAuthenticator authenticator = new AzureAuthenticator(this.SecuritySettings, this.MockAzureClient.Object); var controller = new AzureController(authenticator); try { //Act var result = await controller.Create(googleAuthModel); } catch (SecurityException ex) { //Assert Assert.IsType <SecurityException>(ex); this.MockAzureClient.Verify(x => x.PostSecurityRequest(), Times.Never); } }
public void GivenAzureControllerInitiatedWithDependencies() { var azureServiceMock = new Mock <IAzureService>(); azureServiceMock.Setup(x => x.TriggerLogicApp(It.IsAny <AzureModel>())).Returns(Task.FromResult(true)); azureController = new AzureController(azureServiceMock.Object); }
public void _ControllerAzureGetAllResourceGroupsTest() { // Arrange AzureController controller = new AzureController(); // Act HttpResponseMessage response = controller.GetAllResourceGroups(); var definition = new { resourcegroup = "" }; List <ResourceClass> extracted = JsonConvert.DeserializeObject <List <ResourceClass> >(response.Content.ReadAsStringAsync().Result); Assert.AreEqual(extracted[0].resourcegroup, "DOGService-resource-group"); }
public void WhenCallToAzureIsNotSuccesful_ThenAzureControllerReturnsFalse() { var azureServiceMock = new Mock <IAzureService>(); azureServiceMock.Setup(x => x.TriggerLogicApp(It.IsAny <AzureModel>())).Returns(Task.FromResult(false)); var controller = new AzureController(azureServiceMock.Object); var result = controller.TriggerLogicApp(new AzureModel { Email = "*****@*****.**", FirstName = "Ziom", LastName = "LastName", PhoneNumber = "5554555" }).GetAwaiter().GetResult(); Assert.IsFalse(result); }
private async void LoadDockerInstances() { _dockerConfigSection = ConfigurationManager.GetSection(DockerConfigSection.SectionName) as DockerConfigSection; var azureCfg = ConfigurationManager.GetSection(AzureConfigSection.SectionName) as AzureConfigSection; var azureController = new AzureController(azureCfg.AzureSubscription.SubscriptionId, azureCfg.AzureSubscription.Base64encodedCertificate); var dockerInstanceViewModels = _dockerConfigSection.DockerInstances.Select((i, idx) => new DockerInstanceViewModel( new DockerInstance(i.Host, i.Port, i.Username, i.Password), azureController.GetVirtualMachineByHostnameAsync(azureCfg.AzureSubscription.ResourceGroup, i.Host), idx + 1)); DockerInstanceViewModels = new ObservableCollection <DockerInstanceViewModel>(dockerInstanceViewModels); var initializeTasks = DockerInstanceViewModels.Select(i => i.InitializeAsync()); await Task.WhenAll(initializeTasks); await ReevaluateDatabaseInteractors(); }
public async Task Test_AzureController_Pass() { //Arrange AzureADAuthModel azureADAuthModel = new AzureADAuthModel { APIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; AzureAuthenticator azureAuthenticator = new AzureAuthenticator(this.SecuritySettings, this.MockAzureClient.Object); var controller = new AzureController(azureAuthenticator); //Act var result = await controller.Create(azureADAuthModel); //Assert Assert.IsType <ObjectResult>(result); Assert.True((result as ObjectResult).Value.ToString().IsValidJwtToken()); this.MockAzureClient.Verify(x => x.PostSecurityRequest(), Times.Once); }
public async Task Test_AzureController_InvalidAPIKey_Fail() { //Arrange //Invalid API Key AzureADAuthModel azureADAuthModel = new AzureADAuthModel { APIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; AzureAuthenticator azureAuthenticator = new AzureAuthenticator(this.SecuritySettings, this.MockAzureClient.Object); var controller = new AzureController(azureAuthenticator); //Act var result = await controller.Create(azureADAuthModel); //Assert Assert.IsType <BadRequestResult>(result); this.MockAzureClient.Verify(x => x.PostSecurityRequest(), Times.Never); }
public async Task Test_AzureController_AzureAuth_Fail() { //Arrange //Azure Client returns IsAuthenticated false this.MockAzureClient = this.InitMockAzureClient(this.SecuritySettings, false); AzureADAuthModel azureADAuthModel = new AzureADAuthModel { APIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; AzureAuthenticator azureAuthenticator = new AzureAuthenticator(this.SecuritySettings, this.MockAzureClient.Object); var controller = new AzureController(azureAuthenticator); //Act var result = await controller.Create(azureADAuthModel); //Assert Assert.IsType <BadRequestResult>(result); this.MockAzureClient.Verify(x => x.PostSecurityRequest(), Times.Once); }
private int _height; // height of the object to capture // Use this for initialization void Start() { _azureController = new AzureController(); _width = System.Convert.ToInt32(rectT.rect.width); _height = System.Convert.ToInt32(rectT.rect.height); }
public void GivenAzureControllerInitiatedWithDependencies() { azureController = new AzureController(); }