Renamed web-app-port-ui to web-app-desktop

This commit is contained in:
2025-08-26 11:35:22 +02:00
parent 9756a0f75f
commit b916173422
34 changed files with 35 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
# Unit Tests
This directory contains unit tests for various custom components in the project, such as the custom lookup plugin `docker_cards` used in the `web-app-port-ui` role.
This directory contains unit tests for various custom components in the project, such as the custom lookup plugin `docker_cards` used in the `web-app-desktop` role.
## Overview
@@ -31,7 +31,7 @@ You can run the tests using one of the following methods:
## How It Works
- **Setup:**
The test script creates a temporary directory to simulate your roles folder. It then creates a sample role (`web-app-port-ui`) with a `README.md` file (containing a header for the title) and a `meta/main.yml` file (with the required metadata).
The test script creates a temporary directory to simulate your roles folder. It then creates a sample role (`web-app-desktop`) with a `README.md` file (containing a header for the title) and a `meta/main.yml` file (with the required metadata).
- **Execution:**
Dummy variable values for `domains` and `applications` are provided (these are the variables the lookup plugin expects). The lookup plugin is then run, which processes the sample role and returns the card information.

View File

@@ -22,7 +22,7 @@ class TestApplicationsIfGroupAndDeps(unittest.TestCase):
'web-svc-legal': {},
'web-svc-file': {},
'web-svc-asset': {},
'web-app-port-ui': {},
'web-app-desktop': {},
'util-srv-corporate-identity': {},
}

View File

@@ -182,7 +182,7 @@ class TestCspFilters(unittest.TestCase):
# Ensure feature enabled and domain set
self.apps['app1']['features']['desktop'] = True
# simulate a subdomain for the application
self.domains['web-app-port-ui'] = ['domain-example.com']
self.domains['web-app-desktop'] = ['domain-example.com']
header = self.filter.build_csp_header(self.apps, 'app1', self.domains, web_protocol='https')
# Expect '*.domain-example.com' in the frame-ancestors directive

View File

@@ -22,27 +22,27 @@ class TestDomainMappings(unittest.TestCase):
self.assertEqual(result, [])
def test_app_without_domains(self):
apps = {'web-app-port-ui': {}}
apps = {'web-app-desktop': {}}
# no domains key → no mappings
result = self.filter.domain_mappings(apps, self.primary)
self.assertEqual(result, [])
def test_empty_domains_cfg(self):
apps = {'web-app-port-ui': {'domains': {}}}
default = 'port-ui.example.com'
apps = {'web-app-desktop': {'domains': {}}}
default = 'desktop.example.com'
expected = []
result = self.filter.domain_mappings(apps, self.primary)
self.assertEqual(result, expected)
def test_explicit_aliases(self):
apps = {
'web-app-port-ui': {
'web-app-desktop': {
'server':{
'domains': {'aliases': ['alias.com']}
}
}
}
default = 'port-ui.example.com'
default = 'desktop.example.com'
expected = [
{'source': 'alias.com', 'target': default},
]
@@ -52,21 +52,21 @@ class TestDomainMappings(unittest.TestCase):
def test_canonical_not_default(self):
apps = {
'web-app-port-ui': {
'web-app-desktop': {
'server':{
'domains': {'canonical': ['foo.com']}
}
}
}
expected = [
{'source': 'port-ui.example.com', 'target': 'foo.com'}
{'source': 'desktop.example.com', 'target': 'foo.com'}
]
result = self.filter.domain_mappings(apps, self.primary)
self.assertEqual(result, expected)
def test_canonical_dict(self):
apps = {
'web-app-port-ui': {
'web-app-desktop': {
'server':{
'domains': {
'canonical': {'one': 'one.com', 'two': 'two.com'}
@@ -76,14 +76,14 @@ class TestDomainMappings(unittest.TestCase):
}
# first canonical key 'one' → one.com
expected = [
{'source': 'port-ui.example.com', 'target': 'one.com'}
{'source': 'desktop.example.com', 'target': 'one.com'}
]
result = self.filter.domain_mappings(apps, self.primary)
self.assertEqual(result, expected)
def test_multiple_apps(self):
apps = {
'web-app-port-ui': {
'web-app-desktop': {
'server':{'domains': {'aliases': ['a1.com']}}
},
'web-app-mastodon': {
@@ -91,7 +91,7 @@ class TestDomainMappings(unittest.TestCase):
},
}
expected = [
{'source': 'a1.com', 'target': 'port-ui.example.com'},
{'source': 'a1.com', 'target': 'desktop.example.com'},
{'source': 'mastodon.example.com', 'target': 'c2.com'},
]
result = self.filter.domain_mappings(apps, self.primary)
@@ -99,21 +99,21 @@ class TestDomainMappings(unittest.TestCase):
def test_multiple_aliases(self):
apps = {
'web-app-port-ui': {
'web-app-desktop': {
'server':{'domains': {'aliases': ['a1.com','a2.com']}
}
}
}
expected = [
{'source': 'a1.com', 'target': 'port-ui.example.com'},
{'source': 'a2.com', 'target': 'port-ui.example.com'}
{'source': 'a1.com', 'target': 'desktop.example.com'},
{'source': 'a2.com', 'target': 'desktop.example.com'}
]
result = self.filter.domain_mappings(apps, self.primary)
self.assertCountEqual(result, expected)
def test_invalid_aliases_type(self):
apps = {
'web-app-port-ui': {'server':{'domains': {'aliases': 123}}}
'web-app-desktop': {'server':{'domains': {'aliases': 123}}}
}
with self.assertRaises(AnsibleFilterError):
self.filter.domain_mappings(apps, self.primary)

View File

@@ -6,8 +6,8 @@ import tempfile
import shutil
import unittest
# Adjust the PYTHONPATH to include the lookup_plugins folder from the web-app-port-ui role.
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../../roles/web-app-port-ui/lookup_plugins'))
# Adjust the PYTHONPATH to include the lookup_plugins folder from the web-app-desktop role.
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../../roles/web-app-desktop/lookup_plugins'))
from docker_cards import LookupModule
@@ -17,8 +17,8 @@ class TestDockerCardsLookup(unittest.TestCase):
# Create a temporary directory to simulate the roles directory.
self.test_roles_dir = tempfile.mkdtemp(prefix="test_roles_")
# Create a sample role "web-app-port-ui" under that directory.
self.role_name = "web-app-port-ui"
# Create a sample role "web-app-desktop" under that directory.
self.role_name = "web-app-desktop"
self.role_dir = os.path.join(self.test_roles_dir, self.role_name)
os.makedirs(os.path.join(self.role_dir, "meta"))
os.makedirs(os.path.join(self.role_dir, "vars"))