Esempio n. 1
0
        public async Task TestHttpsApiRestShApiV()
        {
            // Parameters for the API call
            string user = null;

            // Perform API call
            Models.VerifyModelResponse result = null;

            try
            {
                result = await controller.UserVerificationAsync(user);
            }
            catch (APIException) {};

            // Test response code
            Assert.AreEqual(200, httpCallBackHandler.Response.StatusCode,
                            "Status should be 200");

            // Test headers
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Accept-Ranges", null);
            headers.Add("Connection", null);
            headers.Add("Content-Length", null);
            headers.Add("Content-Type", null);
            headers.Add("Date", null);
            headers.Add("Server", null);
            headers.Add("Vary", null);
            headers.Add("Via", null);
            headers.Add("X-Cache", null);
            headers.Add("X-Cache-Hits", null);
            headers.Add("X-Served-By", null);
            headers.Add("X-Timer", null);
            headers.Add("access-control-allow-origin", null);
            headers.Add("cache-control", null);
            headers.Add("etag", null);
            headers.Add("function-execution-id", null);
            headers.Add("strict-transport-security", null);
            headers.Add("x-cloud-trace-context", null);
            headers.Add("x-content-type-options", null);
            headers.Add("x-dns-prefetch-control", null);
            headers.Add("x-download-options", null);
            headers.Add("x-frame-options", null);
            headers.Add("x-powered-by", null);
            headers.Add("x-xss-protection", null);

            Assert.IsTrue(TestHelper.AreHeadersProperSubsetOf(
                              headers, httpCallBackHandler.Response.Headers),
                          "Headers should match");

            // Test whether the captured response is as we expected
            Assert.IsNotNull(result, "Result should exist");

            Assert.AreEqual("{\n    \"request\": \"REQUEST TYPE\",\n    \"to\": \"USER BEING VERIFIED\",\n    \"verified\": \"RETURNS TRUE OR FALSE\",\n    \"id\": \"TRANSACTION ID\"\n}",
                            TestHelper.ConvertStreamToString(httpCallBackHandler.Response.RawBody),
                            "Response body should match exactly (string literal match)");
        }