private void _btnSave_Click(object sender, EventArgs e) { _btnSave.Enabled = false; Subdomain subdomain = new Subdomain(); subdomain.SubdomainName = _txtSubName.Text; subdomain.DateFound = _dateFound.Value; subdomain.DomainId = int.Parse(_cmbDomain.SelectedItem.ToString().Split('~')[1].ToString()); subdomain.FoundType = _txtFoundType.Text; SubdomainController subController = new SubdomainController(); var res = subController.Insert(subdomain); if (res.Error) { MessageBox.Show(res.Message); } else { _txtSubName.Text = ""; _dateFound.Value = DateTime.Now; _cmbDomain.SelectedItem = "Select"; _txtFoundType.Text = ""; } _btnSave.Enabled = true; }
private void _btnInitialize_Click(object sender, EventArgs e) { var controller = new DomainController(); var result = controller.CreateTable(); if (result.Error) { LogTest(result.Message); } var subdomaincontroller = new SubdomainController(); var subdomainresult = subdomaincontroller.CreateTable(); if (subdomainresult.Error) { LogTest(result.Message); } var ignorecontroller = new DomainIgnoreController(); var ignoreresult = ignorecontroller.CreateTable(); if (subdomainresult.Error) { LogTest(result.Message); } LogTest("Tables Created!"); }
public async Task EnumerateAsync_ReturnsSuccess() { // Arrange Mock <ILogger <SubdomainController> > mockLogger = new Mock <ILogger <SubdomainController> >(); Mock <ISubdomainService> mockSubdomainService = new Mock <ISubdomainService>(); const string domainName = "yahoo.com"; EnumerateResponse response = new EnumerateResponse { Subdomains = new List <string> { "aa.yahoo.com" }, Success = true }; mockSubdomainService.Setup(q => q.EnumerateAsync(domainName)).Returns(Task.FromResult(response)); SubdomainController controller = new SubdomainController(mockLogger.Object, mockSubdomainService.Object); // Act IActionResult result = await controller.EnumerateAsync(domainName); ObjectResult okObjectResult = result as ObjectResult; // Assert EnumerateResponse actual = (EnumerateResponse)okObjectResult.Value; Assert.NotNull(okObjectResult); Assert.True(okObjectResult is OkObjectResult); Assert.IsType <EnumerateResponse>(okObjectResult.Value); Assert.Equal(StatusCodes.Status200OK, okObjectResult.StatusCode); Assert.True(actual.Success); }
private void _btnInitSubdomain_Click(object sender, EventArgs e) { DomainController domainController = new DomainController(); SubdomainController subdomainController = new SubdomainController(); DomainFindResult findResult = domainController.FindAll(); List <string> knownSubdomains = new List <string>(); List <string> knowndbSubdomains = new List <string>(); foreach (Domain domainItem in findResult.Items) { string domain = domainItem.DomainName; string existingFile = Path.Combine(@"C:\Alternative\Existing", domain.Replace(".", "") + ".txt"); if (File.Exists(existingFile)) { knownSubdomains = File.ReadAllLines(existingFile).ToList(); } knownSubdomains = knownSubdomains.Select(x => x.Replace("." + domainItem.DomainName, "")).ToList(); SubdomainFindResult subDomainFindResult = subdomainController.FindByDomain(domainItem.DomainId); if (subDomainFindResult.Error) { MessageBox.Show(subDomainFindResult.Message); } knowndbSubdomains = subDomainFindResult.Items.Select(x => x.SubdomainName).ToList(); List <string> inList1ButNotList2 = (from o in knownSubdomains join p in knowndbSubdomains on o equals p into t from od in t.DefaultIfEmpty() where od == null select o).ToList <string>(); foreach (string newItem in inList1ButNotList2) { Subdomain sub = new Subdomain(); sub.DomainId = domainItem.DomainId; sub.DateFound = DateTime.Now; sub.FoundType = "scanner"; sub.SubdomainName = newItem; subdomainController.Insert(sub); } } }
public async Task FindIpAddressesAsync_ReturnsSuccess() { // Arrange Mock <ILogger <SubdomainController> > mockLogger = new Mock <ILogger <SubdomainController> >(); Mock <ISubdomainService> mockSubdomainService = new Mock <ISubdomainService>(); List <string> subdomains = new List <string> { "ar.yahoo.com" }; IpAddressesResponse response = new IpAddressesResponse { Results = new List <Result> { new Result { Subdomain = "ar.yahoo.com", IpAddresses = new List <string> { "106.10.248.150" } } }, Success = true }; mockSubdomainService.Setup(q => q.FindIpAddressesAsync(subdomains)).Returns(Task.FromResult(response)); SubdomainController controller = new SubdomainController(mockLogger.Object, mockSubdomainService.Object); // Act IActionResult result = await controller.FindIpAddressesAsync(subdomains); ObjectResult okObjectResult = result as ObjectResult; // Assert IpAddressesResponse actual = (IpAddressesResponse)okObjectResult.Value; Assert.NotNull(okObjectResult); Assert.True(okObjectResult is OkObjectResult); Assert.IsType <IpAddressesResponse>(okObjectResult.Value); Assert.Equal(StatusCodes.Status200OK, okObjectResult.StatusCode); Assert.True(actual.Success); }