public void ListTest() { ServiceManager target = new ServiceManager(); var actual = target.List(); Assert.IsTrue(actual.Count > 0, "No Services?"); }
public void ServiceManagerConstructorTest() { string host = Settings.Hostname; string username = Settings.Username; string password = Settings.Password; ServiceManager target = new ServiceManager(host, username, password); //no exceptions, ok }
public ActionResult ServersStatus(string serverName) { var authres = CheckAuthorizationAndLog(Audit.AuditTypeEnum.View, false, serverName, "Get server service status","",""); if (authres != null) return authres; ServiceManager sm = new ServiceManager(serverName, Session["Username"] as string, Session["Password"] as string); var services = sm.List(); var service = services.FirstOrDefault(i => i.Name == "DNS"); if (service == null) return Content("Not installed"); return Content(service.State.ToString()); }
public ActionResult ServerServiceAction(string serverName, string serviceName, string action) { var authres = CheckAuthorizationAndLog(Audit.AuditTypeEnum.Change, true, serverName,"","", "change service state"); if (authres != null) return authres; //Check service name is in allowed list if (!AllowedServiceControlNames.Contains(serviceName)) { Audit.Log(Audit.AuditTypeEnum.UnauthorizedAccess, serverName, (Session["Domain"] as string) + "\\" + (Session["Username"] as string), NetworkHelper.ClientIPAddress(HttpContext), "Attempted to change service state for an unauthorized service","",""); return new HttpUnauthorizedResult(); } ServiceManager sm = new ServiceManager(serverName, Session["Username"] as string, Session["Password"] as string); var service = sm.List().Where(i => i.Name == serviceName).FirstOrDefault(); if (service != null) { switch (action.ToLower()) { case "stop": service.StopService(); break; case "start": service.StartService(); break; case "pause": service.PauseService(); break; case "resume": service.ResumeService(); break; case "restart": service.StopService(); service.StartService(); break; } } return Content(true.ToString()); }
public void ServiceManagerConstructorTest1() { ServiceManager target = new ServiceManager(); //no exceptions, ok }