Exemplo n.º 1
0
        public void GetResponseInvalidTokenExceptionTest()
        {
            ServiceContext    serviceContext = Initializer.InitializeServiceContextQbo();
            IRestHandler      handler        = new SyncRestHandler(serviceContext);
            string            resourceUri    = string.Format("v3/company/{0}/customer", AuthorizationKeysQBO.realmIdIAQBO);
            RequestParameters parameters     = new RequestParameters(resourceUri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML);

            Intuit.Ipp.Data.Customer customer = new Data.Customer();
            HttpWebRequest           request  = handler.PrepareRequest(parameters, customer);
            string response = handler.GetResponse(request);
        }
        public void GetResponseSuccessTest()
        {
            ServiceContext    serviceContext = Initializer.InitializeServiceContextQbo();
            IRestHandler      handler        = new SyncRestHandler(serviceContext);
            string            AccountId      = ConfigurationManager.AppSettings["AccountId"].ToString();
            string            resourceUri    = string.Format("v3/company/{0}/account/{1}", serviceContext.RealmId, AccountId);
            RequestParameters parameters     = new RequestParameters(resourceUri, HttpVerbType.GET, CoreConstants.CONTENTTYPE_TEXTXML);
            HttpWebRequest    request        = handler.PrepareRequest(parameters, null);
            string            response       = handler.GetResponse(request);

            Assert.IsTrue(!string.IsNullOrWhiteSpace(response));
        }
        public void PreparRequestSuccessNullRequestBodyTest()
        {
            ServiceContext    serviceContext = Initializer.InitializeServiceContextQbo();
            SyncRestHandler   handler        = new SyncRestHandler(serviceContext);
            string            resourceUri    = string.Format("v3/company/{0}/customer", serviceContext.RealmId);
            RequestParameters parameters     = new RequestParameters(resourceUri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
            HttpWebRequest    request        = handler.PrepareRequest(parameters, null);
            string            endpointUri    = string.Format("{0}{1}", serviceContext.BaseUrl, resourceUri);

            Assert.AreEqual(endpointUri.Trim(), request.RequestUri.ToString().Replace(request.RequestUri.Query, "").Trim());
            Assert.AreEqual(parameters.Verb.ToString(), request.Method.ToString());
            Assert.AreEqual(parameters.ContentType, request.ContentType);
        }
        public void GetResponseInvalidTokenExceptionTest()
        {
            OAuthRequestValidator validator  = new OAuthRequestValidator("adfas", "afd", "adfas", "asdfa");
            string            realmId        = ConfigurationManager.AppSettings["RealmIAQBO"];
            ServiceContext    serviceContext = new ServiceContext(realmId, IntuitServicesType.QBO, validator);
            IRestHandler      handler        = new SyncRestHandler(serviceContext);
            string            resourceUri    = string.Format("v3/company/{0}/customer", serviceContext.RealmId);
            RequestParameters parameters     = new RequestParameters(resourceUri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML);

            Intuit.Ipp.Data.Customer customer = new Data.Customer();
            HttpWebRequest           request  = handler.PrepareRequest(parameters, customer);
            string response = handler.GetResponse(request);
        }
        public void PreparRequestGZipCompressionTest()
        {
            ServiceContext serviceContext = Initializer.InitializeServiceContextQbo();

            serviceContext.IppConfiguration.Message.Request.CompressionFormat  = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
            serviceContext.IppConfiguration.Message.Response.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
            IRestHandler      handler     = new SyncRestHandler(serviceContext);
            string            resourceUri = string.Format("v3/company/{0}/customer", serviceContext.RealmId);
            RequestParameters parameters  = new RequestParameters(resourceUri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
            HttpWebRequest    request     = handler.PrepareRequest(parameters, new Customer());

            Assert.AreEqual(DataCompressionFormat.GZip.ToString().ToLowerInvariant(), request.Headers[CoreConstants.CONTENTENCODING]);
            Assert.AreEqual(DataCompressionFormat.GZip.ToString().ToLowerInvariant(), request.Headers[CoreConstants.ACCEPTENCODING]);
        }
Exemplo n.º 6
0
        public void GetResponseWithRetrySuccessTest()
        {
            ServiceContext serviceContext = Initializer.InitializeServiceContextQbo();

            serviceContext.IppConfiguration.RetryPolicy = new IntuitRetryPolicy(3, TimeSpan.FromSeconds(2));
            IRestHandler      handler     = new SyncRestHandler(serviceContext);
            string            AccountId   = "1";
            string            resourceUri = string.Format("v3/company/{0}/account/{1}", serviceContext.RealmId, AccountId);
            RequestParameters parameters  = new RequestParameters(resourceUri, HttpVerbType.GET, CoreConstants.CONTENTTYPE_APPLICATIONXML);
            HttpWebRequest    request     = handler.PrepareRequest(parameters, null);
            string            response    = handler.GetResponse(request);

            Assert.IsTrue(!string.IsNullOrWhiteSpace(response));
        }
        public void SyncRestHandlerPrepareRequestUpdateBaseURLQBOTest()
        {
            ServiceContext  serviceContext = Initializer.InitializeServiceContextQbo();
            SyncRestHandler handler        = new SyncRestHandler(serviceContext);
            string          resourceUri    = string.Format("v3/company/{0}/customer", serviceContext.RealmId);

            serviceContext.IppConfiguration.BaseUrl.Qbo = "http://www.intuit.com/";
            RequestParameters parameters  = new RequestParameters(resourceUri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
            HttpWebRequest    request     = handler.PrepareRequest(parameters, new Intuit.Ipp.Data.Customer());
            string            endpointUri = string.Format("{0}{1}", "http://www.intuit.com/", resourceUri);

            Assert.AreEqual(endpointUri.Trim(), request.RequestUri.ToString().Replace(request.RequestUri.Query, "").Trim());
            Assert.AreEqual(parameters.Verb.ToString(), request.Method.ToString());
            Assert.AreEqual(parameters.ContentType, request.ContentType);
        }
        public void GetResponseStreamSuccessTest()
        {
            ServiceContext      serviceContext = Initializer.InitializeServiceContextQbo();
            IRestHandler        handler        = new SyncRestHandler(serviceContext);
            List <SalesReceipt> salesReceipts  = Helper.FindAll <SalesReceipt>(serviceContext, new SalesReceipt());

            Assert.IsTrue(salesReceipts.Count > 0);
            string            resourceUri = string.Format("v3/company/{0}/salesreceipt/{1}/pdf", serviceContext.RealmId, salesReceipts[0].Id);
            RequestParameters parameters  = new RequestParameters(resourceUri, HttpVerbType.GET, CoreConstants.CONTENTTYPE_APPLICATIONXML);
            HttpWebRequest    request     = handler.PrepareRequest(parameters, null, includeRequestId: false);

            request.Accept = CoreConstants.CONTENTTYPE_APPLICATIONPDF;
            byte[] response = handler.GetResponseStream(request);
            Assert.IsTrue(response.Length > 0);
        }
Exemplo n.º 9
0
        public void GetResponseTimeoutNoTest()
        {
            ServiceContext serviceContext = Initializer.InitializeServiceContextQbo();

            //Set timeout 200 seconds
            serviceContext.Timeout = 200000;
            IRestHandler      handler     = new SyncRestHandler(serviceContext);
            string            AccountId   = "1";
            string            resourceUri = string.Format("v3/company/{0}/account/{1}", serviceContext.RealmId, AccountId);
            RequestParameters parameters  = new RequestParameters(resourceUri, HttpVerbType.GET, CoreConstants.CONTENTTYPE_TEXTXML);
            HttpWebRequest    request     = handler.PrepareRequest(parameters, null);
            string            response    = handler.GetResponse(request);

            Assert.IsTrue(!string.IsNullOrWhiteSpace(response));
        }
 public void GetResponseStreamFailureTest()
 {
     try
     {
         ServiceContext    serviceContext = Initializer.InitializeServiceContextQbo();
         IRestHandler      handler        = new SyncRestHandler(serviceContext);
         string            AccountId      = ConfigurationManager.AppSettings["AccountId"].ToString();
         string            resourceUri    = string.Format("v3/company/{0}/salesreceipt/3/", serviceContext.RealmId);
         RequestParameters parameters     = new RequestParameters(resourceUri, HttpVerbType.GET, CoreConstants.CONTENTTYPE_APPLICATIONXML);
         HttpWebRequest    request        = handler.PrepareRequest(parameters, null, includeRequestId: false);
         request.Accept = CoreConstants.CONTENTTYPE_APPLICATIONPDF;
         byte[] response = handler.GetResponseStream(request);
         Assert.IsTrue(response.Length > 0);
     }
     catch (IdsException idsEx)
     {
         Assert.IsNotNull(idsEx);
     }
 }