public string Invoke(string responseId = null)
        {
            var response = SoapClient.GetResponse(responseId);

            var incidents = new List <string>();

            if (!string.IsNullOrWhiteSpace(response.Headers["Server"]))
            {
                incidents.Add($"Server header disclosure ({response.Headers["Server"]})");
            }

            if (!string.IsNullOrWhiteSpace(response.Headers["X-Powered-By"]))
            {
                incidents.Add($"X-Powered-By header disclosure ({response.Headers["X-Powered-By"]})");
            }

            if (string.IsNullOrWhiteSpace(response.Headers["X-Frame-Options"]) ||
                !string.Equals(response.Headers["X-Frame-Options"], "deny", StringComparison.InvariantCultureIgnoreCase))
            {
                incidents.Add($"X-Frame-Options header different than DENY ({response.Headers["X-Frame-Options"]})");
            }

            if (incidents.Any())
            {
                throw new AssertionException(
                          "Response should not contain sensitive information",
                          string.Join(Environment.NewLine, incidents),
                          WebDrivers.Default);
            }

            return("true");
        }
Esempio n. 2
0
        public string Invoke(string maxDuration, string responseId = null)
        {
            var response = SoapClient.GetResponse(responseId);

            if (response.Duration > TimeSpan.Parse(maxDuration))
            {
                throw new AssertionException(
                          $"Duration is smaller than {maxDuration}",
                          $"Duration was {response.Duration}",
                          WebDrivers.Default);
            }

            return("true");
        }
        public string Invoke(string statusCodes, string responseId = null)
        {
            var response   = SoapClient.GetResponse(responseId);
            var statusCode = ((int)response.StatusCode).ToString();

            if (!statusCodes.Split(',').Contains(statusCode))
            {
                throw new AssertionException(
                          $"Status code must equal {string.Join(",", statusCodes)}",
                          $"Status code was {statusCode}",
                          WebDrivers.Default);
            }

            return("true");
        }
        public string Invoke(string responseId = null)
        {
            var response   = SoapClient.GetResponse(responseId);
            var statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
            {
                throw new AssertionException(
                          $"Status code must be smaller than 400",
                          $"Status code was {statusCode}",
                          WebDrivers.Default);
            }

            return("true");
        }
Esempio n. 5
0
        private JsonResult GetResponse()
        {
            logger.WriteLog(LogLevel.DEBUG, "Configuring parameters");

            Dictionary <string, string> ctsParams = new Dictionary <string, string>
            {
                { "WsSecurity-Username", "franco.milanese" },
                { "Endpoint", "http://172.28.195.215:9080/COBISCorp.eCOBIS.PfWebConsultaNovedadEnvioMail.Service/PfWebConsultaNovedadEnvioMailWSService" },
                { "Timeout", "10000" },
                { "SOAPAction", "http://service.pfwebconsultanovedadenviomail.ecobis.cobiscorp.ws/PfWebConsultaNovedadEnvioMail/PfWebConsultaNovedadEnvioMail" },
                { "SOAPVersion", "1.1" }
            };

            ICtsBodyRequest input;
            SoapClient      soapClient;

            input = new PfWebConsultaNovedadEnvioMail(this.fil);

            logger.WriteLog(LogLevel.DEBUG, "Creating SoapClient for: " + ctsParams["Endpoint"]);
            soapClient = new SoapClient(logger, input, ctsParams);
            IParser ctsParser;

            try
            {
                logger.WriteLog(LogLevel.INFO, "Getting Soap Response");
                XDocument soapResponse = soapClient.GetResponse();

                logger.WriteLog(LogLevel.INFO, "Parsing Soap Response");
                ctsParser = new PfWebConsultaNovedadEnvioMailParser(soapResponse);

                logger.WriteLog(LogLevel.INFO, "Retrieving JSON Response");
            }
            catch (Exception ex)
            {
                ctsParser = new PfWebConsultaNovedadEnvioMailParser(ex);
            }

            return(ctsParser.GetJsonResponse());
        }