public void WebhookEventValidateNotSupportedAuthAlgorithm() { TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA1withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA256withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA512withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("MD5withDSA")); }
public void PaymentNullAccessToken() { var payment = GetPaymentForSale(); string accessToken = null; TestingUtil.AssertThrownException <System.ArgumentNullException>(() => payment.Create(new APIContext(accessToken))); }
public void APIContextInvalidAccessTokenConstructorTest() { TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("")); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("", "xyz")); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext(null)); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext(null, "xyz")); }
public void OAuthTokenCredentialMissingClientSecretTest() { var config = ConfigManager.Instance.GetProperties(); config[BaseConstants.ClientSecret] = ""; var oauthTokenCredential = new OAuthTokenCredential(config); TestingUtil.AssertThrownException <MissingCredentialException>(() => oauthTokenCredential.GetAccessToken()); }
public void AuthroizationReauthorizeTest() { var authorization = Authorization.Get(TestingUtil.GetApiContext(), "7GH53639GA425732B"); var reauthorizeAmount = new Amount(); reauthorizeAmount.currency = "USD"; reauthorizeAmount.total = "1"; authorization.amount = reauthorizeAmount; TestingUtil.AssertThrownException <PaymentsException>(() => authorization.Reauthorize(TestingUtil.GetApiContext())); }
public void WebhookEventValidateReceivedEventInvalidApiContextTest() { var requestBody = "{\"id\":\"WH-2W7266712B616591M-36507203HX6402335\",\"create_time\":\"2015-05-12T18:14:14Z\",\"resource_type\":\"sale\",\"event_type\":\"PAYMENT.SALE.COMPLETED\",\"summary\":\"Payment completed for $ 20.0 USD\",\"resource\":{\"id\":\"7DW85331GX749735N\",\"create_time\":\"2015-05-12T18:13:18Z\",\"update_time\":\"2015-05-12T18:13:36Z\",\"amount\":{\"total\":\"20.00\",\"currency\":\"USD\"},\"payment_mode\":\"INSTANT_TRANSFER\",\"state\":\"completed\",\"protection_eligibility\":\"ELIGIBLE\",\"protection_eligibility_type\":\"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE\",\"parent_payment\":\"PAY-1A142943SV880364LKVJEFPQ\",\"transaction_fee\":{\"value\":\"0.88\",\"currency\":\"USD\"},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N/refund\",\"rel\":\"refund\",\"method\":\"POST\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/payment/PAY-1A142943SV880364LKVJEFPQ\",\"rel\":\"parent_payment\",\"method\":\"GET\"}]},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335/resend\",\"rel\":\"resend\",\"method\":\"POST\"}]}"; var requestHeaders = new NameValueCollection { { "Paypal-Cert-Url", "https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77" }, { "Paypal-Auth-Version", "v2" }, { "Paypal-Transmission-Sig", "vSOIQFIZQHv8G2vpbOpD/4fSC4/MYhdHyv+AmgJyeJQq6q5avWyHIe/zL6qO5hle192HSqKbYveLoFXGJun2od2zXN3Q45VBXwdX3woXYGaNq532flAtiYin+tQ/0pNwRDsVIufCxa3a8HskaXy+YEfXNnwCSL287esD3HgOHmuAs0mYKQdbR4e8Evk8XOOQaZzGeV7GNXXz19gzzvyHbsbHmDz5VoRl9so5OoHqvnc5RtgjZfG8KA9lXh2MTPSbtdTLQb9ikKYnOGM+FasFMxk5stJisgmxaefpO9Q1qm3rCjaJ29aAOyDNr3Q7WkeN3w4bSXtFMwyRBOF28pJg9g==" }, { "Paypal-Transmission-Id", "b2384410-f8d2-11e4-8bf3-77339302725b" }, { "Paypal-Auth-Algo", "SHA256withRSA" }, { "Paypal-Transmission-Time", "2015-05-12T18:14:14Z" } }; TestingUtil.AssertThrownException <ArgumentNullException>(() => WebhookEvent.ValidateReceivedEvent(null, requestHeaders, requestBody)); }
public void OAuthTokenCredentialInvalidClientSecretTest() { try { var config = ConfigManager.Instance.GetProperties(); config[BaseConstants.ClientSecret] = "abc"; var oauthTokenCredential = new OAuthTokenCredential(config); TestingUtil.AssertThrownException <IdentityException>(() => oauthTokenCredential.GetAccessToken()); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PlanDeleteTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var plan = GetPlan(); var createdPlan = plan.Create(apiContext); this.RecordConnectionDetails(); var planId = createdPlan.id; // Create a patch request that will delete the plan var patchRequest = new PatchRequest { new Patch { op = "replace", path = "/", value = new Plan { state = "DELETED" } } }; createdPlan.Update(apiContext, patchRequest); this.RecordConnectionDetails(); // Attempting to retrieve the plan should result in a PayPalException being thrown. TestingUtil.AssertThrownException <PaymentsException>(() => Plan.Get(apiContext, planId)); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void SaleNullIdTest() { TestingUtil.AssertThrownException <System.ArgumentNullException>(() => Sale.Get(new APIContext("token"), null)); }
public void APIContextInvalidRequestIdConstructorTest() { TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("abc", "")); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("abc", null)); }