Login | Register
My pages Projects Community openCollabNet

Discussions > users > [maxq-users] MaxQ and Stuts token

maxq
Discussion topic

Back to topic list

[maxq-users] MaxQ and Stuts token

Author mregazzi
Full name Matteo Regazzi
Date 2005-02-08 06:00:30 PST
Message Hi, as I said in a prior email, I found a problem using MaxQ with applications
that use the Token generation/validation feature offered by Stuts. In fact
you record a script but the recorder hard codes the token it received. So
I made a quick and dirty solution: I added a method in the HttpTestCase class,
named getStrutsToken(), that parses the responseString and returns the token
(now it's based on the string position). So you can record a full script,
then edit it adding the instruction:
strutsToken=self.get​StrutsToken()
just after the post to the page that returns the token. Last you have to
modify the params definition just befor the invocation of the page/action/servlet
ecc that needs the token. The instruction:

params = [('''org.apache.stru​ts.taglib.html.TOKEN​''', '''d52c0177385dc8d27​c9fbc8b7d49d46a'''),​]

becomes:

params = [('''org.apache.stru​ts.taglib.html.TOKEN​''', strutsToken),]

This is the code of the new method: I know it's owful with a lot of magic
numbers and magic strings, but everyone can start from here in order to
develop a good solution (for example I'm thinking to a simple replaceToken
method in order to have a single instruction to add to the script ecc. ecc.)

    public String getStrutsToken() {
        String responseString = new String(method.getRes​ponseBodyAsString())​;
        String strutsToken = null;
        int index = responseString.index​Of("org.apache.strut​s.taglib.html.TOKEN"​);

        index = index + 44;
        strutsToken = responseString.subst​ring(index,index + 32);
        return strutsToken;
    }


Bye
Matteo

____________________​____________________​____________________​______
Tiscali Adsl 3 Mega Flat, 3 MESI GRATIS!
Con Tiscali Adsl 3 Mega Flat navighi in Rete alla supervelocita'
a soli 29.95 euro al mese senza limiti di tempo. Attivati entro
il 15 Febbraio 2005, 3 MESI sono GRATIS
Scopri come http://abbonati.tisc​ali.it/adsl/sa/2flat​_tc/




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@ma​xq.tigris.org
For additional commands, e-mail: users-help at maxq dot tigris dot org

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

[maxq-users] MaxQ and Stuts token mregazzi Matteo Regazzi 2005-02-08 06:00:30 PST
     Re: [maxq-users] MaxQ and Stuts token oliverbock Oliver Bock 2005-02-08 15:11:23 PST
Messages per page: