mirror of
https://codeberg.org/PGPainless/wkd-java.git
synced 2024-11-22 07:12:05 +01:00
Add CLI tests fetching test keys from github pages
See https://github.com/pgpainless/pgpainless.github.io
This commit is contained in:
parent
5613d42baf
commit
851c14c685
2 changed files with 68 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package pgp.wkd.cli.online_test_vectors;
|
||||||
|
|
||||||
|
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import pgp.wkd.cli.WKDCLI;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class GithubPagesTestVectors extends RedirectSystemStreamsTest {
|
||||||
|
|
||||||
|
// Valid WKD publication.
|
||||||
|
// Cert is available at https://pgpainless.github.io/.well-known/openpgpkey/hu/eprjcbeppbna3f6xabhtpddzpn41nknw
|
||||||
|
private static final String USERID_BASE = "WKD Test <wkd-test-base@pgpainless.github.io> [Base Case - Valid User-ID]";
|
||||||
|
private static final String MAIL_BASE = "wkd-test-base@pgpainless.github.io";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchBaseKeyByMailAddress_Successful() {
|
||||||
|
WKDCLI.main(new String[] {"fetch", MAIL_BASE});
|
||||||
|
assertEquals(718, outContent.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchBaseKeyByUserID_Successful() {
|
||||||
|
WKDCLI.main(new String[] {"fetch", USERID_BASE});
|
||||||
|
assertEquals(718, outContent.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ExpectSystemExitWithStatus(1)
|
||||||
|
public void testFetchNonExistentKeyFails() {
|
||||||
|
WKDCLI.main(new String[] {"fetch", "wkd-test-nonexistent@pgpainless.github,io"});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package pgp.wkd.cli.online_test_vectors;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
public abstract class RedirectSystemStreamsTest {
|
||||||
|
|
||||||
|
protected final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
|
protected final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
|
||||||
|
private final PrintStream originalOut = System.out;
|
||||||
|
private final PrintStream originalErr = System.err;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public final void setUpStreams() {
|
||||||
|
System.setOut(new PrintStream(outContent));
|
||||||
|
System.setErr(new PrintStream(errContent));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void restoreStreams() {
|
||||||
|
System.setOut(originalOut);
|
||||||
|
System.setErr(originalErr);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue