public void RestTesterInvalidUrlTest()
        {
            // Make sure we don't get any proxy intercepts
            var restConfig = new RestConfig();
            var input      = new List <List <string> >
            {
                new List <string> {
                    "Proxy", "None"
                }
            };

            _ = restConfig.DoTable(input);

            var rt = new RestTester
            {
                EndPoint    = "http://localhost:8765",
                RequestBody = "{ \"userId\":96 }"
            };

            rt.SendTo("Post", "posts");

            Assert.AreEqual(403, rt.ResponseCode);
        }
Esempio n. 2
0
        public void RestConfigTableTest()
        {
            var c     = new RestConfig();
            var input = new List <List <string> >
            {
                new List <string> {
                    "DefaultAccept", "application/json"
                },
                new List <string> {
                    "DefaultContentType", "application/json"
                },
                new List <string> {
                    "Headers", "header1:test1\r\nheader2:test2"
                },
                new List <string>
                {
                    "ContentTypeMapping",
                    "application/xml:XML\r\napplication/json:JSON\r\ntext/plain:TEXT\r\ndefault:JSON"
                },
                new List <string> {
                    "Proxy", "System"
                },
                new List <string> {
                    "Encoding", "iso-8859-1"
                },
                new List <string> {
                    "DefaultUserAgent", "FitNesseRest"
                },
                new List <string> {
                    "DefaultXmlNameSpaceKey", "atom"
                },
                new List <string> {
                    "XmlValueTypeAttribute", string.Empty
                },
                new List <string> {
                    "Timeout", "7.5"
                },
                new List <string> {
                    "TrimWhitespace", "false"
                },
                /* new List<string> {"CookieDomain", "localhost"}, */
                new List <string> {
                    "Cookies", "cookie1=value1\r\ncookie2=value2"
                },
                new List <string> {
                    "SecurityProtocol", "Tls12"
                },
                // this must be the last one
                new List <string> {
                    "NonExisting", "Bogus Value"
                }
            };

            var output = c.DoTable(input);

            Assert.AreEqual(input.Count, output.Count);
            for (var i = 0; i < output.Count - 1; i++)
            {
                var line = output[i] as List <string>;
                Assert.IsNotNull(line);
                Assert.AreEqual(string.Empty, line[0]);
                Assert.AreEqual("pass", line[1], "line " + i);
            }

            var lastLine = output[output.Count - 1] as List <string>;

            Assert.IsNotNull(lastLine);
            Assert.AreEqual(string.Empty, lastLine[1]);
        }