public IActionResult GetControllerInfoDto() { AssertTrackRequestSource(Request.HttpContext.Connection); ControllerInfoDto dto = new ControllerInfoDto(); dto.FullName = _sutController.GetType().FullName; dto.IsInstrumentationOn = _sutController.IsInstrumentationActivated(); return(Ok(WrappedResponseDto <ControllerInfoDto> .WithData(dto))); }
public IActionResult GetTestResults([FromQuery] string ids) { //java version: List<AdditionalInfo> additionalInfos = noKillSwitch(() -> sutController.getAdditionalInfoList()); IList <AdditionalInfo> additionalInfos = _sutController.GetAdditionalInfoList(); //Fake data here var dto = new TestResultsDto { AdditionalInfoList = Enumerable.Repeat(new AdditionalInfoDto { LastExecutedStatement = "\"TODO: LastExecutedStatement\"" }, additionalInfos.Count).ToList() }; return(Ok(WrappedResponseDto <TestResultsDto> .WithData(dto))); }
public IActionResult GetSutInfo() { string connectionHeader = Request.Headers["Connection"]; if (connectionHeader == null || !connectionHeader.Equals("keep-alive", StringComparison.OrdinalIgnoreCase)) { return(BadRequest( WrappedResponseDto <string> .WithError("Requests should always contain a 'Connection: keep-alive'"))); } AssertTrackRequestSource(Request.HttpContext.Connection); //TODO: uncomment after implementing VerifySqlConnection method // if (!_sutController.VerifySqlConnection ()) { // string msg = "SQL drivers are misconfigured. You must use a 'p6spy' wrapper when you " + // "run the SUT. For example, a database connection URL like 'jdbc:h2:mem:testdb' " + // "should be changed into 'jdbc:p6spy:h2:mem:testdb'. " + // "See documentation on how to configure P6Spy."; // SimpleLogger.Error (msg); // return StatusCode(StatusCodes.Status500InternalServerError, WrappedResponseDto<string>.WithError(msg)); // } SutInfoDto dto = new SutInfoDto(); dto.IsSutRunning = _sutController.IsSutRunning(); dto.BaseUrlOfSUT = _baseUrlOfSut; dto.InfoForAuthentication = _sutController.GetInfoForAuthentication(); //TODO: uncomment //dto.SqlSchemaDto = _sutController.GetSqlDatabaseSchema (); dto.DefaultOutputFormat = _sutController.GetPreferredOutputFormat(); IProblemInfo info = _sutController.GetProblemInfo(); if (info == null) { string msg = "Undefined problem type in the EM Controller"; SimpleLogger.Error(msg); return(StatusCode(StatusCodes.Status500InternalServerError, WrappedResponseDto <string> .WithError(msg))); } else if (info is RestProblem) { RestProblem rp = (RestProblem)info; dto.RestProblem = new RestProblemDto(); dto.RestProblem.OpenApiUrl = rp.GetSwaggerJsonUrl(); dto.RestProblem.EndpointsToSkip = rp.GetEndpointsToSkip(); } else { string msg = "Unrecognized problem type: " + info.GetType().FullName; SimpleLogger.Error(msg); return(StatusCode(StatusCodes.Status500InternalServerError, WrappedResponseDto <string> .WithError(msg))); } dto.UnitsInfoDto = _sutController.GetUnitsInfoDto(); if (dto.UnitsInfoDto == null) { string msg = "Failed to extract units info"; SimpleLogger.Error(msg); return(StatusCode(StatusCodes.Status500InternalServerError, WrappedResponseDto <string> .WithError(msg))); } return(Ok(WrappedResponseDto <SutInfoDto> .WithData(dto))); }