API failures are inevitable; the important part is how quickly you can react. Here are 4 common API failures, and how you can test them.
Preventing and reacting to problems in your web services is something every developer, QA analyst, and project manager should be thinking about often. As web services grow they require more complex types of testing, but there are a few fundamentals that should always be covered in your automated API tests.
Here's how you can continuously monitor your web service for these issues using Assertible.
Invalid SSL certificates
It happens to the best of us: once a year an SSL cert expires and error reports start rolling in from API clients. These types of outages can be tough to track down and correct, so it's important to monitor your APIs SSL certificates and be alerted of any failures.
SSL validation testing with Assertible
a core assertion to validate SSL every time a
test is run. If the validation of your certificate doesn't pass, the
AssertValidSsl core assertion will fail the test. This
is configurable per environment, so if your
production web service requires SSL, but your
staging app doesn't,
you can configure your tests to only validate SSL in
Service provider outages
Sometimes it's not our fault. Service providers go out too. A web service becoming unreachable can cause widespread issues. Monitoring your API with a ping can help spot these situations fast.
Frequent health checks with Assertible
A basic request to test for
200 status codes is a good way to ensure
your service is reachable. You can add these tests to
a schedule on your web
service that runs on a given interval and alerts on any failures.
Too many redirects
Redirects in APIs and web applications are a part of how some services
work, but if something spins out of control you don't want Chrome
showing your users a
TOO_MANY_REDIRECTS page instead of your app.
Enforce a redirect limit
The Max redirects setting on each test sets a limit of the number of redirects the test's request can make. If it exceeds that number, the test will fail. Any API or web app that utilizes redirects, should have these cases tested.
Invalid payload formats
Sometimes applications return data in unexpected formats, like when a JSON API responds with an HTML error page, and things start to go wrong. It's important to validate your APIs response data, in normal and error scenarios, so your clients don't start to fail.
Payload validation with Assertible
Assertible has a JSON validation and an HTML validation assertion to test the response of your API. Every time your test is run, the response body will be checked and you will (hopefully!) see a passing assertion:
Having your bases covered with these steps is good start to correctly testing your APIs and web services. You can join Assertible for free and get started today!
Feedback or Questions? Tell us your thoughts on Twitter.
The easiest way to test and
monitor your web services
Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.Get started with GitHubSign up for free
New feature: Smarter notifications 5/17/2019