[Webtest] New user - basic verification and variable setting problem

Douglas Beattie Douglas Beattie" <beattiedb@ldschurch.org
Thu, 10 Jan 2008 10:09:59 -0700


I have used C and done much work with Unix internals over 20 years, but am =
very new to programing and testing with html, java, xml, XPath, ... type we=
b services. I am attempting to use WebTest to validate some new RESTful API=
s. In doing this I have run into what I'm sure is a very basic problem that=
 many of you could easily handle.

I have the following test file to do a login using a RESTful uri endpoint. =
I can do the login, but I have not seen how I can verify the returned statu=
sCode nor how I can get the returned session ID to use as an input for othe=
r endpoint calls I will be testing. I would simply like to know what I have=
 to do to verify the statusCode then get and save the session ID so I can u=
se it later. I'm thinking I need to perhaps use the verifyXPath with someth=
ing like:
                                        <verifyXPath
                                                description=3D"Get the stat=
us code"
                                                regex=3D"false"
                                                text=3D"200"
                                                xpath=3D"//identity[@status=
Code=3D'200']"
                                        />
but I'm not positive as I have not gotten this to work. All suggestions wou=
ld be appreciated.

My tests/loginValidUser.xml file contains:
-----------
<?xml version=3D"1.0"?>

<!DOCTYPE project SYSTEM "../dtd/Project.dtd">

<project name=3D"loginValidUser" default=3D"test">

        <target name=3D"test">
                <webtest name=3D"Login valid User">
                        <steps>
                                <invoke url=3D"http://10.0.1.1:8080/identit=
y/v1/login" username=3D"jon" password=3D"1234pass"
                                        description=3D"Login valid user"/>

<!-- I want to be able to verify the statusCode from this operation is 200
     If it is then I want to be able to to get the session ID, store it in =
a variable to use in other tests
     Then proceed to the next step.
     If the statusCode is not 200 I should just fail and stop all tests at =
this point.
 -->

                        </steps>
                </webtest>
        </target>
</project>
-----------

The response I receive to the file results/001_LoginValidUser/001_response_=
invoke.xml when doing the invoke above is:
-----------
<?xml version=3D'1.0' encoding=3D'UTF-8'?><identity xmlns=3D"http://10.0.1.=
1/identity/v1" xmlns:fsapi-v1=3D"http://10.0.1.1/v1" version=3D"1.0.2007121=
9.0" statusMessage=3D"OK" statusCode=3D"200"><session id=3D"434DF084FA59680=
55B802AF6F4073725" /></identity>
-----------

Again, thanks for any help you may be able to provide me to get past this i=
nitial road block.
Doug


----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended recipient(s)=
 and may contain confidential and privileged information. Any unauthorized =
review, use, disclosure or distribution is prohibited. If you are not the i=
ntended recipient, please contact the sender by reply email and destroy all=
 copies of the original message.