From 4dd7fe03d6f2db3879de8f7ef0425261906302d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicklas=20K=C3=B6rtge?= Date: Wed, 11 Sep 2024 14:03:25 +0200 Subject: [PATCH] add test case for issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicklas Körtge --- .../com/ibm/mapper/model/algorithms/RSA.java | 6 +-- .../mapper/mapper/issues/Issue127Test.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java diff --git a/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java b/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java index 89cebb25..1c7536c2 100644 --- a/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java +++ b/mapper/src/main/java/com/ibm/mapper/model/algorithms/RSA.java @@ -57,14 +57,12 @@ public final class RSA extends Algorithm implements KeyAgreement, Signature, Pub } public RSA(@NotNull DetectionLocation detectionLocation) { - super(NAME, PublicKeyEncryption.class, detectionLocation); - this.put(new Oid(OID, detectionLocation)); + this(PublicKeyEncryption.class, detectionLocation); } public RSA(int keyLength, @Nonnull DetectionLocation detectionLocation) { - super(NAME, PublicKeyEncryption.class, detectionLocation); + this(detectionLocation); this.put(new KeyLength(keyLength, detectionLocation)); - this.put(new Oid(OID, detectionLocation)); } public RSA( diff --git a/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java b/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java new file mode 100644 index 00000000..c267f259 --- /dev/null +++ b/mapper/src/test/java/com/ibm/mapper/mapper/issues/Issue127Test.java @@ -0,0 +1,39 @@ +/* + * SonarQube Cryptography Plugin + * Copyright (C) 2024 IBM + * + * 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 com.ibm.mapper.mapper.issues; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.ibm.mapper.model.INode; +import com.ibm.mapper.model.algorithms.RSA; +import com.ibm.mapper.utils.DetectionLocation; +import java.util.List; +import org.junit.Test; + +public class Issue127Test { + + @Test + public void test() { + final RSA rsa = + new RSA(2048, new DetectionLocation("test.java", 1, 1, List.of(), () -> "Test")); + final INode rsaCopy = rsa.deepCopy(); + assertThat(rsaCopy).isInstanceOf(RSA.class); + } +}