This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git
commit b8105d9268d0ceb52cbbbcc1f2cb07b7226b4dbf Author: Gary Gregory <[email protected]> AuthorDate: Mon Dec 12 07:30:00 2022 -0500 Add missing tests --- .../commons/crypto/cipher/CryptoCipherTest.java | 41 +++++++++++ .../commons/crypto/cipher/DefaultCryptoCipher.java | 86 ++++++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java new file mode 100644 index 0000000..20b641b --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.crypto.cipher; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.nio.ByteBuffer; + +import org.junit.jupiter.api.Test; + +/** + * Tests default methods. + */ +public class CryptoCipherTest { + + @Test + public void testUpdateAADByteArray() { + assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((byte[]) null)); + } + + @Test + public void testUpdateAADByteBuffer() { + assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((ByteBuffer) null)); + } +} diff --git a/src/test/java/org/apache/commons/crypto/cipher/DefaultCryptoCipher.java b/src/test/java/org/apache/commons/crypto/cipher/DefaultCryptoCipher.java new file mode 100644 index 0000000..4e0f3cd --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/cipher/DefaultCryptoCipher.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.crypto.cipher; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.spec.AlgorithmParameterSpec; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.ShortBufferException; + +/** + * Tests default methods. + */ +public class DefaultCryptoCipher implements CryptoCipher { + + @Override + public void close() throws IOException { + // Simplest + + } + + @Override + public int getBlockSize() { + // Simplest + return 0; + } + + @Override + public String getAlgorithm() { + // Simplest + return null; + } + + @Override + public void init(int mode, Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException { + // Simplest + + } + + @Override + public int update(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException { + // Simplest + return 0; + } + + @Override + public int update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { + // Simplest + return 0; + } + + @Override + public int doFinal(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { + // Simplest + return 0; + } + + @Override + public int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) + throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { + // Simplest + return 0; + } + +}
