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. Anyone see 
what may be wrong?

Again, here is my current .xml file (all invokes, etc. in the single file for 
now)
------------
<?xml version="1.0"?>

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

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

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

          <verifyXPath
            description="Check login status code equals 200"
            xpath="//@statusCode='200'"
          />

          <storeXPath
            description="Extract value to sessionID for use with future calls"
            xpath="//@id"
            property="sessionID"
          />

          <invoke url="http://10.0.1.1:8080/infoList/v1/getFullList";
                                                description="Get Entire List"
          />

          <verifyXPath
            description="Check get list status code equals 200"
            xpath="//@statusCode='200'"
          />

          <invoke url="http://10.0.1.1:8080/identity/v1/logout"; 
sessionId="#{sessionID}"
            description="Logout valid user"
          />

          <verifyXPath
            description="Check logout status code equals 200"
            xpath="//@statusCode='200'"
          />

        </steps>
    </webtest>
  </target>
</project>
------------ 
 
The output in the WebTestReport.xml file I see when obtaining the sessiodID is: 
            
            <step>
                <parameter name="=> value" 
value="50BDD7FE276B9066AE2F0D662D3A931B"/>
                <parameter name="description" value="Extract value to sessionID 
for use with future calls"/>
                <parameter name="property" value="sessionID"/>
                <parameter name="taskName" value="storeXPath"/>
                <parameter name="xpath" value="//@id"/>
                <result>
                    <completed duration="2"/>
                </result>
            </step>

The output in the WebTestReport.xml file I see when using the sessiodID is:
            <step>
                <parameter name="description" value="Logout valid user"/>
                <parameter name="sessionId" 
value="50BDD7FE276B9066AE2F0D662D3A931B"/>
                <parameter name="taskName" value="invoke"/>
                <parameter name="url" 
value="http://10.0.1.1:8080/identity/v1/logout"/>
                <result>
                    <failed duration="0"/>
                </result>
            </step> 

Any thoughts on why this uri fails? The REST endpoint takes a "sessionID" and 
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 session 
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" <[EMAIL PROTECTED]> 01/11/08 9:00 AM >>> 
I'll followup my own post with some changes I've made, but which still do not 
work.
What am I doing wrong?

The new test .xml file I've generated and tested is as follows:
---------------
<?xml version="1.0"?>

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

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

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

                                        <verifyXPath
                                                description="Check status code 
eauals 200"
                                                xpath="//[EMAIL 
PROTECTED]'200']"
                                        />

                                        <storeXPath
                                                description="Extract session ID 
for use with future calls"
                                                xpath="//identity/[EMAIL 
PROTECTED]"
                                                property="sessionID"
                                        />

                                        <invoke 
url="http://10.0.1.1:8080/infoList/v1/getFullList";
                                                description="Get Entire List"
                                        />

                                        <invoke 
url="http://10.0.1.1:8080/identity/v1/logout"; sessionid="#{sessionID}"
                                                description="Logout valid user"
                                        />
                                </steps>
                </webtest>
        </target>
</project>
 ---------------
 
The first invoke returns:
---------------
<?xml version='1.0' encoding='UTF- 8'?><identity 
xmlns="http://10.0.1.1/identity/v1"; xmlns:fsapi- v1="http://10.0.1.1/v1"; 
version="1.0.20071219.0" statusMessage="OK" statusCode="200"><session 
id="6945B0AD3083631B9B9D2DAED1B5C250" /></identity>
---------------

I fail to verify the statusCode.

If I comment out the verify statusCode check then I fail to get and store the 
sessionID to be used for logout.

Can anyone tell me the error(s) in my code?

Thanks,
Doug

>>> "Douglas Beattie" <[EMAIL PROTECTED]> 01/10/08 10:09 AM >>> 
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 web 
services. I am attempting to use WebTest to validate some new RESTful APIs. 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 statusCode 
nor how I can get the returned session ID to use as an input for other 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 use it later. 
I'm thinking I need to perhaps use the verifyXPath with something like:
                                        <verifyXPath
                                                description="Get the status 
code"
                                                regex="false"
                                                text="200"
                                                xpath="//[EMAIL 
PROTECTED]'200']"
                                        />
but I'm not positive as I have not gotten this to work. All suggestions would 
be appreciated.

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

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

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

        <target name="test">
                <webtest name="Login valid User">
                        <steps>
                                <invoke 
url="http://10.0.1.1:8080/identity/v1/login"; username="jon" password="1234pass"
                                        description="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='1.0' encoding='UTF-  8'?><identity 
xmlns="http://10.0.1.1/identity/v1"; xmlns:fsapi-  v1="http://10.0.1.1/v1"; 
version="1.0.20071219.0" statusMessage="OK" statusCode="200"><session 
id="434DF084FA5968055B802AF6F4073725" /></identity>
-----------

Again, thanks for any help you may be able to provide me to get past this 
initial 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 intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.
_______________________________________________
WebTest mailing list
[email protected]
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 intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.
_______________________________________________
WebTest mailing list
[email protected]
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 intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to