Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to test a local BouncyCastle jar #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ common_deps = [

test_srcs = glob(["java/com/google/security/wycheproof/testcases/*.java"]) + ["java/com/google/security/wycheproof/WycheproofRunner.java"]

# We cannot supply $(BOUNCYCASTLE_JAR) directly to the 'jars'
# attribute of java_import, but we can generate a symlink.
# TODO(wycheproof-team): is there an easier way to supply
# deps from the command line?
java_import(
name = "bouncycastle_jar",
jars = ["bouncycastle.jar"],
)

genrule(
name = "bouncycastle_symlink",
outs = ["bouncycastle.jar"],
cmd = "ln -sf $(BOUNCYCASTLE_JAR) $@",
)

# These targets run all tests.

load(":build_defs.bzl", "bouncycastle_all_tests", "spongycastle_all_tests")
Expand All @@ -29,7 +44,11 @@ load(":build_defs.bzl", "bouncycastle_all_tests", "spongycastle_all_tests")
# $ bazel test BouncyCastleAllTests_1_52
#
# To test all known versions (warning, will take a long time):
# $ bazel test BouncyCastleAllTest_*
# $ bazel test BouncyCastleAllTests_*
#
# To test against a local jar:
# $ bazel test BouncyCastleAllTestsLocal \
# --define BOUNCYCASTLE_JAR=/path/to/bouncycastle
bouncycastle_all_tests(
# This test takes a long time, because key generation for DSA and DH generate new parameters.
size = "large",
Expand All @@ -38,6 +57,14 @@ bouncycastle_all_tests(
deps = common_deps,
)

java_test(
name = "BouncyCastleAllTestsLocal",
size = "large",
srcs = ["java/com/google/security/wycheproof/BouncyCastleAllTests.java"] + test_srcs,
test_class = "com.google.security.wycheproof.BouncyCastleAllTests",
deps = common_deps + [":bouncycastle_jar"],
)

# Generates SpongyCastleAllTests_1_xx target for all available versions,
# plus a SpongyCastleAllTests alias for latest stable.
#
Expand Down Expand Up @@ -79,6 +106,14 @@ bouncycastle_tests(
deps = common_deps,
)

java_test(
name = "BouncyCastleTestLocal",
size = "large",
srcs = ["java/com/google/security/wycheproof/BouncyCastleTest.java"] + test_srcs,
test_class = "com.google.security.wycheproof.BouncyCastleTest",
deps = common_deps + [":bouncycastle_jar"],
)

# Generates SpongyCastleTest_1_xx target for all available versions,
# plus a SpongyCastleTest alias for latest stable.
#
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ bazel test BouncyCastleAllTests_1_52
bazel test BouncyCastleAllTests_*
```

- To test a local jar

``` shell
bazel test BouncyCastleAllTestsLocal --define BOUNCYCASTLE_JAR=/path/to/bouncycastle
```

- To test [Spongy Castle](https://rtyley.github.io/spongycastle/), replace
BouncyCastle with SpongyCastle in your commands, for example

Expand Down