mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Compare commits
39 commits
2d9a5646bb
...
7c4b4a4ddb
Author | SHA1 | Date | |
---|---|---|---|
7c4b4a4ddb | |||
fd789c8652 | |||
a71f4162a2 | |||
563542b88a | |||
9a20b48f02 | |||
c17a922594 | |||
560da4fb8d | |||
655f9ac134 | |||
4b00369194 | |||
3ccd83f795 | |||
61f2b93a5b | |||
9fe49319f8 | |||
cedded2e79 | |||
c09d548bea | |||
e306cf7345 | |||
96593354e0 | |||
b0ff1856a7 | |||
c8626e77ed | |||
91131f114d | |||
0d8f6d7f10 | |||
d490ada270 | |||
1254a867a7 | |||
3d2adab35d | |||
8e3f7ecd4d | |||
f4fe1cdac9 | |||
fe431070a4 | |||
48689ca406 | |||
158cf28412 | |||
62d9cd1991 | |||
a98afb1755 | |||
bd692c7309 | |||
aa8c2be25a | |||
cbeec9c90d | |||
701f9453ca | |||
2d99aea4ab | |||
4d2876a296 | |||
e3fe9410d7 | |||
a2a3bda2b3 | |||
cddc92bd92 |
7 changed files with 150 additions and 35 deletions
|
@ -6,9 +6,12 @@ SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 10.1.1-SNAPSHOT
|
## 10.1.1
|
||||||
- Prepare jar files for use in native images, e.g. using GraalVM by generating and including
|
- Prepare jar files for use in native images, e.g. using GraalVM by generating and including
|
||||||
configuration files for reflection, resources and dynamic proxies.
|
configuration files for reflection, resources and dynamic proxies.
|
||||||
|
- gradle: Make use of jvmToolchain functionality
|
||||||
|
- gradle: Improve reproducibility
|
||||||
|
- gradle: Bump animalsniffer to `2.0.0`
|
||||||
|
|
||||||
## 10.1.0
|
## 10.1.0
|
||||||
- `sop-java`:
|
- `sop-java`:
|
||||||
|
|
|
@ -18,7 +18,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'ru.vyarus.animalsniffer' version '1.5.3'
|
id 'ru.vyarus.animalsniffer' version '2.0.0'
|
||||||
id 'org.jetbrains.kotlin.jvm' version "1.9.21"
|
id 'org.jetbrains.kotlin.jvm' version "1.9.21"
|
||||||
id 'com.diffplug.spotless' version '6.22.0' apply false
|
id 'com.diffplug.spotless' version '6.22.0' apply false
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2025 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.testsuite;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Inherited
|
||||||
|
public @interface AbortOnUnsupportedOption {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
// SPDX-FileCopyrightText: 2025 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.testsuite;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||||
|
import sop.exception.SOPGPException;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
|
||||||
|
public class AbortOnUnsupportedOptionExtension implements TestExecutionExceptionHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTestExecutionException(ExtensionContext extensionContext, Throwable throwable) throws Throwable {
|
||||||
|
Class<?> testClass = extensionContext.getRequiredTestClass();
|
||||||
|
Annotation annotation = testClass.getAnnotation(AbortOnUnsupportedOption.class);
|
||||||
|
if (annotation != null && throwable instanceof SOPGPException.UnsupportedOption) {
|
||||||
|
assumeTrue(false, "Test aborted due to: " + throwable.getMessage());
|
||||||
|
}
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
// SPDX-FileCopyrightText: 2025 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.testsuite.operation;
|
||||||
|
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import sop.SOP;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
|
||||||
|
public class MergeCertsTest extends AbstractSOPTest {
|
||||||
|
|
||||||
|
static Stream<Arguments> provideInstances() {
|
||||||
|
return provideBackends();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("provideInstances")
|
||||||
|
public void testMergeWithItself(SOP sop) throws IOException {
|
||||||
|
byte[] key = sop.generateKey()
|
||||||
|
.noArmor()
|
||||||
|
.userId("Alice <alice@pgpainless.org>")
|
||||||
|
.generate()
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] cert = sop.extractCert()
|
||||||
|
.noArmor()
|
||||||
|
.key(key)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] merged = sop.mergeCerts()
|
||||||
|
.noArmor()
|
||||||
|
.updates(cert)
|
||||||
|
.baseCertificates(cert)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
assertArrayEquals(cert, merged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("provideInstances")
|
||||||
|
public void testApplyBaseToUpdate(SOP sop) throws IOException {
|
||||||
|
byte[] key = sop.generateKey()
|
||||||
|
.noArmor()
|
||||||
|
.userId("Alice <alice@pgpainless.org>")
|
||||||
|
.generate()
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] cert = sop.extractCert()
|
||||||
|
.noArmor()
|
||||||
|
.key(key)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] update = sop.revokeKey()
|
||||||
|
.noArmor()
|
||||||
|
.keys(key)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] merged = sop.mergeCerts()
|
||||||
|
.noArmor()
|
||||||
|
.updates(cert)
|
||||||
|
.baseCertificates(update)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
assertArrayEquals(update, merged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("provideInstances")
|
||||||
|
public void testApplyUpdateToBase(SOP sop) throws IOException {
|
||||||
|
byte[] key = sop.generateKey()
|
||||||
|
.noArmor()
|
||||||
|
.userId("Alice <alice@pgpainless.org>")
|
||||||
|
.generate()
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] cert = sop.extractCert()
|
||||||
|
.noArmor()
|
||||||
|
.key(key)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] update = sop.revokeKey()
|
||||||
|
.noArmor()
|
||||||
|
.keys(key)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
byte[] merged = sop.mergeCerts()
|
||||||
|
.noArmor()
|
||||||
|
.updates(update)
|
||||||
|
.baseCertificates(cert)
|
||||||
|
.getBytes();
|
||||||
|
|
||||||
|
assertArrayEquals(update, merged);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package sop.testsuite
|
|
||||||
|
|
||||||
import java.lang.annotation.Inherited
|
|
||||||
|
|
||||||
@Target(AnnotationTarget.TYPE)
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
@Inherited
|
|
||||||
annotation class AbortOnUnsupportedOption
|
|
|
@ -1,21 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package sop.testsuite
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assumptions
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext
|
|
||||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler
|
|
||||||
import sop.exception.SOPGPException
|
|
||||||
|
|
||||||
class AbortOnUnsupportedOptionExtension : TestExecutionExceptionHandler {
|
|
||||||
override fun handleTestExecutionException(context: ExtensionContext, throwable: Throwable) {
|
|
||||||
val testClass = context.requiredTestClass
|
|
||||||
val annotation = testClass.getAnnotation(AbortOnUnsupportedOption::class.java)
|
|
||||||
if (annotation != null && SOPGPException.UnsupportedOption::class.isInstance(throwable)) {
|
|
||||||
Assumptions.assumeTrue(false, "Test aborted due to: " + throwable.message)
|
|
||||||
}
|
|
||||||
throw throwable
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue