Testing REST webservices [closed]
Asked Answered
I

24

63

My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.

  1. Are there any publicly available RESTful services available on the net for free that someone could test ?
  2. What tools are available(and used) for testing RESTful web services ?
Irwinirwinn answered 15/10, 2008 at 2:6 Comment(2)
Regarding the title "Teting REST webservices" ... I hope you mean 'Test' and aren't making an obscure reference to the Tet Offensive (talk about hardening a server!)Plowshare
I meant Testing, of course. thanks micahwittman and Chris for fixing itIrwinirwinn
A
28

soapUI will do the job as well, check out this blog post to get started.

Amargo answered 24/6, 2009 at 9:52 Comment(1)
Maybe soapUI works, but I can't tell because it constantly crashes on my Ubuntu machine, killing Eclipse and causing me to lose any unsaved work. I've tried all the usual workarounds. The standalone edition is worse.Early
B
25

Please try Firefox addon Poster , which is simple to use and gets you up nd running quickly

Batty answered 15/10, 2008 at 10:42 Comment(1)
Actually, I take back my +1. When inspecting the traffic Poster sends through, it is malformed which causes problems for my webservice. When you add parameters and do either POST or PUT it will not actually send those parameters and it will not send a content-type unless you explicitly add content.Whey
M
20

You can exercise web services using fairly trivial bits of Python. Depending on your security, you may be able to simply use Python's urllib or urllib2 to do do you REST requests and examine your answers.

Additionally, you might want to use Python unittest to control the execution of the Python tests of your REST services.

class TestSomeREST( unittest.TestCase ):
    def setUp(self):
        REALM = "[email protected]"
        self.client= RESTClient( "localhost", 18000, "tester", "tester", REALM )
    def test_1_get(self):
        response = self.client.get('/this/that/other/2/')
        self.failUnlessEqual(200, response.status_code)
        j1= JSONDecoder().decode(response.content)
        self.assertEquals(2, j1[0]['pk'] )
        entity= j1[0]['fields']
        self.assertEquals('Some Other Group', entity['name'])
        self.assertEquals('E1G2', entity['customer_id'])

The RESTClient class uses urllib2 to pass through digest authentication for each request. It's rather complex, but I can share the essence if it's of interest.

Mears answered 15/10, 2008 at 3:9 Comment(0)
N
12

Check out Fiddler

Nature answered 15/10, 2008 at 2:43 Comment(0)
T
8

CURL Gets you halfway there. The other half is checking the headers, response codes and entity content to make sure its good. You could use a variety of tools for that (in shell scripting land, piping the header and contents to files, and diffing them might just do the trick). It wouldn't be that difficult to further refine the toolset, maybe stacking curl up with the unit-testing framework of your choice.

I built a rest webservice testing panel with AJAX. It wasn't that difficult at all actually. You have some security issues to work out (i.e. making sure that you have the test suite on the same server, or maybe signed Javascript.)

Turner answered 15/10, 2008 at 2:41 Comment(1)
Yes, CURL rules for REST testing. curl.haxx.seListed
B
8

To test a REST service you can try REST Assured which makes it very simple to test REST services and validating the response in Java (using JUnit or TestNG).

Borszcz answered 5/1, 2011 at 16:48 Comment(0)
P
8

Check out Postman - https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm/. This is a tool I have been working on over the past several months and lately from the feedback that I have been getting it's becoming quite useful for large REST projects while helping with basic REST endpoint testing.

The code for this is available on Github as well. https://github.com/a85/POSTMan-Chrome-Extension

Poulterer answered 2/6, 2012 at 0:25 Comment(0)
I
6

The simplest way to test REST web service is using curl in terminal.

There are some codes I used to test my web service of rails. You may modify them to fit your services.

GET

curl http://localhost:3000/courses.json

POST

curl -H "Content-Type:application/json"  -d '{"courseCode":"55555","courseName":"SEEEE","courseYr":999}' http://localhost:3000/courses.json

PUT in Raills: eg1(with all fields) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseCode":"123456","courseName":"AAAAAAAA","courseYr":12345}' http://localhost:3000/courses/5.json

eg2(with the field only be edited) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseYr":999999999}' http://localhost:3000/courses/3.json

DELETE in rails with id provided

 curl -H "X-Http-Method-Override: delete" -H "Content-Type:application/json"  -d '{"id":4}' http://localhost:3000/courses/5.json
Ignatzia answered 11/11, 2012 at 16:56 Comment(0)
N
4

I don't have tested it yet but this Java app seems to be nice to test REST services. There is also a tutorial on Javalobby about it.

Java App: http://code.google.com/p/rest-client/

Tuto: http://java.dzone.com/announcements/wiztoolsorg-restclient-21-rele

Navicert answered 19/1, 2009 at 13:31 Comment(0)
M
3

you can use the Simple REST Client is an extension for Google Chrome too https://chrome.google.com/webstore/detail/fhjcajmcbmldlhcimfajhfbgofnpcjmb

