Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfiles/htadmin.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ ADD --chmod=644 docs/images/favicon/favicon.ico /var/www/htadmin/
ADD --chmod=644 htadmin/supervisord.conf /supervisord.conf
ADD --chmod=755 htadmin/htadmin.sh /usr/local/bin/
ADD --chmod=644 htadmin/src/bootstrap.* /var/www/htadmin/
ADD --chmod=644 htadmin/src/malcolm.css /var/www/htadmin/
ADD --chmod=644 nginx/landingpage/assets/img/CISA.svg /var/www/htadmin/malcolm-cisa.svg
ADD --chmod=644 htadmin/src/includes/*.php /var/www/htadmin/includes/
ADD --chmod=644 htadmin/php/php.ini /etc/php/$PHP_VERSION/fpm/php.ini
ADD --chmod=644 htadmin/nginx/sites-available/default /etc/nginx/sites-available/default
Expand Down
22 changes: 22 additions & 0 deletions htadmin/src/includes/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Copyright (c) 2026 Battelle Energy Alliance, LLC. All rights reserved. -->
<footer class="malcolm-footer" role="contentinfo">
<div class="container malcolm-footer-content">
<p class="text-muted small">
<a href="https://github.com/cisagov/Malcolm/releases">Malcolm<?php
$version = getenv('MALCOLM_VERSION');
if ($version) {
echo ' ' . htmlspecialchars($version, ENT_QUOTES, 'UTF-8');
}
?></a>
&copy; 2026 Battelle Energy Alliance, LLC.
</p>
<nav aria-label="Malcolm resources">
<a href="/">Home</a>
<a href="/readme/">Documentation</a>
<a href="/mapi/ready">Service Readiness</a>
<a href="https://github.com/cisagov/Malcolm">GitHub</a>
</nav>
</div>
</footer>
</body>
</html>
6 changes: 4 additions & 2 deletions htadmin/src/includes/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
<script src="script/jquery-1.12.0.min.js"></script>
<script src="bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="script/script.js"></script>
<link rel="stylesheet" href="styles/style.css"> <!-- These are local (overriding) css styles. -->
<link rel="stylesheet" href="styles/style.css"> <!-- Existing htadmin overrides -->
<link rel="stylesheet" href="malcolm.css"> <!-- Consistent Malcolm landing-page appearance -->
<link rel="icon" type="image/x-icon" href="favicon.ico">

<!-- viewport: To ensure proper rendering and touch zooming. See 3.3.6 bootstrap docs -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<title><?php echo $ini ['app_title']; ?></title>
<title><?php echo htmlspecialchars($ini['app_title'] ?? 'Malcolm Account Management', ENT_QUOTES, 'UTF-8'); ?></title>
</head>
<body>

23 changes: 23 additions & 0 deletions htadmin/src/includes/nav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
// Copyright (c) 2026 Battelle Energy Alliance, LLC. All rights reserved.
// Shared Malcolm navigation for the embedded htadmin account manager.
?>
<nav class="navbar navbar-default malcolm-navigation" aria-label="Account management navigation">
<div class="container malcolm-navigation-content">
<div class="navbar-header">
<a class="navbar-brand malcolm-brand" href="/" aria-label="Malcolm home">
<img src="malcolm-cisa.svg" alt="CISA" class="malcolm-brand-logo">
<span>Malcolm <small>Account Management</small></span>
</a>
</div>
<ul class="nav navbar-nav navbar-right malcolm-navigation-links">
<li><a href="/" class="malcolm-home-link">Home</a></li>
<?php if (check_admin_login()): ?>
<li><a href="admin_logout.php">Logout</a></li>
<?php else: ?>
<li><a href="admin_login.php">Administrator Login</a></li>
<li><a href="selfservice.php">Account Self Service</a></li>
<?php endif; ?>
</ul>
</div>
</nav>
101 changes: 101 additions & 0 deletions htadmin/src/malcolm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* Copyright (c) 2026 Battelle Energy Alliance, LLC. All rights reserved. */
/* Align local account administration with Malcolm's Bootstrap-based landing UI
* while retaining the existing htadmin Bootstrap 3 forms and behavior. */
:root {
--malcolm-primary: #0d6efd;
--malcolm-text: #212529;
--malcolm-muted: #6c757d;
--malcolm-page: #fff;
--malcolm-surface: #f8f9fa;
--malcolm-border: #dee2e6;
}
html { min-height: 100%; }
body {
color: var(--malcolm-text);
background-color: var(--malcolm-page);
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
display: flex;
flex-direction: column;
min-height: 100vh;
}
body > .container, body > .container-fluid { flex: 1 0 auto; }
a { color: var(--malcolm-primary); }
a:hover, a:focus { color: #0a58ca; }
.malcolm-navigation {
background: var(--malcolm-surface);
border: 0;
border-bottom: 1px solid var(--malcolm-border);
border-radius: 0;
min-height: 70px;
margin-bottom: 32px;
box-shadow: none;
}
.malcolm-navigation-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 8px 18px;
}
.navbar-header { float: none; }
.malcolm-brand {
float: none;
display: inline-flex;
align-items: center;
gap: 12px;
color: var(--malcolm-text) !important;
min-height: 68px;
height: auto;
padding: 10px 0;
font-size: 22px;
line-height: 1.2;
font-weight: 600;
}
.malcolm-brand-logo { width: 44px; height: 44px; object-fit: contain; }
.malcolm-brand small { display: block; font-size: 12px; font-weight: 400; color: var(--malcolm-muted); }
.malcolm-navigation .malcolm-navigation-links { float: none !important; margin: 0; }
.malcolm-navigation-links > li > a {
color: var(--malcolm-text) !important;
font-weight: 500;
padding: 14px 12px;
}
.malcolm-navigation-links > li > a:hover,
.malcolm-navigation-links > li > a:focus {
color: var(--malcolm-primary) !important;
background: #e9ecef;
outline-offset: 2px;
}
h1, h2, h3, h4 { color: var(--malcolm-text); font-weight: 600; }
.panel, .well, .thumbnail {
border: 1px solid var(--malcolm-border);
border-radius: 6px;
box-shadow: none;
}
.btn-primary { background: var(--malcolm-primary); border-color: var(--malcolm-primary); }
.btn-primary:hover, .btn-primary:focus { background: #0b5ed7; border-color: #0a58ca; }
.form-control:focus { border-color: #86b7fe; box-shadow: 0 0 0 2px #0d6efd24; }
.malcolm-footer {
width: 100%;
background: var(--malcolm-surface);
border-top: 1px solid var(--malcolm-border);
margin-top: auto;
padding: 22px 0;
}
.malcolm-footer-content {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 14px 24px;
}
.malcolm-footer p { margin: 0; color: var(--malcolm-muted); }
.malcolm-footer nav { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.malcolm-footer a { text-decoration: none; }
.malcolm-footer a:hover, .malcolm-footer a:focus { text-decoration: underline; }
@media (max-width: 767px) {
.malcolm-navigation { margin-bottom: 20px; }
.malcolm-navigation-content, .malcolm-footer-content { align-items: flex-start; }
.malcolm-navigation-links > li { display: inline-block; }
.malcolm-navigation-links > li > a { padding: 8px 10px; }
.malcolm-footer-content { flex-direction: column; }
}
150 changes: 150 additions & 0 deletions scripts/installer/tests/unit/test_htadmin_branding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
"""Tests for consistent Malcolm branding on the htadmin account management UI."""

import os
import shutil
import subprocess
import unittest
from html.parser import HTMLParser
from pathlib import Path

ROOT = Path(__file__).resolve().parents[4]
HEADER = ROOT / "htadmin/src/includes/head.php"
NAV = ROOT / "htadmin/src/includes/nav.php"
FOOTER = ROOT / "htadmin/src/includes/footer.php"
CSS = ROOT / "htadmin/src/malcolm.css"
DOCKERFILE = ROOT / "Dockerfiles/htadmin.Dockerfile"


class _MarkupParser(HTMLParser):
def __init__(self):
super().__init__()
self.links = []
self.images = []
self.navigation = []
self.footer_count = 0

def handle_starttag(self, tag, attrs):
attributes = dict(attrs)
if tag == "a":
self.links.append(attributes.get("href", ""))
if tag == "img":
self.images.append(attributes)
if tag == "nav":
self.navigation.append(attributes.get("aria-label", ""))
if tag == "footer":
self.footer_count += 1


class TestHtadminMalcolmBranding(unittest.TestCase):
@unittest.skipUnless(shutil.which("php"), "PHP CLI is not available")
def test_php_files_have_valid_syntax(self):
for file in (HEADER, NAV, FOOTER):
with self.subTest(file=file.name):
proc = subprocess.run(
["php", "-l", str(file)],
capture_output=True,
text=True,
check=False,
)
self.assertEqual(proc.returncode, 0, proc.stderr)

def _render_nav(self, is_admin):
php = (
"$ini = ['app_title' => 'Account management']; "
f"function check_admin_login() {{ return {'true' if is_admin else 'false'}; }} "
"include $argv[1];"
)
result = subprocess.run(
["php", "-r", php, str(NAV)],
text=True,
capture_output=True,
check=False,
)
self.assertEqual(result.returncode, 0, result.stderr)
parser = _MarkupParser()
parser.feed(result.stdout)
return parser, result.stdout

@unittest.skipUnless(shutil.which("php"), "PHP CLI is not available")
def test_unauthenticated_navigation_retains_both_workflows(self):
parsed, html = self._render_nav(False)
self.assertIn("admin_login.php", parsed.links)
self.assertIn("selfservice.php", parsed.links)
self.assertNotIn("admin_logout.php", parsed.links)
self.assertIn("Account Management", html)

@unittest.skipUnless(shutil.which("php"), "PHP CLI is not available")
def test_authenticated_navigation_provides_logout(self):
parsed, _ = self._render_nav(True)
self.assertIn("admin_logout.php", parsed.links)
self.assertNotIn("admin_login.php", parsed.links)
self.assertNotIn("selfservice.php", parsed.links)

@unittest.skipUnless(shutil.which("php"), "PHP CLI is not available")
def test_navigation_has_home_and_accessible_logo(self):
parsed, _ = self._render_nav(False)
self.assertIn("/", parsed.links)
self.assertIn("Account management navigation", parsed.navigation)
self.assertTrue(any(img.get("alt") == "CISA" for img in parsed.images))

@unittest.skipUnless(shutil.which("php"), "PHP CLI is not available")
def test_footer_includes_brand_and_navigation(self):
result = subprocess.run(
["php", "-r", "include $argv[1];", str(FOOTER)],
capture_output=True,
text=True,
check=False,
env={**os.environ, "MALCOLM_VERSION": "26.09.0"},
)
self.assertEqual(result.returncode, 0, result.stderr)
parser = _MarkupParser()
parser.feed(result.stdout)
self.assertEqual(parser.footer_count, 1)
self.assertIn("/", parser.links)
self.assertIn("/readme/", parser.links)
self.assertIn("/mapi/ready", parser.links)
self.assertIn("Malcolm resources", parser.navigation)
self.assertIn("Malcolm 26.09.0", result.stdout)

def test_bootstrap_and_application_assets_are_preserved(self):
html = HEADER.read_text()
self.assertIn('href="bootstrap.css"', html)
self.assertIn('href="styles/style.css"', html)
self.assertIn('href="malcolm.css"', html)
self.assertIn('href="favicon.ico"', html)
self.assertLess(
html.index('href="bootstrap.css"'), html.index('href="malcolm.css"')
)

def test_consistent_brand_palette_and_responsive_layout(self):
css = CSS.read_text()
for token in ("#0d6efd", "#212529", "#6c757d", "#f8f9fa"):
self.assertIn(token, css)
self.assertIn("@media (max-width: 767px)", css)
self.assertIn(".malcolm-navigation", css)
self.assertIn(".malcolm-footer", css)

def test_image_is_part_of_the_upstream_landing_page(self):
logo = ROOT / "nginx/landingpage/assets/img/CISA.svg"
self.assertTrue(logo.is_file())
self.assertIn("<svg", logo.read_text())

def test_dockerfile_installs_overrides_and_shared_logo(self):
dockerfile = DOCKERFILE.read_text()
self.assertIn("htadmin/src/includes/*.php", dockerfile)
self.assertIn("htadmin/src/malcolm.css", dockerfile)
self.assertIn(
"nginx/landingpage/assets/img/CISA.svg /var/www/htadmin/malcolm-cisa.svg",
dockerfile,
)
self.assertIn("htadmin/src/bootstrap.*", dockerfile)

def test_original_workflows_are_still_reachable(self):
text = NAV.read_text()
for route in ("admin_login.php", "selfservice.php", "admin_logout.php"):
self.assertIn(f'href="{route}"', text)
self.assertIn("check_admin_login()", text)


if __name__ == "__main__":
unittest.main()