1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.cipher.internal.symmetric.factory

File BcCast5CbcPaddedCipherFactoryTest.java

 

Code metrics

0
8
3
1
56
31
3
0.38
2.67
3
1

Classes

Class Line # Actions
BcCast5CbcPaddedCipherFactoryTest 29 8 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto.cipher.internal.symmetric.factory;
21   
22    import org.junit.Before;
23    import org.junit.Rule;
24    import org.xwiki.crypto.cipher.Cipher;
25    import org.xwiki.crypto.cipher.CipherFactory;
26    import org.xwiki.crypto.params.cipher.symmetric.KeyWithIVParameters;
27    import org.xwiki.test.mockito.MockitoComponentMockingRule;
28   
 
29    public class BcCast5CbcPaddedCipherFactoryTest extends AbstractSymmetricCipherFactoryTest
30    {
31    @Rule
32    public final MockitoComponentMockingRule<CipherFactory> mocker =
33    new MockitoComponentMockingRule<CipherFactory>(BcCast5CbcPaddedCipherFactory.class);
34   
 
35  12 toggle {
36  12 CIPHER_ALGO = "CAST5/CBC/PKCS5Padding";
37  12 BLOCK_SIZE = 8;
38  12 KEY_SIZE = 16;
39  12 SUPPORTED_KEY_SIZE = new int[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
40   
41  12 BYTES_ENCRYPTED_SIZE = ((BYTES.length / BLOCK_SIZE) * BLOCK_SIZE) + BLOCK_SIZE;
42  12 ANOTHER_BYTES_ENCRYPTED_SIZE = ((ANOTHER_BYTES.length / BLOCK_SIZE) * BLOCK_SIZE) + BLOCK_SIZE;
43    }
44   
 
45  12 toggle @Before
46    public void configure() throws Exception
47    {
48  12 factory = mocker.getComponentUnderTest();
49    }
50   
 
51  2 toggle @Override
52    Cipher getCipherInstance(boolean forEncryption)
53    {
54  2 return factory.getInstance(forEncryption, new KeyWithIVParameters(KEY16, IV8));
55    }
56    }