Mantling answered 20/12, 2010 at 16:2 Comment(0)
S
2

SOA Cleaner, is a test tool that tests both soap and rest (also WCF, but it seems you don't need that feature). It's very intuative, and usable. Written in .NET. A free version is also available. can be downloaded from http://xyrow.com. Good luck!

Seeger answered 16/9, 2009 at 8:2 Comment(0)
P
1

I'm using REST console extension for Google Chrome and It's by far the best i've tried. It also supports various security mechanisms like OAuth

(update 2: fix link)

Pentothal answered 17/6, 2011 at 8:45 Comment(0)
I
1

I'm testing RESTful services with an in house .NET framework (no problem porting it in Java). Basic principles:

  • build client (to make the calls)
  • build type classes (XML and JSON)
  • deserialize response
  • assert stuff

If you want more info, I'm glad to talk.

Infarction answered 29/5, 2012 at 14:20 Comment(0)
K
1

For java, there also exists RESTFuse, which allows to develop unit tests which may look like this:

@Rule
public Destination destination = new Destination("http://localhost:8080/rest/");


@HttpTest( method = Method.GET, path = "/status" ,authentications =
   @Authentication(type = AuthenticationType.BASIC, user = "joe", password = "doe")
)
public void testAuthRhqadmin() {
    com.eclipsesource.restfuse.Assert.assertOk(response);
}

This test runs against http://localhost:8080/rest/status and authenticates as user joe with password doe. The body of the method then checks that the GET call returns a 200 status code.

Kicker answered 6/9, 2012 at 10:46 Comment(0)
A
0

Try Python's httplib. It's very easy, you specify the method, url, and use urllib.urlencode for the parameters/POST body.

This can be combined with the builtin unittest module if you like, for reporting of errors.

Atheism answered 15/10, 2008 at 3:11 Comment(0)
E
0

I've been using JMeter for this, especially for stuff like load testing. It's similar to SoapUI (which I've also used), but geared more toward testing web pages, which makes it pretty decent at testing RESTful services, too.

Enlistment answered 15/10, 2008 at 19:53 Comment(0)
U
0

I've written a program specifically for testing REST Web Services. Its a pretty simple application written in .NET 2.0 (I've only tested it on Windows Vista, but should work on XP also). The application uses HttpWebRequest to make requests, and displays the resulting response, as well as the headers for the request and response. I've done a bit of testing, but I thought it might help you test your web services.

REST Test

Underexposure answered 24/12, 2008 at 3:40 Comment(0)
K
0

I'm currently investigating wsclient CLI app for this purpose (http://wso2.org/library/3362). It is quite promising, and can be used to hack a quick test from a bash shell. Of course, as many mentioned here, many of the tools that come with a *nix system will do the job with a tidbit of coding/scripting

Kisumu answered 8/12, 2009 at 2:23 Comment(0)
A
0

If you like using Ruby there's a REST-Client gem for it

For testers I find ruby is a really easy language to learn, and it has some excecllent tools like Cucumber for doing BDD style acceptance tests.

Altorelievo answered 11/1, 2012 at 0:41 Comment(0)
C
0

I've tried numerous REST clients and by far the best I've used is the Chrome app: DHC.

DHC (aka Dev HTTP Client) is designed and developed by a developer for developers to make direct HTTP resource discovery, manipulation and testing more easily. Beside the main function, sending/receiving custom HTTP requests/responses, it allows permanently to save a request to a local repository for later reuse and moreover the request declaration can include variables that are context specific. With the use of contexts you can easily switch between various environments without modifying request declaration. (e.g. from a test environment to production)

Chasse answered 26/8, 2014 at 16:19 Comment(0)
C
0

Testing REST full web services is a easy task to do. Free ad-ons are available on the browsers as REST Client from where you have to send a web service with expected/required method type: GET/POST/PUT/DELETE If the parameters are matched then output will get generated in the body of browser.enter image description here

Camarena answered 16/9, 2014 at 11:34 Comment(2)
Even when I know how to test REST web services & have used plugins like Postman & RestClient, I didn't find it easy to understand what you're trying to say. I'm sure someone who asks the question will not understand it properly. I would request you to work on writing more clearly.Unfreeze
I hope the attachment will help you...!Camarena
B
0

I know it is very old question, but could be helpful to others. Just to answer your first question you can check here to get some REST webservices to test.

Fiddler and Poster plug in Firefox can be use to test any REST web services. SoapUI also comes with RESTful webservices support.

Brett answered 1/3, 2015 at 7:45 Comment(0)
L
0

For advanced REST testing you can try HttpMaster.
It supports dynamic parameters, friendly viewers for XML/JSON, and various types of response data validations that can be combined into logical expressions.
For basic http requests some browser plugin will be sufficient.

Libelant answered 1/4, 2015 at 19:34 Comment(0)
R
-1

OnionTest still beta , but quite useful

Regeneration answered 16/8, 2011 at 6:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.