From 9ffef4aa80d5fb2119d4c9cfffa9640c33f589e7 Mon Sep 17 00:00:00 2001 From: "Emerle, Ryan" Date: Mon, 16 May 2022 14:33:12 -0400 Subject: [PATCH] Fix tests Update query sorting for recordset search Update `How to Search` instructions --- ...ordSetCacheRepositoryIntegrationSpec.scala | 11 +---- .../MySqlRecordSetCacheRepository.scala | 9 ++-- .../views/recordsets/recordSets.scala.html | 43 +++++++++++-------- modules/portal/public/css/vinyldns.css | 5 +++ quickstart/README.md | 28 ++++++------ quickstart/quickstart-vinyldns.sh | 34 ++++++++------- 6 files changed, 68 insertions(+), 62 deletions(-) diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepositoryIntegrationSpec.scala index 9027b2dac..ae83d5b17 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepositoryIntegrationSpec.scala @@ -441,16 +441,7 @@ class MySqlRecordSetCacheRepositoryIntegrationSpec "return applicable recordsets in descending order when recordNameFilter is given and name sort is descending" in { val existing = insert(okZone, 10).map(_.recordSet) val found = recordSetCacheRepo - .listRecordSetData(None, None, None, Some("*.ok*"), None, None, NameSort.DESC) - .unsafeRunSync() - found.recordSets should contain theSameElementsAs existing - .map(r => recordSetDataWithFQDN(r, okZone)) - .reverse - } - "return applicable recordsets in descending order when recordNameFilter supports full-text" in { - val existing = insert(okZone, 10).map(_.recordSet) - val found = recordSetCacheRepo - .listRecordSetData(None, None, None, Some("apply*test"), None, None, NameSort.DESC) + .listRecordSetData(None, None, None, Some("*.recordsets."), None, None, NameSort.DESC) .unsafeRunSync() found.recordSets should contain theSameElementsAs existing .map(r => recordSetDataWithFQDN(r, okZone)) diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepository.scala b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepository.scala index 6d5e95895..1a8e30ece 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepository.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordSetCacheRepository.scala @@ -314,11 +314,11 @@ class MySqlRecordSetCacheRepository ) case (false, NameSort.ASC) => pagingKey.as( - sqls"((recordset_data.fqdn >= ${pagingKey.map(pk => pk.recordName)} AND recordset.type > ${pagingKey.map(pk => pk.recordType)}) OR recordset_data.fqdn > ${pagingKey.map(pk => pk.recordName)})" + sqls"((recordset.fqdn >= ${pagingKey.map(pk => pk.recordName)} AND recordset.type > ${pagingKey.map(pk => pk.recordType)}) OR recordset.fqdn > ${pagingKey.map(pk => pk.recordName)})" ) case (false, NameSort.DESC) => pagingKey.as( - sqls"((recordset_data.fqdn <= ${pagingKey.map(pk => pk.recordName)} AND recordset.type > ${pagingKey.map(pk => pk.recordType)}) OR recordset_data.fqdn < ${pagingKey.map(pk => pk.recordName)})" + sqls"((recordset.fqdn <= ${pagingKey.map(pk => pk.recordName)} AND recordset.type > ${pagingKey.map(pk => pk.recordType)}) OR recordset.fqdn < ${pagingKey.map(pk => pk.recordName)})" ) case _ => pagingKey.as( @@ -338,10 +338,10 @@ class MySqlRecordSetCacheRepository (zoneAndNameFilters ++ sortBy ++ typeFilter ++ ownerGroupFilter).toList val qualifiers = if (nameSort == ASC) { - sqls"ORDER BY recordset_data.fqdn ASC, recordset.type ASC " + sqls"ORDER BY recordset.fqdn ASC, recordset.type ASC " } else { - sqls"ORDER BY recordset_data.fqdn DESC, recordset.type ASC " + sqls"ORDER BY recordset.fqdn DESC, recordset.type ASC " } val recordLimit = maxPlusOne match { @@ -358,7 +358,6 @@ class MySqlRecordSetCacheRepository // Join query for data column from recordset table val recordsetDataJoin = sqls"RIGHT JOIN recordset ON recordset.id=recordset_data.recordset_id " - val recordsetDataJoinQuery = initialQuery.append(recordsetDataJoin) val appendOpts = if (opts.nonEmpty) { diff --git a/modules/portal/app/views/recordsets/recordSets.scala.html b/modules/portal/app/views/recordsets/recordSets.scala.html index 23f5f9ff6..47c1d9341 100644 --- a/modules/portal/app/views/recordsets/recordSets.scala.html +++ b/modules/portal/app/views/recordsets/recordSets.scala.html @@ -39,25 +39,32 @@

The search is based on the fully qualified domain name (FQDN) of a record. You can do an exact match search or fuzzy match to lookup records.

-

A minimum of two alphanumeric characters for the record name is required for searching.

-

Examples: -

    -
  • test.example.com. -> test.example.com.
  • -
  • test.example.com -> test.example.com.
  • -
  • test.* -> test.example.com., test.example.net., test.net.
  • -
  • *example.com -> one.example.com., test.example.com.
  • -
  • *example* -> one.example.com., test.example.com., test.example.net.
  • -
+

+ A minimum of two alphanumeric characters for the record name is required for searching. Also, + a search term cannot both start and end with a wildcard character. +

+

+ Examples: +

    +
  • test.example.com. -> test.example.com.
  • +
  • test.example.com -> test.example.com.
  • +
  • test.* -> test.example.com., test.example.net., test.net.
  • +
  • *example.com -> one.example.com., test.example.com.
  • +
  • *example* -> INVALID
  • +


PTR Records
-

For PTR records you can look up records by their IP address or by their FQDN. Compressed or expanded formats of IPv6 addresses are supported. Partial matching is not supported.

-

Examples: -

    -
  • 4.4.8.8.in-addr.arpa. -> 4.4.8.8.in-addr.arpa.
  • -
  • 8.8.4.4 -> 4.4.8.8.in-addr.arpa.
  • -
  • 2001:db8::567:89ab -> b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
  • -
+

For PTR records you can look up records by their IP address or by their FQDN. Compressed or expanded formats of IPv6 addresses are supported.

+

Partial matching of IP addresses is not supported, but partial matching of the FQDN is supported.

+

+ Examples: +

    +
  • 4.4.8.8.in-addr.arpa. -> 4.4.8.8.in-addr.arpa.
  • +
  • *.4.8.8.in-addr.arpa. -> 2.4.8.8.in-addr.arpa., 3.4.8.8.in-addr.arpa., 4.4.8.8.in-addr.arpa.
  • +
  • 8.8.4.4 -> 4.4.8.8.in-addr.arpa.
  • +
  • 2001:db8::567:89ab -> b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
  • +

@@ -167,8 +174,8 @@ {{record.fqdn}} - {{record.type}} - {{record.ttl}} + {{record.type}} + {{record.ttl}} diff --git a/modules/portal/public/css/vinyldns.css b/modules/portal/public/css/vinyldns.css index 6d30d5e0f..b59f8174a 100644 --- a/modules/portal/public/css/vinyldns.css +++ b/modules/portal/public/css/vinyldns.css @@ -425,6 +425,11 @@ input[type="file"] { word-break: break-all; } +.no-wrap { + white-space: nowrap; + word-break: keep-all; +} + .record-data-label { vertical-align: top; } diff --git a/quickstart/README.md b/quickstart/README.md index f4ee766df..f47d5047a 100644 --- a/quickstart/README.md +++ b/quickstart/README.md @@ -25,19 +25,19 @@ From a shell in the `quickstart/` directory, simply run: The `quickstart-vinyldns.sh` script takes a number of optional arguments: -| Flag | Description | -|:------------------|:----------------------------------------------------------------------------------------------------| -| -a, --api | start the API, but not the Portal and its dependencies (e.g., LDAP) | -| -b, --build | force a rebuild of the Docker images with the local code | -| -c, --clean | stops all VinylDNS containers and exits | -| -d, --deps | start up the dependencies, but not the API or Portal | -| -sh, --shell | loads the .env file into a new BASH shell. The .env file can be overridden with -e | -| -e, --env-file | specifies the path (relative to the docker-compose file) to the .env file to load (e.g., .env.dev). | -| -r, --reset | stops any the running containers before starting new containers | -| -s, --service | specify the service to run | -| -t, --timeout | the time to wait (in seconds) for the Portal and API to start (default: 60) | -| -u, --update | remove the local quickstart images to force a rebuild | -| -v, --version-tag | specify Docker image tag version (default: latest) | +| Flag | Description | +|:------------------|:-----------------------------------------------------------------------------------------------------------------------| +| -a, --api | start the API, but not the Portal and its dependencies (e.g., LDAP) | +| -b, --build | force a rebuild of the Docker images with the local code | +| -c, --clean | stops all VinylDNS containers and exits | +| -d, --deps | start up the dependencies, but not the API or Portal | +| -sh, --shell | loads the .env file into a new BASH shell. The .env file can be overridden with -e | +| -e, --env-file | specifies the suffix of the .env file (relative to the docker-compose file) to load (e.g., 'dev' - to load '.env.dev') | +| -r, --reset | stops any the running containers before starting new containers | +| -s, --service | specify the service to run | +| -t, --timeout | the time to wait (in seconds) for the Portal and API to start (default: 60) | +| -u, --update | remove the local quickstart images to force a rebuild | +| -v, --version-tag | specify Docker image tag version (default: latest) | ## Environment Settings @@ -53,7 +53,7 @@ Let's say you have a `.env.dev` file in the `quickstart/` directory. You can loa shell with ```shell -$ ./quickstart/quickstart.sh --env-file .env.dev --sh +$ ./quickstart/quickstart.sh -sh --env-file dev # To load .env.dev just specify the suffix - dev Please wait.. creating a new shell with the environment variables set. To return, simply exit the new shell with 'exit' or ^D. $ diff --git a/quickstart/quickstart-vinyldns.sh b/quickstart/quickstart-vinyldns.sh index de4edaf1c..776630df0 100755 --- a/quickstart/quickstart-vinyldns.sh +++ b/quickstart/quickstart-vinyldns.sh @@ -24,7 +24,7 @@ function usage() { echo -e "\t-c, --clean stops all VinylDNS containers and exits" echo -e "\t-d, --deps start up the dependencies, but not the API or Portal" echo -e "\t-sh, --shell loads the .env file into a new BASH shell. The .env file can be overridden with -e" - echo -e "\t-e, --env-file specifies the path (relative to the docker-compose file) to the .env file to load (e.g., .env.dev)." + echo -e "\t-e, --env-file specifies the suffix of the .env file (relative to the docker-compose file) to load (e.g., 'dev' - to load '.env.dev')" echo -e "\t-r, --reset stops any the running containers before starting new containers" echo -e "\t-s, --service specify the service to run" echo -e "\t-t, --timeout the time to wait (in seconds) for the Portal and API to start (default: 60)" @@ -84,6 +84,7 @@ RESET_DOCKER=0 UPDATE=0 CLEAN=0 ENV_FILE="${DIR}/.env" +SHELL_REQUESTED=0 while [[ $# -gt 0 ]]; do case "$1" in -t | --timeout) @@ -124,16 +125,16 @@ while [[ $# -gt 0 ]]; do RESET_DOCKER=1 shift ;; - -sh | --shell) - # shellcheck disable=SC2046 - export $(grep -Ev '^#' "${ENV_FILE}" | xargs) - echo "Please wait.. creating a new shell with the environment variables set." - echo "To return, simply exit the new shell with 'exit' or ^D." - bash - exit - ;; + -sh | --shell) + SHELL_REQUESTED=1 + shift + ;; -e | --env-file) - export ENV_FILE="${DIR}/$2" + if [ ! -f "${DIR}/.env.$2" ]; then + echo "Cannot load ${DIR}/.env.$2" + exit 1 + fi + export ENV_FILE="${DIR}/.env.$2" shift shift ;; @@ -151,12 +152,15 @@ while [[ $# -gt 0 ]]; do esac done -# Source customizable env files ('-a' causes all variables to be exported) +# Load environment variables +export $(echo $(cat "${ENV_FILE}" | sed 's/#.*//g'| xargs) | envsubst) -set -a -# shellcheck disable=SC1090 -source "${ENV_FILE}" -set +a +if [[ $SHELL_REQUESTED -eq 1 ]]; then + echo "Please wait.. creating a new shell with the environment variables set." + echo "To return, simply exit the new shell with 'exit' or ^D." + bash + exit +fi # The version of VinylDNS docker image to run export VINYLDNS_VERSION=latest