log in using fitnesse

Posted by user1513027 on Stack Overflow See other posts from Stack Overflow or by user1513027
Published on 2012-07-09T21:13:27Z Indexed on 2012/07/09 21:15 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

This is a basic HTTP encoding and formatting question. I need to log in from a RESTFixture to a PHP web service. I need to pass in the account, username, and password, as POST variables just as a login page does.

Wireshark shows that my login page formats it as accountNumber=accounttest&username=usertest&password=passtest

When I do that in the test, I get a POST array of $_POST: Array ( [accountNumber] => accounttest [amp;username] => usertest [amp;password] => passtest )

That would work but the "amp;" obviously makes it so that PHP doesn't find the username.

Content type is the same for both live and the test. [CONTENT_TYPE] => application/x-www-form-urlencoded

Here are a few other formats I've tried with results. In all three cases, it fails to parse so all fields end up in one array entry.

input: accountNumber=accounttest%amp;username=usertest%amp;password=passtest

Result: $_POST: Array ( [accountNumber] => accounttest%amp;username=usertest%amp;password=passtest )

input: accountNumber=accounttest;username=usertest;password=passtest
Result: $_POST: Array ( [accountNumber] => accounttest;username=usertest;password=passtest )

input: accountNumber=accounttest%26username=usertest%26password=passtest
Result: $_POST: Array ( [accountNumber] => accounttest&username=usertest&password=passtest )

So the last one correctly converts the %26 to &, but doesn't break the items apart into array elements.

© Stack Overflow or respective owner

Related posts about php

Related posts about http