Add grpcserver test coverage

- Add comprehensive test file for internal/grpcserver package
- Cover interceptors, system, engine, policy, and auth handlers
- Cover pbToRule/ruleToPB conversion helpers
- 37 tests total; CA/PKI/ACME and Login/Logout skipped (require live deps)

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-03-15 13:07:42 -07:00
parent ad167aed9b
commit 8215aaccc5
40 changed files with 8865 additions and 519 deletions

View File

@@ -1,63 +1,85 @@
{{define "title"}} - Dashboard{{end}}
{{define "content"}}
<h2>Dashboard</h2>
<div class="status-bar">
<span>Logged in as <strong>{{.Username}}</strong></span>
{{if .IsAdmin}}<span class="badge">Admin</span>{{end}}
<span>State: <strong>{{.State}}</strong></span>
<span class="version">v{{.Version}}</span>
<a href="/login" onclick="fetch('/v1/auth/logout',{method:'POST'})">Logout</a>
<div class="page-header">
<h2>Dashboard</h2>
<div class="page-meta">
<span class="state-chip state-{{.State}}">{{.State}}</span>
</div>
</div>
<h3>Engine Mounts</h3>
{{if .Mounts}}
<table>
<thead><tr><th>Name</th><th>Type</th><th>Path</th></tr></thead>
<tbody>
{{range .Mounts}}
<tr>
<td>{{if eq (printf "%s" .Type) "ca"}}<a href="/pki">{{.Name}}</a>{{else}}{{.Name}}{{end}}</td>
<td>{{.Type}}</td>
<td>{{.MountPath}}</td>
</tr>
<div class="card">
<div class="card-title">Engine Mounts</div>
{{if .Mounts}}
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Path</th>
</tr>
</thead>
<tbody>
{{range .Mounts}}
<tr>
<td>
{{if eq (printf "%s" .Type) "ca"}}
<a href="/pki">{{.Name}}</a>
{{else}}
{{.Name}}
{{end}}
</td>
<td><code>{{.Type}}</code></td>
<td><code>{{.MountPath}}</code></td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{else}}
<p>No engines mounted.</p>
{{end}}
</tbody>
</table>
{{else}}
<p>No engines mounted.</p>
{{end}}
</div>
{{if .IsAdmin}}
<h3>Mount CA Engine</h3>
{{if .MountError}}<div class="error">{{.MountError}}</div>{{end}}
<form method="post" action="/dashboard/mount-ca" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group">
<label for="mount_name">Mount Name</label>
<input type="text" id="mount_name" name="name" placeholder="pki" required>
</div>
<div class="form-group">
<label for="organization">Organization</label>
<input type="text" id="organization" name="organization" placeholder="Metacircular">
</div>
</div>
<div class="card">
<div class="card-title">Mount Engine</div>
{{if .MountError}}<div class="error">{{.MountError}}</div>{{end}}
<details>
<summary>Import existing root CA (optional)</summary>
<div class="form-group">
<label for="cert_file">Certificate PEM file</label>
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
</div>
<div class="form-group">
<label for="key_file">Private Key PEM file</label>
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
</div>
<summary>Mount a CA engine</summary>
<form method="post" action="/dashboard/mount-ca" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group">
<label for="mount_name">Mount Name</label>
<input type="text" id="mount_name" name="name" placeholder="pki" required>
</div>
<div class="form-group">
<label for="organization">Organization</label>
<input type="text" id="organization" name="organization" placeholder="Metacircular">
</div>
</div>
<details>
<summary>Import existing root CA (optional)</summary>
<div class="form-group">
<label for="cert_file">Certificate PEM</label>
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
</div>
<div class="form-group">
<label for="key_file">Private Key PEM</label>
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
</div>
</details>
<div class="form-actions">
<button type="submit">Mount</button>
</div>
</form>
</details>
<button type="submit">Mount</button>
</form>
</div>
<h3>Admin Actions</h3>
<div class="admin-actions">
<button hx-post="/v1/seal" hx-confirm="Are you sure you want to seal the service?">Seal Service</button>
<div class="card">
<div class="card-title">Administration</div>
<p>Sealing the service will require the seal password to restore access.</p>
<button class="btn-danger" hx-post="/v1/seal" hx-confirm="Are you sure you want to seal the service?">Seal Service</button>
</div>
{{end}}
{{end}}