svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

multi domain, about login #187

Closed alswl closed 8 years ago

alswl commented 8 years ago

I'm using pyresttest in QA unit now.

And I occurred a question, this is my test case:

Now I can only pass one argument to command, so I cannot do the test case.

Thank you.

svanoort commented 8 years ago

Hi @alswl, I am not sure what you are asking here?

You can extract multiple values from the login request (multiple extractor declarations, using the set-cookie headers) and use them as variables in future requests. You can use multiple variables in templates for the POST requests. You can also (fun part) supply a 'vars' argument at the command line, which is parsed as a YAML dictionary of variables to use in the test.

Kind regards, Sam

alswl commented 8 years ago

Hi, thanks for your reply.

My question is, I must login in A domain, and test HTTP API in B domain.

I cannot extract A domain's cookie to B domain, because this command pyresttest SOME_DOMAIN SOME_TEST.py only takes one domain.

svanoort commented 8 years ago

The first argument is just a URL prefix, it should work with something like 'http://' as the basis, and then each test just defines the rest of the URL.

Or you can use the '--absolute-urls' command line argument - this will disregard any URL prefix you supply at the command line, and just use the URL or fragment defined in the tests themselves.

svanoort commented 8 years ago

@alswl ^ answered above, that should solve your challenge.

alswl commented 8 years ago

Thanks, --absolute-urls + --vars should solve my problem.