From 0b630037f97b75ebc17f6774471116b2cf43e9dc Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Tue, 23 Mar 2021 15:02:50 -0400 Subject: [PATCH] pagekite: Convert entered kite name to lower case Let's Encrypt certificate paths use lower-case kite name. Test: Pagekite functional tests are passing. Signed-off-by: James Valleroy Reviewed-by: Veiko Aasa --- plinth/modules/pagekite/forms.py | 10 ++++++++-- plinth/modules/pagekite/tests/pagekite.feature | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plinth/modules/pagekite/forms.py b/plinth/modules/pagekite/forms.py index 805fde25b..e95ca3b42 100644 --- a/plinth/modules/pagekite/forms.py +++ b/plinth/modules/pagekite/forms.py @@ -67,11 +67,17 @@ class ConfigurationForm(forms.Form): old = _filter(self.initial) new = _filter(self.cleaned_data) + # Kite name should be ASCII. If it's unicode, convert to + # ASCII. + kite_name = str(new['kite_name']) + + # Let's Encrypt certificate paths use lower-case kite name. + kite_name = kite_name.lower() + if old != new: frontend = f"{new['server_domain']}:{new['server_port']}" utils.run([ - 'set-config', '--kite-name', new['kite_name'], '--frontend', - frontend + 'set-config', '--kite-name', kite_name, '--frontend', frontend ], input=new['kite_secret'].encode()) messages.success(request, _('Configuration updated')) diff --git a/plinth/modules/pagekite/tests/pagekite.feature b/plinth/modules/pagekite/tests/pagekite.feature index 3f6edb62c..8e4848725 100644 --- a/plinth/modules/pagekite/tests/pagekite.feature +++ b/plinth/modules/pagekite/tests/pagekite.feature @@ -23,6 +23,11 @@ Scenario: Configure pagekite application When I configure pagekite with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret Then pagekite should be configured with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret +Scenario: Capitalized kite name + Given the pagekite application is enabled + When I configure pagekite with host pagekite.example.com, port 8080, kite name Mykite.example.com and kite secret mysecret + Then pagekite should be configured with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret + @backups Scenario: Backup and restore pagekite Given the pagekite application is enabled