[Webtest] Basic verification and variable setting problem
- using the obtained value
Douglas Beattie
Douglas Beattie" <beattiedb@ldschurch.org
Fri, 11 Jan 2008 11:57:29 -0700
With more modifications I am not logging in and getting the list I want. I =
am not however able to pass the sessionID to the logout uri properly. Anyon=
e see what may be wrong?
Again, here is my current .xml file (all invokes, etc. in the single file f=
or now)
------------
<?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/identity/v1/login" username=
=3D"jon" password=3D"1234pass"
description=3D"Login valid user"
/>
<verifyXPath
description=3D"Check login status code equals 200"
xpath=3D"//@statusCode=3D'200'"
/>
<storeXPath
description=3D"Extract value to sessionID for use with future c=
alls"
xpath=3D"//@id"
property=3D"sessionID"
/>
<invoke url=3D"http://10.0.1.1:8080/infoList/v1/getFullList"
description=3D"Get Entire L=
ist"
/>
<verifyXPath
description=3D"Check get list status code equals 200"
xpath=3D"//@statusCode=3D'200'"
/>
<invoke url=3D"http://10.0.1.1:8080/identity/v1/logout" sessionId=
=3D"#{sessionID}"
description=3D"Logout valid user"
/>
<verifyXPath
description=3D"Check logout status code equals 200"
xpath=3D"//@statusCode=3D'200'"
/>
</steps>
</webtest>
</target>
</project>
------------=20
=20
The output in the WebTestReport.xml file I see when obtaining the sessiodID=
is:=20=20=20=20=20=20=20=20=20=20=20=20=20
<step>
<parameter name=3D"=3D> value" value=3D"50BDD7FE276B9066AE2=
F0D662D3A931B"/>
<parameter name=3D"description" value=3D"Extract value to s=
essionID for use with future calls"/>
<parameter name=3D"property" value=3D"sessionID"/>
<parameter name=3D"taskName" value=3D"storeXPath"/>
<parameter name=3D"xpath" value=3D"//@id"/>
<result>
<completed duration=3D"2"/>
</result>
</step>
The output in the WebTestReport.xml file I see when using the sessiodID is:
<step>
<parameter name=3D"description" value=3D"Logout valid user"=
/>
<parameter name=3D"sessionId" value=3D"50BDD7FE276B9066AE2F=
0D662D3A931B"/>
<parameter name=3D"taskName" value=3D"invoke"/>
<parameter name=3D"url" value=3D"http://10.0.1.1:8080/ident=
ity/v1/logout"/>
<result>
<failed duration=3D"0"/>
</result>
</step>=20
Any thoughts on why this uri fails? The REST endpoint takes a "sessionID" a=
nd its value as a parameter; simililar to how the login takes a "username" =
and "password" as its parameters.
If I manually (via the browser) make the call to logout and provide the ses=
sion id obtained in the login I get a valid "200" statusCode returned.
Thanks for any pointers any of you may be able to provide.
Doug
>>> "Douglas Beattie" <beattiedb@ldschurch.org> 01/11/08 9:00 AM >>>=20
I'll followup my own post with some changes I've made, but which still do n=
ot work.
What am I doing wrong?
The new test .xml file I've generated and tested is as follows:
---------------
<?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=
/identity/v1/login" username=3D"jon" password=3D"1234pass"
description=3D"Login valid =
user"
/>
<verifyXPath
description=3D"Check status=
code eauals 200"
xpath=3D"//identity[@status=
Code=3D'200']"
/>
<storeXPath
description=3D"Extract sess=
ion ID for use with future calls"
xpath=3D"//identity/session=
[@id]"
property=3D"sessionID"
/>
<invoke url=3D"http://10.0.1.1:8080=
/infoList/v1/getFullList"
description=3D"Get Entire L=
ist"
/>
<invoke url=3D"http://10.0.1.1:8080=
/identity/v1/logout" sessionid=3D"#{sessionID}"
description=3D"Logout valid=
user"
/>
</steps>
</webtest>
</target>
</project>
---------------
=20
The first invoke returns:
---------------
<?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.20071=
219.0" statusMessage=3D"OK" statusCode=3D"200"><session id=3D"6945B0AD30836=
31B9B9D2DAED1B5C250" /></identity>
---------------
I fail to verify the statusCode.
If I comment out the verify statusCode check then I fail to get and store t=
he sessionID to be used for logout.
Can anyone tell me the error(s) in my code?
Thanks,
Doug
>>> "Douglas Beattie" <beattiedb@ldschurch.org> 01/10/08 10:09 AM >>>=20
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.200=
71219.0" statusMessage=3D"OK" statusCode=3D"200"><session id=3D"434DF084FA5=
968055B802AF6F4073725" /></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.
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest
----------------------------------------------------------------------
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.
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest
----------------------------------------------------------------------
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.