Search in sources :

Example 16 with ZimbraAuthToken

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

the class TestCookieReuse method testOldClientSupport.

/**
 * Test old behavior: tokens appear to be registered even when they are not registered when lowest
 * supported auth version is set to 1
 * @throws Exception
 */
@Test
public void testOldClientSupport() throws Exception {
    Account a = TestUtil.getAccount(USER_NAME);
    ZimbraAuthToken at = new ZimbraAuthToken(a, System.currentTimeMillis() - 1000);
    Assert.assertTrue("token should be registered", at.isRegistered());
    at.deRegister();
    Assert.assertFalse("token should not be registered", at.isRegistered());
    // lowering supported auth version should allow unregistered cookies
    Provisioning.getInstance().getLocalServer().setLowestSupportedAuthVersion(1);
    Assert.assertTrue("token should appear to be registered", at.isRegistered());
    // raising supported auth version should not allow unregistered cookies
    Provisioning.getInstance().getLocalServer().setLowestSupportedAuthVersion(2);
    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

ZimbraAuthToken (com.zimbra.cs.account.ZimbraAuthToken)16 Account (com.zimbra.cs.account.Account)14 Test (org.junit.Test)9 ServiceException (com.zimbra.common.service.ServiceException)8 AuthToken (com.zimbra.cs.account.AuthToken)8 AuthTokenException (com.zimbra.cs.account.AuthTokenException)5 Server (com.zimbra.cs.account.Server)3 ZMailbox (com.zimbra.client.ZMailbox)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)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