aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_privacy_link.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_privacy_link.py')
-rw-r--r--packages/meshbay-hub/tests/test_privacy_link.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_privacy_link.py b/packages/meshbay-hub/tests/test_privacy_link.py
new file mode 100644
index 0000000..f53c867
--- /dev/null
+++ b/packages/meshbay-hub/tests/test_privacy_link.py
@@ -0,0 +1,40 @@
+"""
+The sign-up form links the hub's privacy statement, the information GDPR
+art. 13 owes a person whose data is collected: the French text in French,
+the English one in every other language. On the hub that served the page,
+like every legal link (platform.legalUrl), never on a hub of somebody else's.
+"""
+
+import json
+import shutil
+import subprocess
+
+import pytest
+from spa_source import STATIC
+
+pytestmark = pytest.mark.skipif(shutil.which("node") is None, reason="no node")
+
+
+def test_each_language_links_its_statement():
+ probe = (
+ f"import({json.dumps((STATIC / 'platform.js').as_uri())}).then(p => "
+ "process.stdout.write(JSON.stringify(['fr', 'en', 'de', 'pt-BR']"
+ ".map(l => p.privacyUrl(l)))))"
+ )
+ out = subprocess.run(["node", "-e", probe], capture_output=True, text=True, check=True)
+ assert json.loads(out.stdout) == [
+ "/legal/confidentialite.fr.txt",
+ "/legal/privacy-statement.en.txt",
+ "/legal/privacy-statement.en.txt",
+ "/legal/privacy-statement.en.txt",
+ ]
+
+
+def test_the_sign_up_notice_links_it():
+ source = (STATIC / "auth-page.js").read_text(encoding="utf-8")
+ notice = source[source.index("${t('register.legal_notice')}"):]
+ notice = notice[:notice.index("</a>")]
+ assert "platform.privacyUrl(getLocale())" in notice
+ # htm drops whitespace that holds a line break: without it the link is
+ # glued to the sentence before it.
+ assert notice.startswith("${t('register.legal_notice')}${' '}")