Code Monkey home page Code Monkey logo

rest-assured's People

Watchers

 avatar

rest-assured's Issues

Implement syntax

Scala: 
given parameters(map) do get("") and verify { json => 
assertEquals(json.johan.hello == "Hello Johan") }

Groovy: 
get("").and().verify { response, json -> assertEquals json.code, "ikk" }
get("").and().verify { response -> assertEquals json.code, "ikk" } // Works!


get("").and().verifyResponse("statusLine.statusCode", equalTo(200));
get("").and().verifyResponse(STATUS_CODE, equalTo(200));
get("").and().verifyResponse(header(johan), equalTo(200));

Java:
expect().content("lotto.winners.winnerId", hasItems(23, 
54)).when().get("/lotto");
expect().header("lotto.winners.winnerId", hasItems(23, 
54)).when().get("/lotto");
expect().contentType(XML).

Original issue reported on code.google.com by [email protected] on 27 Oct 2010 at 6:35

convertToString in RestAssuredResponseImpl can throw NPE

reader can be null in:

private String convertToString(Reader reader) {
    Writer writer = new StringWriter();
    char[] buffer = new char[1024];
    try {
      int n;
      while ((n = reader.read(buffer)) != -1) {
        writer.write(buffer, 0, n);
      }
    } finally {
      reader.close();
    }
    return writer.toString();
  }

Original issue reported on code.google.com by [email protected] on 3 Feb 2011 at 8:21

Add support for sessions

E.g. 

Session session = createSession();
session.expect().body("x.y.z", equalTo("xyz")).when().get("/xyz");
session.expect().body("z.y.x", equalTo("zyx")).when().get("/zyx");
session.close();

RA should automatically extract the session id from the header and pass it 
along to the next request.

Original issue reported on code.google.com by [email protected] on 13 Feb 2011 at 10:17

Add support for getting path from request

E.g. 

List<Object> shoppingCategories = get("/somewhere").read("shopping.category");

and:
xmlPath = new XmlPath(get("/somewhere").asString());

int foo = path.read("..");
List bar = path.read(".."); 

Original issue reported on code.google.com by [email protected] on 12 Feb 2011 at 11:30

Spurious basic authorisation warning

I am using RestAssured version 1.0.3, from the central Maven repository. The 
code below is being used to test authentication for a user that does not exist.

given()
    .auth()
    .basic("abcd", "abCD1")
.expect()
    .statusCode(401)
.when()
    .get("/");

This test passes, but the logger displays the following message.

Mar 3, 2011 11:37:58 AM org.apache.http.impl.client.DefaultRequestDirector 
handleResponse
WARNING: Authentication error: basic authorization challenge expected, but not 
found

Below are the associated response headers.

$ curl -i http://localhost:8080
HTTP/1.1 401 Authorization Required
WWW-Authenticate: Basic realm="myapplication"
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1391
Server: Jetty(7.3.0.v20110203)

$ curl --user abcd:abCD1 -i http://localhost:8080
HTTP/1.1 401 Unauthorized
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1371
Server: Jetty(7.3.0.v20110203)

I have tried to find the cause of this message, but have had little luck thus 
far. I get no such warning for tests with malformed credentials (eg. 
"u:ser:passwo:rd") or well-formed credentials for a user that does exist.

Original issue reported on code.google.com by [email protected] on 3 Mar 2011 at 1:44

XML parsing doesn't work well for lists

You cannot work with lists in XML parsing. E.g. get all items doesn't work. 
E.g. 
expect("rss.channel.item", ..) should return a list of all items but it only 
returns the first. This needs to be fixed.

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>something</title>
    <link>http://www.someone.com</link>
    <description>something RSS</description>
    <dc:creator>someone</dc:creator>
    <item>
      <title>A title</title>
      <link>http://www.something.com/link/1</link>
      <description>Description 1</description>
      <enclosure url="http://www.someone.com/somejpg.jpg" length="2721" type="image/jpg" />
      <pubDate>Mon, 10 Jan 2011 19:31:46 GMT</pubDate>
      <guid isPermaLink="false">http://www.something.com/link/1</guid>
      <dc:date>2011-01-10T19:31:46Z</dc:date>
    </item>
    <item>
      <title>Title 2</title>
      <link>http://www.something.com/link/2</link>
      <description>Description 2</description>
      <enclosure url="http://www.someone.com/someotherjpg.jpg" length="2721" type="image/jpg" />
      <pubDate>Mon, 10 Jan 2011 19:41:46 GMT</pubDate>
      <guid isPermaLink="false">http://www.something.com/link/2</guid>
      <dc:date>2011-01-10T19:42:46Z</dc:date>
    </item>
  </channel>
