Testing the interaction of multiple sites

13 views
Skip to first unread message

Michal Petrucha

unread,
Jan 4, 2016, 5:50:05 PM1/4/16
to django...@googlegroups.com
Hi folks,

I'd like to write some tests for a simple redirect-based SSO solution,
in which there's one instance of an app responsible for
authentication, and all other instances redirect new sessionless users
to it, and then expect a redirect callback. Kind of like a simplified
version of OAuth in which there's no need for the relying party to
make a background request to the identity provider, since the provider
and the relying party share the same database. Each instance has its
own settings, SITE_ID and such.

I was thinking about using Selenium with LiveServerTestCase for this;
however, I'd need to have both the provider and the relying instance
listening at the same time.

Is there a simple mechanism to have LiveServerTestCase run two
separate server threads with different settings? Is there some kind of
third-party testing package that can do that?

Cheers, and have a happy New Year.

Michal
signature.asc

Nikolas Stevenson-Molnar

unread,
Jan 4, 2016, 6:21:37 PM1/4/16
to 'Tom Evans' via Django users
HTTPretty may help with this. It will let you mock a response from the second server: https://github.com/gabrielfalcao/httpretty

_Nik

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20160104224904.GA20308%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Nikolas Stevenson-Molnar

unread,
Jan 4, 2016, 6:22:11 PM1/4/16
to Django users
HTTPretty may help with this. It will let you mock a response from the second server: https://github.com/gabrielfalcao/httpretty

_Nik

Michal Petrucha

unread,
Jan 4, 2016, 6:39:22 PM1/4/16
to django...@googlegroups.com
On Mon, Jan 04, 2016 at 03:22:10PM -0800, Nikolas Stevenson-Molnar wrote:
> HTTPretty may help with this. It will let you mock a response from the
> second server: https://github.com/gabrielfalcao/httpretty
>
> _Nik

Hi Nikolas,

Thanks for your suggestion, unfortunately, I don't see how it helps in
my case.

What I'm after is some kind of integration test: when I try to load a
page form the relying instance, verify that it gets redirected to the
provider, and then it gets redirected back with the correct callback
parameters. In both cases I need to actually hit the respective server
running a Django app, since it involves side effects (and side
conditions), such as whether the user is logged in on the provider,
and some in-database state changes to verify that the callback was
valid.

I don't see how mocking a HTTP response would help me with this, but,
of course, I may be missing something here.

Cheers,

Michal
signature.asc

Nikolas Stevenson-Molnar

unread,
Jan 4, 2016, 7:10:39 PM1/4/16
to Django users
On Monday, January 4, 2016 at 3:39:22 PM UTC-8, Michal Petrucha wrote:
Hi Nikolas,

Thanks for your suggestion, unfortunately, I don't see how it helps in
my case.

What I'm after is some kind of integration test: when I try to load a
page form the relying instance, verify that it gets redirected to the
provider, and then it gets redirected back with the correct callback
parameters. In both cases I need to actually hit the respective server
running a Django app, since it involves side effects (and side
conditions), such as whether the user is logged in on the provider,
and some in-database state changes to verify that the callback was
valid.

I don't see how mocking a HTTP response would help me with this, but,
of course, I may be missing something here.

Cheers,

Michal

Sorry, I just misunderstood the question. I was thinking of unit tests, in which you'd want to remove as many external components as possible. 
Reply all
Reply to author
Forward
0 new messages