tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndegraev <nick.degra...@telenet.be>
Subject Re: JUnit: Sessioncontext.isCallerInRole allways returns false
Date Tue, 08 Feb 2011 12:43:34 GMT

It never occured to me it might be a bug. I thought I was just missing
something. :-) 

Thanks for the new project.

Just to let you know that all roles I want to test must be mentioned in the
@RolesAllowed.
The test method below only succeeds if @RolesAllowed({ "admins", "users" })
is set on the EJB.

    @Test
    public void test1() throws NamingException {
        ISayHelloServiceLocal ibean;

        ibean = TestUtils.interfaceLookup(TestUtils.getCtx("user",
"user_pass"), ISayHelloServiceLocal.class);
        Assert.assertEquals("user", ibean.getUserName());
        Assert.assertFalse(ibean.isCallerAdmin());
        Assert.assertFalse(ibean.hasRole("admins"));
        Assert.assertTrue(ibean.hasRole("users"));

        ibean = TestUtils.interfaceLookup(TestUtils.getCtx("admin",
"admin_pass"), ISayHelloServiceLocal.class);
        Assert.assertEquals("admin", ibean.getUserName());
        Assert.assertTrue(ibean.isCallerAdmin());
        Assert.assertTrue(ibean.hasRole("admins"));
        Assert.assertFalse(ibean.hasRole("users"));
    }


-- 
View this message in context: http://openejb.979440.n4.nabble.com/JUnit-Sessioncontext-isCallerInRole-allways-returns-false-tp3257408p3275888.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message