From b51aad2d20ecb9ef2d4b05ac9179a6bf3832e8f6 Mon Sep 17 00:00:00 2001 From: Mahbub Ul Alam Date: Tue, 26 Nov 2024 15:38:56 +0100 Subject: [PATCH] SS-1206 added validation and unit tests --- apps/models/app_types/shiny.py | 15 ++++---- apps/tests/test_forms.py | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/apps/models/app_types/shiny.py b/apps/models/app_types/shiny.py index 2452fda9..3321fa58 100644 --- a/apps/models/app_types/shiny.py +++ b/apps/models/app_types/shiny.py @@ -17,16 +17,15 @@ def validate_shiny_site_dir(candidate): It is up to the caller to handle the raised exception if desired. """ error_message = ( - "Your shiny site directory subpath is not valid, please correct it. " - "It must be 1-53 characters long." - " It can contain only Unicode letters, digits, hyphens" - " ( - ), forward slashes ( / ), and underscores ( _ )." - " It cannot start or end with a hyphen ( - ) and " - "cannot start with a forward slash ( / )." - " It cannot contain consecutive forward slashes ( // )." + "Please provide a valid path. " + "It can be empty. " + "Otherwise, it must be 63 characters or less. " + " It must begin and end with an alphanumeric character (a-z, or 0-9, or A-Z)." + " It could contain dashes ( - ), underscores ( _ ), dots ( . ), " + "and alphanumerics." ) - pattern = r"^(?!-)(?!/)(?!.*//)[\p{Letter}\p{Mark}0-9-/_]{1,53}(?