summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-04-27 00:58:28 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2020-06-01 01:26:22 +0200
commit77848d635b76d8294697ffaf11acf51256df2a5b (patch)
tree9a91a25512d2dff89bb9cc0b336279eef2df18e5 /org.eclipse.jgit.test
parent0b2d41b8584e16d6f7abeca92eaae326033b4489 (diff)
downloadjgit-77848d635b76d8294697ffaf11acf51256df2a5b.tar.gz
jgit-77848d635b76d8294697ffaf11acf51256df2a5b.zip
Decouple BouncyCastle from JGit Core
Motivation: BouncyCastle serves as 'default' implementation of the GPG Signer. If a client application does not use it there is no need to pull in this dependency, especially since BouncyCastle is a large library. Move the classes depending on BouncyCastle to an OSGi fragment extending the org.eclipse.jgit bundle. They are moved to a distinct internal package in order to avoid split packages. This doesn't break public API since these classes were already in an internal package before this change. Add a new feature org.eclipse.jgit.gpg.bc to enable installation. With that users can now decide if they want to install it. Attempts to sign a commit if org.eclipse.jgit.gpg.bc isn't available will result in ServiceUnavailableException being thrown. Bug: 559106 Change-Id: I42fd6c00002e17aa9a7be96ae434b538ea86ccf8 Also-by: Michael Dardis <git@md-5.net> Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/BUILD1
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java134
2 files changed, 1 insertions, 134 deletions
diff --git a/org.eclipse.jgit.test/BUILD b/org.eclipse.jgit.test/BUILD
index b04ac553d1..cd6195e287 100644
--- a/org.eclipse.jgit.test/BUILD
+++ b/org.eclipse.jgit.test/BUILD
@@ -74,6 +74,7 @@ java_library(
resource_strip_prefix = "org.eclipse.jgit.test/resources",
resources = RESOURCES,
visibility = [
+ "//org.eclipse.jgit.gpg.bc.test:__pkg__",
"//org.eclipse.jgit.ssh.apache.test:__pkg__",
],
deps = [
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java
deleted file mode 100644
index e93091d67d..0000000000
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2019, Thomas Wolf <thomas.wolf@paranor.ch> and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0 which is available at
- * https://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-package org.eclipse.jgit.lib.internal;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Locale;
-
-import org.junit.Test;
-
-public class BouncyCastleGpgKeyLocatorTest {
-
- private static final String USER_ID = "Heinrich Heine <heinrichh@uni-duesseldorf.de>";
-
- private static boolean match(String userId, String pattern) {
- return BouncyCastleGpgKeyLocator.containsSigningKey(userId, pattern);
- }
-
- @Test
- public void testFullMatch() throws Exception {
- assertTrue(match(USER_ID,
- "=Heinrich Heine <heinrichh@uni-duesseldorf.de>"));
- assertFalse(match(USER_ID, "=Heinrich Heine"));
- assertFalse(match(USER_ID, "= "));
- assertFalse(match(USER_ID, "=heinrichh@uni-duesseldorf.de"));
- }
-
- @Test
- public void testEmpty() throws Exception {
- assertFalse(match(USER_ID, ""));
- assertFalse(match(USER_ID, null));
- assertFalse(match("", ""));
- assertFalse(match(null, ""));
- assertFalse(match(null, null));
- assertFalse(match("", "something"));
- assertFalse(match(null, "something"));
- }
-
- @Test
- public void testFullEmail() throws Exception {
- assertTrue(match(USER_ID, "<heinrichh@uni-duesseldorf.de>"));
- assertTrue(match(USER_ID + " ", "<heinrichh@uni-duesseldorf.de>"));
- assertFalse(match(USER_ID, "<>"));
- assertFalse(match(USER_ID, "<h>"));
- assertFalse(match(USER_ID, "<heinrichh>"));
- assertFalse(match(USER_ID, "<uni-duesseldorf>"));
- assertFalse(match(USER_ID, "<h@u>"));
- assertFalse(match(USER_ID, "<HeinrichH@uni-duesseldorf.de>"));
- assertFalse(match(USER_ID.substring(0, USER_ID.length() - 1),
- "<heinrichh@uni-duesseldorf.de>"));
- assertFalse(match("", "<>"));
- assertFalse(match("", "<heinrichh@uni-duesseldorf.de>"));
- }
-
- @Test
- public void testPartialEmail() throws Exception {
- assertTrue(match(USER_ID, "@heinrichh@uni-duesseldorf.de"));
- assertTrue(match(USER_ID, "@heinrichh"));
- assertTrue(match(USER_ID, "@duesseldorf"));
- assertTrue(match(USER_ID, "@uni-d"));
- assertTrue(match(USER_ID, "@h"));
- assertTrue(match(USER_ID, "@."));
- assertTrue(match(USER_ID, "@h@u"));
- assertFalse(match(USER_ID, "@ "));
- assertFalse(match(USER_ID, "@"));
- assertFalse(match(USER_ID, "@Heine"));
- assertFalse(match(USER_ID, "@HeinrichH"));
- assertFalse(match(USER_ID, "@Heinrich"));
- assertFalse(match("", "@"));
- assertFalse(match("", "@h"));
- }
-
- private void substringTests(String prefix) throws Exception {
- assertTrue(match(USER_ID, prefix + "heinrichh@uni-duesseldorf.de"));
- assertTrue(match(USER_ID, prefix + "heinrich"));
- assertTrue(match(USER_ID, prefix + "HEIN"));
- assertTrue(match(USER_ID, prefix + "Heine <"));
- assertTrue(match(USER_ID, prefix + "UNI"));
- assertTrue(match(USER_ID, prefix + "uni"));
- assertTrue(match(USER_ID, prefix + "rich He"));
- assertTrue(match(USER_ID, prefix + "h@u"));
- assertTrue(match(USER_ID, prefix + USER_ID));
- assertTrue(match(USER_ID, prefix + USER_ID.toUpperCase(Locale.ROOT)));
- assertFalse(match(USER_ID, prefix + ""));
- assertFalse(match(USER_ID, prefix + " "));
- assertFalse(match(USER_ID, prefix + "yy"));
- assertFalse(match("", prefix + ""));
- assertFalse(match("", prefix + "uni"));
- }
-
- @Test
- public void testSubstringPlain() throws Exception {
- substringTests("");
- }
-
- @Test
- public void testSubstringAsterisk() throws Exception {
- substringTests("*");
- }
-
- @Test
- public void testExplicitFingerprint() throws Exception {
- assertFalse(match("John Fade <j.fade@example.com>", "0xfade"));
- assertFalse(match("John Fade <0xfade@example.com>", "0xfade"));
- assertFalse(match("", "0xfade"));
- }
-
- @Test
- public void testImplicitFingerprint() throws Exception {
- assertTrue(match("John Fade <j.fade@example.com>", "fade"));
- assertTrue(match("John Fade <0xfade@example.com>", "fade"));
- assertTrue(match("John Fade <j.fade@example.com>", "FADE"));
- assertTrue(match("John Fade <0xfade@example.com>", "FADE"));
- }
-
- @Test
- public void testZeroX() throws Exception {
- assertTrue(match("John Fade <0xfade@example.com>", "0x"));
- assertTrue(match("John Fade <0xfade@example.com>", "*0x"));
- assertTrue(match("John Fade <0xfade@example.com>", "*0xfade"));
- assertTrue(match("John Fade <0xfade@example.com>", "*0xFADE"));
- assertTrue(match("John Fade <0xfade@example.com>", "@0xfade"));
- assertFalse(match("John Fade <0xfade@example.com>", "@0xFADE"));
- assertFalse(match("", "0x"));
- }
-}