Discussion:
PreemptiveAuth in Jersey test framework
Robert Naczinski
2012-01-13 11:38:45 UTC
Permalink
Hello,

I use Jersey test framework for the development and testing. Can I add
my test PreemptiveAuth?

Has someone already done something and help me? A snipet would be great.

I'm using Grizzly Web Container.

Regards,

Robert
Pavel Bucek
2012-01-13 11:56:28 UTC
Permalink
Hi Robert,

Jersey Test Framework currently does not support any auth settings on
container side, but we already needed to test this, see
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/https-clientserver-grizzly/src/test/java/com/sun/jersey/samples/https_grizzly/MainTest.java?rev=5594.

Its not that hard to use and you even could extract core functionality
into some abstract class (if you need this in more than one test).

Regards,
Pavel
Post by Robert Naczinski
Hello,
I use Jersey test framework for the development and testing. Can I add
my test PreemptiveAuth?
Has someone already done something and help me? A snipet would be great.
I'm using Grizzly Web Container.
Regards,
Robert
Robertnac
2012-01-13 16:04:41 UTC
Permalink
Thanks for the quick reply. I thought it would be easier. Simply
override JerseyTest#configure()
http://jersey.java.net/nonav/apidocs/latest/jersey-test-framework/jersey-test-framework-core/com/sun/jersey/test/framework/JerseyTest.html#configure%28%29

Is it not for possible BasicAuth?

Regards,

Robert
Post by Pavel Bucek
Hi Robert,
Jersey Test Framework currently does not support any auth settings on
container side, but we already needed to test this, see
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/https-clientserver-grizzly/src/test/java/com/sun/jersey/samples/https_grizzly/MainTest.java?rev=5594.
Its not that hard to use and you even could extract core functionality into
some abstract class (if you need this in more than one test).
Regards,
Pavel
Post by Robert Naczinski
Hello,
I use Jersey test framework for the development and testing. Can I add
my test  PreemptiveAuth?
Has someone already done something and help me? A snipet would be great.
I'm using Grizzly Web Container.
Regards,
Robert
Pavel Bucek
2012-01-13 16:52:59 UTC
Permalink
no, that is not supported right now.

but it should not be that hard to implement. I have 2 ways how to do it
on my mind right now:

1) create ContainerRequestFilter which would implement basic auth and
wire it into test application (that would be done in mentioned configure
method).
2) implement your own TestContainerFactory, which would do almost the
same as MainTest in https-clientserver-grizzly sample.

or (the best approach for us), you can modify existing
TestContainerFactory / WebAppDescriptor and donate it back;
unfortunately, this would be most likely not trivial task (security
configuration is usually not an easy task to implement)

Regards,
Pavel
Post by Robertnac
Thanks for the quick reply. I thought it would be easier. Simply
override JerseyTest#configure()
http://jersey.java.net/nonav/apidocs/latest/jersey-test-framework/jersey-test-framework-core/com/sun/jersey/test/framework/JerseyTest.html#configure%28%29
Is it not for possible BasicAuth?
Regards,
Robert
Post by Pavel Bucek
Hi Robert,
Jersey Test Framework currently does not support any auth settings on
container side, but we already needed to test this, see
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/https-clientserver-grizzly/src/test/java/com/sun/jersey/samples/https_grizzly/MainTest.java?rev=5594.
Its not that hard to use and you even could extract core functionality into
some abstract class (if you need this in more than one test).
Regards,
Pavel
Post by Robert Naczinski
Hello,
I use Jersey test framework for the development and testing. Can I add
my test PreemptiveAuth?
Has someone already done something and help me? A snipet would be great.
I'm using Grizzly Web Container.
Regards,
Robert
Loading...