aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/cross_language
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/cross_language')
-rw-r--r--tools/testing/cross_language/BUILD.bazel10
-rwxr-xr-xtools/testing/cross_language/test_util.sh143
2 files changed, 0 insertions, 153 deletions
diff --git a/tools/testing/cross_language/BUILD.bazel b/tools/testing/cross_language/BUILD.bazel
deleted file mode 100644
index 6ad5f6f70..000000000
--- a/tools/testing/cross_language/BUILD.bazel
+++ /dev/null
@@ -1,10 +0,0 @@
-package(default_visibility = ["//:__subpackages__"])
-
-licenses(["notice"])
-
-filegroup(
- name = "test_lib",
- srcs = [
- "test_util.sh",
- ],
-)
diff --git a/tools/testing/cross_language/test_util.sh b/tools/testing/cross_language/test_util.sh
deleted file mode 100755
index e466760c4..000000000
--- a/tools/testing/cross_language/test_util.sh
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/bash
-# Copyright 2018 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-################################################################################
-
-
-REPO_DIR="${TEST_SRCDIR}"
-TOOLS_DIR="${REPO_DIR}/tools"
-TINKEY_CLI="${TOOLS_DIR}/tinkey/tinkey"
-#############################################################################
-##### Helper functions.
-
-# Generates private and public keys according to $key_template,
-# which should be supported by Tinkey.
-# If $output_prefix is specified, the generated keyset will use it
-# instead of default value "TINK".
-# Stores the keys in files $priv_key_file and $pub_key_file, respectively.
-generate_asymmetric_keys() {
- local key_name="$1"
- local key_template="$2"
- local output_prefix="$3"
- if [ "$output_prefix" == "" ]; then
- output_prefix="TINK"
- fi
-
- local json_priv_key_file="$TEST_TMPDIR/${key_name}_private_key.json"
- priv_key_file="$TEST_TMPDIR/${key_name}_private_key.bin"
- pub_key_file="$TEST_TMPDIR/${key_name}_public_key.bin"
- echo "--- Using template $key_template to generate keysets"\
- "to files $priv_key_file and $pub_key_file ..."
-
- $TINKEY_CLI create-keyset --key-template $key_template --out-format JSON\
- | sed -e "s/\"TINK\"/\"$output_prefix\"/" > $json_priv_key_file || exit 1
- $TINKEY_CLI convert-keyset --in-format JSON --in $json_priv_key_file\
- --out-format BINARY --out $priv_key_file || exit 1
- $TINKEY_CLI create-public-keyset --in-format BINARY --in $priv_key_file\
- --out-format BINARY --out $pub_key_file || exit 1
- echo "Done generating keysets."
-}
-
-# Generates a symmetric key according to $key_template,
-# which should be supported by Tinkey.
-# Stores the key in file $symmetric_key_file.
-generate_symmetric_key() {
- local key_name="$1"
- local key_template="$2"
- local output_format="$3"
- if [ "$output_format" == "" ]; then
- output_format="BINARY"
- fi
-
- symmetric_key_file="$TEST_TMPDIR/${key_name}_symmetric_key.bin"
- echo "--- Using template $key_template to generate keyset"\
- "to file $symmetric_key_file ..."
-
- $TINKEY_CLI create-keyset --key-template $key_template\
- --out-format $output_format --out $symmetric_key_file || exit 1
- echo "Done generating a symmetric keyset."
-}
-
-# Generates some example plaintext data, and stores it in $plaintext_file.
-generate_plaintext() {
- local plaintext_name="$1"
-
- plaintext_file="$TEST_TMPDIR/${plaintext_name}_plaintext.bin"
- echo "This is some plaintext message to be encrypted and/or signed" \
- " named $plaintext_name just like that." > $plaintext_file
-}
-
-# Checks that two files are equal.
-assert_files_equal() {
- local expected_file="$1"
- local given_file="$2"
- echo "*** Checking that 2 files are equal:"
- echo " file #1: $expected_file"
- echo " file #2: $given_file"
- diff $expected_file $given_file
- if [ $? -ne 0 ]; then
- echo "--- Failure: the files are different."
- exit 1
- fi
- echo "+++ Success: the files are equal."
-}
-
-# Checks that the given file has the expected content.
-assert_file_equals() {
- local expected_content="$1"
- local given_file="$2"
- echo "*** Checking that given file: $given_file"
- echo " has content equal to \"$expected_content\""
- local file_content=`cat $given_file`
- if [ "$expected_content" != "$file_content" ]; then
- echo "--- Failure. expected content: \"$expected_content\","\
- " actual content: \"$file_content\""
- exit 1
- fi
- echo "+++ Success: the file has expected content: \"$expected_content\"."
-}
-
-# Checks that two files are different.
-assert_files_different() {
- local expected_file="$1"
- local given_file="$2"
- echo "*** Checking that 2 files are different:"
- echo " file #1: $expected_file"
- echo " file #2: $given_file"
- diff -q $expected_file $given_file
- if [ $? -eq 0 ]; then
- echo "--- Failure: the files are equal."
- exit 1
- fi
- echo "+++ Success: the files are different."
-}
-
-# Checks that a given file contains specified substrings.
-assert_file_contains() {
- local file_to_test="$1"
- echo "*** Checking that file $file_to_test contains substrings:"
- cat $file_to_test
- # Shift the first argument and iterate through the remaining ones.
- shift
- for s do
- echo "... checking for string [$s]"
- if grep -q "$s" "$file_to_test"; then
- echo " found"
- else
- echo "--- Failure: file does not contain string [$s]"
- exit 1
- fi
- done
- echo "+++ Success: file contains all expected substrings."
-}