package dev.jeka.core.api.crypto.gpg.embedded.bc;

import dev.jeka.core.api.crypto.gpg.JkGpgTest;
import dev.jeka.core.api.file.JkPathFile;
import dev.jeka.core.api.utils.JkUtilsIO;
import dev.jeka.core.tool.JkConstants;
import org.junit.Test;

import java.io.InputStream;
import java.nio.file.Paths;

@SuppressWarnings("javadoc")
public class BcGpgDoerTest {

    @Test
    public void testSignAndVerify() throws Exception {
        final JkPathFile path = JkPathFile.of(Paths.get(JkConstants.OUTPUT_PATH +
                "/test-out/signature.asm")).createIfNotExist();
        BcGpgDoer.sign(sample(), JkGpgTest.class.getResourceAsStream("secring.gpg"), "",
                JkUtilsIO.outputStream(path.get().toFile(), false), "jerkar".toCharArray(), true);

        final boolean result = BcGpgDoer.verify(sample(), JkUtilsIO.inputStream(path.get().toFile()),
                JkGpgTest.class.getResourceAsStream("pubring.gpg"));
        System.out.println(result);

    }

    private static InputStream sample() {
        return JkGpgTest.class.getResourceAsStream("sampleFileToSign.txt");
    }

}

@@ -120,104 +120,23 @@
 api.
-file.JkPathFile;%0Aimport dev.jeka.core.api.utils.JkUtilsIO;%0Aimport dev.jeka.core.tool.JkConstants
+utils.JkUtilsIO
 ;%0Aim
@@ -185,16 +185,44 @@
 Stream;%0A
+import java.nio.file.Files;%0A
 import j
@@ -238,17 +238,16 @@
 ile.Path
-s
 ;%0A%0A@Supp
@@ -377,178 +377,95 @@
     
-final JkPathFile path = JkPathFile.of(Paths.get(JkConstants.OUTPUT_PATH +%0A                %22/test-out/signature.asm%22)).createIfNotExist();%0A        BcGpgDoer.sign(sample(),
+Path asmSignature = Files.createTempFile(%22jeka%22, %22.asm%22);%0A        InputStream secring =
  JkG
@@ -511,16 +511,58 @@
 ng.gpg%22)
+;%0A        BcGpgDoer.sign(sample(), secring
 , %22%22,%0A  
@@ -594,34 +594,36 @@
 utputStream(
-path.get()
+asmSignature
 .toFile(), f
@@ -660,17 +660,16 @@
  true);%0A
-%0A
         
@@ -744,18 +744,20 @@
 eam(
-path.get()
+asmSignature
 .toF

clean test