</rss>

Original issue reported on code.google.com by [email protected] on 27 Jan 2011 at 9:15

IllegalStateException when getting a 401

What steps will reproduce the problem?
Try to get the return of a HTTP 401 status code

What is the expected output? What do you see instead?
When we try this:
String returnStr = with().parameters("name", "tester", "paswoord", 
"paswoord").post("/rest/authentication/validation/").asString();

It gives the following exception: java.lang.IllegalStateException: You cannot 
use REST Assured expectations and return the response at the same time.

As we can see, we do not use an expectation but rather want the response.

What version of the product are you using? On what operating system?
1.1

Please provide any additional information below.
We have also tried: 
String returnStr = with().parameters("name", "tester", "paswoord", 
"paswoord").post("/rest/authentication/validation/").andReturn().body().asString
();


Original issue reported on code.google.com by [email protected] on 2 Mar 2011 at 2:56

Specify servlet-mapping prefix

E.g. instead of doing:
expect().body(..).when().get("/servlet-mapping-name/getStuff");
expect().body(..).when().get("/servlet-mapping-name/getOtherStuff");

It would be nice to be able to do:
RestAssured.servletMapping = "/servlet-mapping-name"

and then:
expect().body(..).when().get("/getStuff");
expect().body(..).when().get("/getOtherStuff");

Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 12:35

Imported library throwing signature exception

What steps will reproduce the problem?
1. Setting up a new project
2. Imported the 3 libraries as asked
3. When running the first test created the following exception happens
java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information 
does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(Unknown Source)
    at java.lang.ClassLoader.preDefineClass(Unknown Source)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.jayway.restassured.internal.ResponseSpecificationImpl.class$(ResponseSpecificationImpl.groovy)
    at com.jayway.restassured.internal.ResponseSpecificationImpl.$get$$class$org$hamcrest$Matchers(ResponseSpecificationImpl.groovy)
    at com.jayway.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:76)
    at test.java.SITRestTests.resttests.EM3GetTest.testEm3Rest(EM3GetTest.java:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
The latest. Using eclipse in conjunction with junit.

Essentially no tests can run.


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Mar 2011 at 4:59

Complete syntax

Scala: 
given parameters(map) do get("") and verify { json => 
assertEquals(json.johan.hello == "Hello Johan") }

Groovy: 
get("").and().verify { response, json -> assertEquals json.code, "ikk" }
get("").and().verify { response -> assertEquals json.code, "ikk" } // Works!


get("").and().verifyResponse("statusLine.statusCode", equalTo(200));
get("").and().verifyResponse(STATUS_CODE, equalTo(200));
get("").and().verifyResponse(header(johan), equalTo(200));

Java:
expect().content("lotto.winners.winnerId", hasItems(23, 
54)).when().get("/lotto");
expect().header("lotto.winners.winnerId", hasItems(23, 
54)).when().get("/lotto");
expect().contentType(XML).

Original issue reported on code.google.com by [email protected] on 27 Oct 2010 at 6:36

Add JSONP support

E.g. 

expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");

But perhaps it's better/easier to do something like:

expect().jsonp("callback", "y").body("root.child", 
equalTo("x")).when().get("/jsonp");

or:

expect().jsonp("callback").body("root.child", 
equalTo("x")).when().get("/jsonp"); 

which should generate a random method-name.

It should also be possible to set it as default:

RestAssured.expectedParser = jsonp("callback", "y");
RestAssured.expectedParser = jsonp("callback");
RestAssured.expectedParser = auto(); // Default

There should also be a JsonpPath that simply extends JsonPath and removes 
method call.

Original issue reported on code.google.com by [email protected] on 10 Mar 2011 at 2:00

Add custom List impl

Given:
greeting.name.children() = [{attributes={}, children=[], value=John}, 
{attributes={}, children=[], value=Doe}]

Should allow for:
expect().body("greeting.name.children()", hasItems("John", 
"Doe")).get("/anotherGreetXML")

I.e.:
children.containsKey("John") should return true






Original issue reported on code.google.com by [email protected] on 14 Feb 2011 at 9:24

Support for re-usable expectations and re-usable "givens"

Instead of doing: 

given().
        body(..).
        body(..).
        body(..).
        body(..).
        body(..).
        param(..).
expect().
         body(..).
         body(..).
         body(..).
         header(..).
when().
       get(..);

it would be nice to able able to re-use. E.g.

given().
        spec(requestSpec1).
        spec(requestSpec2).
expect().
        spec(responseSpec1).
        spec(responseSpec2).
when().
        get(..);

The specifications can be re-used in multiple tests.

Original issue reported on code.google.com by [email protected] on 23 Mar 2011 at 6:46

Enable setting root path in standard expecations

E.g. instead of

expect().
         body("x.y.firstName", is(..)).
         body("x.y.lastName", is(..)).
         body("x.y.age", is(..)).
         body("x.y.gender", is(..)).
when().get(..);

You should be able to do something in the line of:

expect().
         rootPath("x.y").
         body("firstName", is(..)).
         body("lastName", is(..)).
         body("age", is(..)).
         body("gender", is(..)).
when().get(..);


Original issue reported on code.google.com by [email protected] on 23 Mar 2011 at 6:49

Allow to print response

E.g. 

print().get("/something"); 

print should set "text/plain" parsing and simply print the reponse to the 
console. print() should return TestSpecification directly.

Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 8:53

Support for default authentication

E.g. instead of 

given().auth().basic("john", "doe").expect()..
given().auth().basic("john", "doe").expect()..
given().auth().basic("john", "doe").expect()..

you could do:

RestAssured.defaultAuth = basic("john", "doe");

Original issue reported on code.google.com by [email protected] on 24 Jan 2011 at 11:31

Add support for JsonPath syntax

Specify that you can set the pathSyntax:

RestAssured.pathSyntax = JSON_PATH;
RestAssured.pathSyntax = GROOVY;

JSON_PATH requires http://code.google.com/p/json-path/ in CP (optional 
dependency) whereas GROOVY uses the current impl.


