/************************************************************************* * * * EJBCA Community: The OpenSource Certificate Authority * * * * This software is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or any later version. * * * * See terms of license at gnu.org. * * * *************************************************************************/ package org.ejbca.ui.cli.ca; import static org.junit.Assert.assertFalse; import org.cesecore.CaTestUtils; import org.cesecore.authentication.tokens.AuthenticationToken; import org.cesecore.authorization.AuthorizationDeniedException; import org.cesecore.certificates.ca.CADoesntExistsException; import org.cesecore.certificates.ca.CaSessionRemote; import org.cesecore.certificates.ca.X509CA; import org.cesecore.certificates.crl.CRLInfo; import org.cesecore.certificates.crl.CrlStoreSessionRemote; import org.cesecore.mock.authentication.tokens.TestAlwaysAllowLocalAuthenticationToken; import org.cesecore.util.CryptoProviderTools; import org.cesecore.util.EjbRemoteHelper; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; /** * @version $Id: CaCreateCrlCommandTest.java 19902 2014-09-30 14:32:24Z anatom $ * */ public class CaCreateCrlCommandTest { private static final String CA_NAME = "CaCreateCrlCommandTest"; private static final String CA_DN = "CN=" + CA_NAME; private final CaCreateCrlCommand command = new CaCreateCrlCommand(); private final CaSessionRemote caSession = EjbRemoteHelper.INSTANCE.getRemoteSession(CaSessionRemote.class); private final CrlStoreSessionRemote crlStoreSession = EjbRemoteHelper.INSTANCE.getRemoteSession(CrlStoreSessionRemote.class); private X509CA ca; private final AuthenticationToken authenticationToken = new TestAlwaysAllowLocalAuthenticationToken( CaChangeCertProfileCommand.class.getSimpleName()); @BeforeClass public static void beforeClass() throws Exception { CryptoProviderTools.installBCProviderIfNotAvailable(); } @Before public void setup() throws Exception { ca = CaTestUtils.createTestX509CA(CA_DN, null, false); caSession.addCA(authenticationToken, ca); } @After public void tearDown() throws Exception { if (ca != null) { caSession.removeCA(authenticationToken, ca.getCAId()); } } @Test public void testCommand() throws CADoesntExistsException, AuthorizationDeniedException { CRLInfo oldCrl = crlStoreSession.getLastCRLInfo(CA_DN, false); String[] args = new String[] { CA_NAME }; command.execute(args); assertFalse("No CRL was produced", crlStoreSession.getLastCRLInfo(CA_DN, false).equals(oldCrl)); } }