Validate() public method

Validates the response and attempts to detect root causes for failures for non 200 responses. The most common cause is due to time synchronization of the local server. If the local server is more than 30seconds out of sync then the API server will reject the request. TODO: catch rate limitting errors. Should delay and retry.
public Validate ( WebResponse response ) : void
response System.Net.WebResponse the active response object
return void
        public void TestAPIActionValidateDateDrift()
        {
            string TestURIProtocol = "asdf";

            WebRequest.RegisterPrefix(TestURIProtocol, new WebRequestTestCreate());
            var request = (HttpWebRequestTest)WebRequest.Create("asdf://www.example.com/");


            var signer   = new EdgeGridV1Signer();
            var response = request.CreateResponse(HttpStatusCode.ServiceUnavailable, "Server Unavailable");

            var currentDate = DateTime.UtcNow.AddMinutes(-2);
            var headers     = new WebHeaderCollection {
                { "Date", currentDate.ToString("r") }
            };

            response = request.CreateResponse(HttpStatusCode.ServiceUnavailable, "Server Unavailable", headers);
            try
            {
                signer.Validate(response);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, "Local server Date is more than 30s out of sync with Remote server");
                throw ex;
            }
        }
        public void TestAPIActionValidateOK()
        {
            string TestURIProtocol = "asdf";

            WebRequest.RegisterPrefix(TestURIProtocol, new WebRequestTestCreate());
            var request = (HttpWebRequestTest)WebRequest.Create("asdf://www.example.com/");


            var signer   = new EdgeGridV1Signer();
            var response = request.CreateResponse();

            signer.Validate(response);
        }
        public void TestAPIActionValidateUnavailable()
        {
            string TestURIProtocol = "asdf";

            WebRequest.RegisterPrefix(TestURIProtocol, new WebRequestTestCreate());
            var request = (HttpWebRequestTest)WebRequest.Create("asdf://www.example.com/");


            var signer   = new EdgeGridV1Signer();
            var response = request.CreateResponse(HttpStatusCode.ServiceUnavailable, "Server Unavailable");

            var currentDate = DateTime.UtcNow;
            var headers     = new WebHeaderCollection {
                { "Date", currentDate.ToString("r") }
            };

            response = request.CreateResponse(HttpStatusCode.ServiceUnavailable, "Server Unavailable", headers);
            signer.Validate(response);
        }