daml/triggers/tests/BUILD.bazel
Gary Verhaegen 878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00

155 lines
5.8 KiB
Python

# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
)
load(
"//bazel_tools/client_server:client_server_test.bzl",
"client_server_test",
)
genrule(
name = "acs",
srcs =
glob(["**/*.daml"]) + [
"//triggers/daml:daml-trigger.dar",
"//docs:source/triggers/template-root/src/CopyTrigger.daml",
"//:VERSION",
],
outs = ["acs.dar"],
cmd = """
set -eou pipefail
TMP_DIR=$$(mktemp -d)
mkdir -p $$TMP_DIR/daml
cp -L $(location :daml/ACS.daml) $$TMP_DIR/daml
cp -L $(location :daml/Retry.daml) $$TMP_DIR/daml
cp -L $(location :daml/ExerciseByKey.daml) $$TMP_DIR/daml
cp -L $(location :daml/Numeric.daml) $$TMP_DIR/daml
cp -L $(location :daml/CommandId.daml) $$TMP_DIR/daml
cp -L $(location :daml/PendingSet.daml) $$TMP_DIR/daml
cp -L $(location :daml/TemplateIdFilter.daml) $$TMP_DIR/daml
cp -L $(location :daml/Time.daml) $$TMP_DIR/daml
cp -L $(location //docs:source/triggers/template-root/src/CopyTrigger.daml) $$TMP_DIR/daml
cp -L $(location //triggers/daml:daml-trigger.dar) $$TMP_DIR/
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: $$(cat $(location //:VERSION))
name: acs
source: daml
version: 0.0.1
dependencies:
- daml-stdlib
- daml-prim
- daml-trigger.dar
EOF
$(location //compiler/damlc) build --project-root=$$TMP_DIR -o $$PWD/$(location acs.dar)
rm -rf $$TMP_DIR
""",
tools = ["//compiler/damlc"],
visibility = ["//visibility:public"],
)
da_scala_binary(
name = "test_client",
srcs = glob(["src/**/*.scala"]),
main_class = "com.digitalasset.daml.lf.engine.trigger.test.TestMain",
resources = ["//triggers/runner:src/main/resources/logback.xml"],
deps = [
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/interpreter",
"//daml-lf/language",
"//daml-lf/transaction",
"//language-support/scala/bindings",
"//language-support/scala/bindings-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger/ledger-api-common",
"//libs-scala/auth-utils",
"//triggers/runner:trigger-runner-lib",
"@maven//:com_github_scopt_scopt_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
"@maven//:org_scalaz_scalaz_core_2_12",
],
)
client_server_test(
name = "test_static_time",
timeout = "long",
client = ":test_client",
client_files = ["$(rootpath :acs.dar)"],
data = [":acs.dar"],
server = "//ledger/sandbox:sandbox-binary",
server_args = ["--port=0"],
server_files = ["$(rootpath :acs.dar)"],
)
client_server_test(
name = "test_wallclock_time",
timeout = "long",
client = ":test_client",
client_args = ["-w"],
client_files = ["$(rootpath :acs.dar)"],
data = [":acs.dar"],
server = "//ledger/sandbox:sandbox-binary",
server_args = [
"-w",
"--port=0",
],
server_files = ["$(rootpath :acs.dar)"],
)
AUTH_TOKEN = "I_CAN_HAZ_AUTH"
# This is a genrule so we can replace it by something nicer that actually generates the token
# from some readable input so we can change it more easily.
# For now, this corresponds to a token that has admin set to false
# and actAs to Alice1, …, Alice100
genrule(
name = "test-auth-token",
outs = ["test-auth-token.jwt"],
cmd = """
cat <<EOF > $(location test-auth-token.jwt)
Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3RBcyI6WyJBbGljZTEiLCJBbGljZTIiLCJBbGljZTMiLCJBbGljZTQiLCJBbGljZTUiLCJBbGljZTYiLCJBbGljZTciLCJBbGljZTgiLCJBbGljZTkiLCJBbGljZTEwIiwiQWxpY2UxMSIsIkFsaWNlMTIiLCJBbGljZTEzIiwiQWxpY2UxNCIsIkFsaWNlMTUi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QWxpY2U5NSIsIkFsaWNlOTYiLCJBbGljZTk3IiwiQWxpY2U5OCIsIkFsaWNlOTkiLCJBbGljZTEwMCJdfQ.p78Bgrx0kX2tPwXoc2p5Uz22HifzfELjnmf7XwmCI4k
EOF
""",
)
client_server_test(
name = "test_static_time_authenticated",
timeout = "long",
client = ":test_client",
client_args = ["--access-token-file"],
client_files = [
"$(rootpath :test-auth-token.jwt)",
"$(rootpath :acs.dar)",
],
data = [
":acs.dar",
":test-auth-token.jwt",
],
server = "//ledger/sandbox:sandbox-binary",
server_args = [
"--port=0",
"--auth-jwt-hs256-unsafe={}".format(AUTH_TOKEN),
],
server_files = ["$(rootpath :acs.dar)"],
)
sh_test(
name = "list-triggers",
srcs = ["list-triggers.sh"],
args = [
"$(location //triggers/runner:trigger-runner)",
"$(location :acs.dar)",
],
data = [
":acs.dar",
"//triggers/runner:trigger-runner",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)