Note that this setting should not be affected by the reset() method.

Original issue reported on code.google.com by [email protected] on 15 Feb 2011 at 7:45

Allow constant body expressions

E.g. 

expect().body(constant(ITEMS, ADDRESS, STREET), equalTo("something").when()..

where ITEMS, ADDRESS, and STREET are pre-defined (by user) strings that build 
up the . notation using String.format().

Original issue reported on code.google.com by [email protected] on 18 Jan 2011 at 8:14

Support getting empty bodies

We get an error message that you can't using exceptions when a response body  
is empty.

E.g. get("/emptyBody").asString() throws exception if /emptyBody returns an 
empty response body.

Original issue reported on code.google.com by [email protected] on 25 Mar 2011 at 9:13

Allow specifying parser method

E.g. if response mime type is text/plain but the content is XML you should be 
able to parse it using the XML parser. 

E.g. 

expect(..).with().parser('application/xml').when().get(..)

Original issue reported on code.google.com by [email protected] on 12 Jan 2011 at 8:10

Support for asObject

Responses should be serialized to Objects if we have e.g. Jackson or Jersey in 
CP. E.g. 

get("/something").asObject(MyClass.class);

MyClass should be annotated with standard javax bind annotations (XmlElement).

Original issue reported on code.google.com by [email protected] on 18 Jan 2011 at 9:00

Support for more even more content types

Register the "XML" IANA (http://www.iana.org/assignments/media-types/) content 
types as XML parsing. See 
http://groovy.codehaus.org/modules/http-builder/doc/contentTypes.html for 
details.

Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 7:08

Support pretty printing

Allow:

get("/something").andPrintBody();

Implementation:

 // pretty print format the response
                        def stringWriter = new StringWriter()
                        def node = new XmlParser().parseText(reader.text);
                        new XmlNodePrinter(new PrintWriter(stringWriter)).print(node)
                        return stringWriter.toString()

Only works for XML responses. Otherwise don't pretty print, just print.

The method should also return the (original or pretty?) body.

Original issue reported on code.google.com by [email protected] on 16 Jan 2011 at 8:12

Better error message

Filter out groovy stuff from error messages, e.g. when "get" on illegal path:

expect().body("validRoot.illegalChild.get(0)")..

Original issue reported on code.google.com by [email protected] on 21 Feb 2011 at 2:31

Avoid 406 Not acceptable

when doing e.g.:
expect().body("something").when().get("/admin");

and /admin has content-type of application/xml we force text parsing by setting 
the content-type header. This is bad because the server can then respond with a 
406. What we should do is to change parser 
(http://groovy.codehaus.org/modules/http-builder/doc/contentTypes.html) by:

http.parser.'application/xml' = http.parser.'text/plain'
http.parser.'application/json' = http.parser.'text/plain'

etc.

Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 8:05

Add support for assertions

E.g. 

given().
        param(x, y).
when().
        get("/lotto").
then(). 
        assertThat("lotto.lottoId", is(5));

Copy assertThat defs from JUnit. 

get("/lotto") returns an AssertableResponse class which extends Response and 
adds assertion capabilities.

Original issue reported on code.google.com by [email protected] on 15 Mar 2011 at 12:23

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.