Search in sources :

Example 11 with ZimbraAuthToken

use of com.zimbra.cs.account.ZimbraAuthToken in project zm-mailbox by Zimbra.

the class TestCookieReuse method testTokenExpiredTokenDeregistration.

/**
     * test token being deregistered after it is expired
     * @throws Exception
     */
@Test
public void testTokenExpiredTokenDeregistration() throws Exception {
    Account a = TestUtil.getAccount(USER_NAME);
    ZimbraAuthToken at = new ZimbraAuthToken(a, System.currentTimeMillis() - 1000);
    ZimbraAuthToken at2 = new ZimbraAuthToken(a, System.currentTimeMillis() + 10000);
    Assert.assertFalse("First token should not be registered", at.isRegistered());
    Assert.assertTrue("Second token should be registered", at2.isRegistered());
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraAuthToken(com.zimbra.cs.account.ZimbraAuthToken) Test(org.junit.Test)

Example 12 with ZimbraAuthToken

use of com.zimbra.cs.account.ZimbraAuthToken in project zm-mailbox by Zimbra.

the class TestCookieReuse method testClearCookies.

/**
     * Verify that when zimbraForceClearCookies is set to TRUE authtokens get deregistered
     * @throws Exception
     */
@Test
public void testClearCookies() throws Exception {
    Account a = TestUtil.getAccount(USER_NAME);
    a.setForceClearCookies(true);
    ZimbraAuthToken at = new ZimbraAuthToken(a);
    Assert.assertTrue("token should be registered", at.isRegistered());
    at.deRegister();
    Assert.assertFalse("token should not be registered", at.isRegistered());
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraAuthToken(com.zimbra.cs.account.ZimbraAuthToken) Test(org.junit.Test)

Aggregations

Account (com.zimbra.cs.account.Account)12 ZimbraAuthToken (com.zimbra.cs.account.ZimbraAuthToken)12 Test (org.junit.Test)8 AuthToken (com.zimbra.cs.account.AuthToken)7 ServiceException (com.zimbra.common.service.ServiceException)5 AuthTokenException (com.zimbra.cs.account.AuthTokenException)3 Server (com.zimbra.cs.account.Server)2 AccountBy (com.zimbra.common.account.Key.AccountBy)1 ZAuthToken (com.zimbra.common.auth.ZAuthToken)1 Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)1 Domain (com.zimbra.cs.account.Domain)1 Provisioning (com.zimbra.cs.account.Provisioning)1 EmailAddress (com.zimbra.cs.account.names.NameUtil.EmailAddress)1 AuthRequest (com.zimbra.soap.account.message.AuthRequest)1 AuthResponse (com.zimbra.soap.account.message.AuthResponse)1