diff --git a/CHANGELOG.md b/CHANGELOG.md index 915909d..62f8caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to NetDiagram-PS will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +- **`Export-DrawIO` L2-FDB edge style.** Bridge forwarding-table edges (`Confidence='L2-FDB'`) + were falling through to the gray dotted “unknown” default. They now use a dedicated + solid teal stroke (between verified L2-SNMP green and dashed amber heuristic). + ## [1.3.0] - 2026-07-30 ### Fixed diff --git a/NetDiagram-PS/Public/Export-DrawIO.ps1 b/NetDiagram-PS/Public/Export-DrawIO.ps1 index 00e7e8a..33b3466 100644 --- a/NetDiagram-PS/Public/Export-DrawIO.ps1 +++ b/NetDiagram-PS/Public/Export-DrawIO.ps1 @@ -269,11 +269,18 @@ function Export-DrawIO { $edgeStyle += 'labelBackgroundColor=#ffffff;fontSize=11;fontFamily=Helvetica;' # Different styling based on confidence level + # Visual rank matches Merge-Edges: L2-SNMP > L2-FDB > L2-SNMP-Heuristic > L3-Inferred if ($confidence -eq 'L2-SNMP') { - # L2-SNMP: Solid line, green, thicker (verified connection) + # L2-SNMP: Solid line, green, thicker (verified CDP/LLDP) $edgeStyle += 'strokeColor=#2D7600;strokeWidth=2.5;' $edgeStyle += 'endArrow=classic;endFill=1;' } + elseif ($confidence -eq 'L2-FDB') { + # L2-FDB: Solid teal — verified-ish bridge forwarding table, + # distinct from SNMP green and from dashed heuristic/L3 styles. + $edgeStyle += 'strokeColor=#0B7285;strokeWidth=2;dashed=0;' + $edgeStyle += 'endArrow=classic;endFill=1;' + } elseif ($confidence -eq 'L2-SNMP-Heuristic') { # Provisional SNMP hint: amber and dashed, visually distinct from # verified physical topology. diff --git a/README.md b/README.md index a214c59..2889411 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ Generated diagrams include: - Subnet containers for visual grouping by network segment - Color-coded status indicators: green (reachable), red (unreachable), and gray (unknown) - Orthogonal connectors with rounded corners -- Confidence levels: solid green (verified layer 2 SNMP), dashed amber (provisional SNMP hint), and dashed gray (layer 3 inferred) +- Confidence levels: solid green (verified layer 2 SNMP), solid teal (bridge FDB / L2-FDB), dashed amber (provisional SNMP hint), and dashed gray (layer 3 inferred) - Labels that include device names, IP addresses, and connection details - Hierarchical layouts that align devices by network layer diff --git a/tests/NetDiagram.Tests.ps1 b/tests/NetDiagram.Tests.ps1 index cdc61c5..69e2ae1 100644 --- a/tests/NetDiagram.Tests.ps1 +++ b/tests/NetDiagram.Tests.ps1 @@ -350,6 +350,68 @@ Describe 'Export-DrawIO' { $content | Should -Match 'target="\d+"' } + It 'Styles L2-FDB edges as solid teal, not the unknown dotted default (#59)' { + $topology = Import-Inventory -Path $script:TestInventoryPath + $topology.Edges = @( + [pscustomobject]@{ + SourceIP = '192.168.1.1'; TargetIP = '192.168.1.10' + Label = 'FDB'; Source = 'SNMP-FDB'; Confidence = 'L2-FDB' + } + ) + + $drawioPath = Join-Path $script:TestDataPath 'test-l2-fdb-edge.drawio' + $topology | Export-DrawIO -OutFile $drawioPath + + $xml = [xml](Get-Content -Path $drawioPath -Raw) + $edge = $xml.SelectSingleNode('//mxCell[@edge="1"]') + + $edge.style | Should -Match 'strokeColor=#0B7285' + $edge.style | Should -Match 'strokeWidth=2' + $edge.style | Should -Match 'dashed=0' + $edge.style | Should -Not -Match 'strokeColor=#999999' + $edge.style | Should -Not -Match 'dashPattern=2 2' + } + + It 'Keeps L2-SNMP, heuristic, L3, and unknown styles distinct from L2-FDB (#59)' { + $topology = Import-Inventory -Path $script:TestInventoryPath + $topology.Edges = @( + [pscustomobject]@{ SourceIP = '192.168.1.1'; TargetIP = '192.168.1.10'; Label = 'snmp'; Source = 'SNMP'; Confidence = 'L2-SNMP' } + [pscustomobject]@{ SourceIP = '192.168.1.10'; TargetIP = '192.168.1.1'; Label = 'fdb'; Source = 'SNMP-FDB'; Confidence = 'L2-FDB' } + [pscustomobject]@{ SourceIP = '192.168.1.10'; TargetIP = '192.168.1.20'; Label = 'hint'; Source = 'SNMP'; Confidence = 'L2-SNMP-Heuristic' } + [pscustomobject]@{ SourceIP = '192.168.1.1'; TargetIP = '192.168.1.20'; Label = 'l3'; Source = 'Manual'; Confidence = 'L3-Inferred' } + [pscustomobject]@{ SourceIP = '192.168.1.20'; TargetIP = '192.168.1.1'; Label = 'unk'; Source = 'Manual'; Confidence = 'Something-Else' } + ) + + $drawioPath = Join-Path $script:TestDataPath 'test-edge-style-rank.drawio' + $topology | Export-DrawIO -OutFile $drawioPath + + $xml = [xml](Get-Content -Path $drawioPath -Raw) + $edges = @($xml.SelectNodes('//mxCell[@edge="1"]')) + $edges | Should -HaveCount 5 + + $byLabel = @{} + foreach ($edge in $edges) { + $byLabel[$edge.value] = $edge.style + } + + $byLabel['snmp'] | Should -Match 'strokeColor=#2D7600' + $byLabel['snmp'] | Should -Not -Match 'dashed=1' + + $byLabel['fdb'] | Should -Match 'strokeColor=#0B7285' + $byLabel['fdb'] | Should -Match 'dashed=0' + $byLabel['fdb'] | Should -Not -Match 'dashed=1' + + $byLabel['hint'] | Should -Match 'strokeColor=#B26A00' + $byLabel['hint'] | Should -Match 'dashed=1' + + $byLabel['l3'] | Should -Match 'strokeColor=#808080' + $byLabel['l3'] | Should -Match 'dashed=1' + + $byLabel['unk'] | Should -Match 'strokeColor=#999999' + $byLabel['unk'] | Should -Match 'dashed=1' + $byLabel['unk'] | Should -Match 'dashPattern=2 2' + } + It 'Should skip edges with invalid node IDs' { $topology = Import-Inventory -Path $script:TestInventoryPath $topology.Edges = @(