What's the best way to generate a post request to test an API. Sadly, this won't work since there is no form to submit: create a post request using poltergeist and capybara
Never mind, just added a post method to the poltergiest driver:
https://github.com/nathantsoi/poltergeist
use it with:
Gemfile:
gem 'capybara', '~> 2.4.4'
gem 'poltergeist', github: 'nathantsoi/poltergeist'
Tests:
page.driver.browser.post 'https://vertile.com/api/client/v1/stuff.json', { email: 'me#vertile.com', awesomeness: '1000%' }
If you're testing an API there's no need for Poltergeist.
Poltergeist is useful for testing web pages with Javascript on them without a browser so it can run headless.
We use the Faraday gem to generate all the RESTful calls, GET, POST and etc to an API. But Httparty is just as good, or even bare net/http
Related
I'm trying to write a Cypress test that interacts with react-stripe-js's PaymentRequestButtonElement component. Unfortunately I'm hitting a little bit of a stumbling block actually getting my test to render the button (works fine when I manually test).
I've tried mocking the window's PaymentRequest function:
cy.window().then(win => {
if (win.PaymentRequest) {
// If we’re running in headed mode
cy.stub(win, 'PaymentRequest').callsFake(getMockPaymentRequest(validPaymentRequestResponse));
} else {
// else headless
win.PaymentRequest = getMockPaymentRequest(validPaymentRequestResponse)
}
});
but no luck, our button still doesn't appear. I suspect it has something to do with the following error I see in my console:
Unable to download payment manifest "https://google.com/pay"., but had a look through Google and seemingly nobody seems to have mentioned this.
I've also tried stubbing window.Stripe in a similar way (to mock out the stripe.paymentRequest function) but equally no luck there.
Has anyone had any success implementing something similar?
In order to test Stripe's Payment Request button in Cypress you will likely need to mock the Payment Request API:
Now that all the pieces are in place we can attempt to test something a bit trickier, the Payment Request API that Stripe conveniently wraps for us.
This API is used to detect whether a browser supports payment methods like Apple or Google Pay and then handles accepting payments via these APIs.
I have 2 microservices based on SAP SDK 3.0 archetype binded by the same xsuaa service.From the first microservice A, I wanted to call the second microservice B by using rest template. It fails to call, as it is not able to authenticate. Can you find my approach is right?
Sharing the code below along with the error screenshot
Error:
<200,document.cookie="fragmentAfterLogin="+encodeURIComponent(location.hash)+";path=/";document.cookie="locationAfterLogin="+encodeURIComponent(location.href.split('#')[0].split(location.host)1)+";path=/";document.cookie="signature=pim93tQhbcWCYYAiFxYkwrHBY%2Fs%3D;path=/";location="https://xxxxx.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-Ledify!t7251&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Flogin%2Fcallback",{x-request-id=[k8h8rf33], x-frame-options=[SAMEORIGIN], Cache-Control=[no-cache, no-store, must-revalidate], Content-Type=[text/html], Content-Security-Policy=[script-src 'self' 'unsafe-inline'], Date=[Wed, 01 Apr 2020 11:23:01 GMT], Connection=[keep-alive], Content-Length=[620]}>
Note : localhost:5000 is my local approuter port and it is configured to call the second microservice which I have tested it in browser
Updated:
I have updated with getToken() but I am getting the below error in my local approuter.
Error Response:
xsapp.json Route
{
"source": "/notif-mock/(.*)",
"authenticationType": "xsuaa",
"destination": "notif-mock",
"csrfProtection": true
}
FYI, I have used the local approuter setup as per this post Link here
In the following line, you are concatenating a String with DecodedJWT:
String encodedAuth = "Bearer " + getJWTTokenDetails();
But DecodedJWT does not implement a toString() method. You must use getToken() instead.
Hint: For easier support handling please copy/paste your code, because text in screenshot cannot efficiently be referenced.
Arun,
Thanks for providing all the additional details. I recommend updating to SDK Version 3.16.1 and testing if it solves your issue.
I do it because version 3.9.0 which you're using at the moment has an incomplete implementation of security scenarios invoked by XSUAA.
We fixed many issues related to the handling of XSUAA and JWT validation in release 3.15.1. Please, check release notes for details..
If even after update your issue persists, we'll have to see how we can reproduce it or get more logs data from you as a response only doesn't provide enough clue on where it fails.
Hope it helps!
As mentioned in the title I am using python v3.6
I'm trying to create a python application using the coinbase api and for my code i have
import coinbase
coinbase = coinbase.Coinbase.with_api_key('key','key') #Replacing the 'key's with my associated keys
and when i try to make the function call
coinbase.get_user()
I get the error
coinbase.error.CoinbaseAPIException: ('Status Code 404', 404, '{"errors":[{"id":"not_found","message":"Not found"}],"warnings":[{"id":"missing_version","message":"Please supply API version (YYYY-MM-DD) as CB-VERSION header","url":"https://developers.coinbase.com/api#versioning"}]}')
I went to the aforementioned website and found out about the CB-VERSION header and I have no idea how to implement this, every single way i've tried has failed and led to me getting the same error message.
from coinbase.wallet.client import Client
client = Client(
<api_key>,
<api_secret>,
api_version='2017-11-28')
That should work
Your problem is that you are using an unofficial, unmaintained, out-of-date and incompatible coinbase package. The latest commit was three years ago:
https://github.com/resy/coinbase_python3/commits/master
You'll need to get on board with a newer API, such as the official one:
https://github.com/coinbase/coinbase-python
I am trying to get myself mediafeeds information with the following API (using JInstagram library):
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
The response code is 404. I am not sure what I'm missing since the access_token is valid, the API is listed in the Ruby library, but it can't be found on the develop website.
I see there is a 404 error in this site for feeds to, but it are not same API.
Instagram changed their policy and also deprecated some APIs. Check the below link.
https://instagram.com/developer/changelog/
Old API
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
Use the below API instead of the above one
https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN
I am trying to use nipple to post to an url within my nodejs application, which itself is running on hapi.js
The documentation essentially doesn't seem to spell it out.
(https://www.npmjs.com/package/nipple)
I tried passing it as payload inside options but that, while not returning an error, returns a 400. Can someone provide a correct example doing a post using nipple?
Essentially, I have two variables that I need to send - let's call the var1 and var2.
Thanks!
That link says that the project has been renamed to wreck. On wreck's github, several of the tests are for a post requests, including this one:
https://github.com/hapijs/wreck/blob/master/test/index.js#L68
If you are still scratching your head, you could also try using curl or postman to sanity check your URL, regardless of any nipple/wreck errors. If that also gives you a 400, nipple/wreck may not be the culprit.