diff --git a/output/PSOPNSenseAPI-v0.6.0-updated.zip b/output/PSOPNSenseAPI-v0.6.0-updated.zip new file mode 100644 index 0000000..bf466c3 Binary files /dev/null and b/output/PSOPNSenseAPI-v0.6.0-updated.zip differ diff --git a/output/PSOPNSenseAPI-v0.6.0.zip b/output/PSOPNSenseAPI-v0.6.0.zip new file mode 100644 index 0000000..b38cfe6 Binary files /dev/null and b/output/PSOPNSenseAPI-v0.6.0.zip differ diff --git a/output/PSOPNSenseAPI/PSOPNSenseAPI.psd1 b/output/PSOPNSenseAPI/PSOPNSenseAPI.psd1 index 192e6fc..4535f60 100644 --- a/output/PSOPNSenseAPI/PSOPNSenseAPI.psd1 +++ b/output/PSOPNSenseAPI/PSOPNSenseAPI.psd1 @@ -1,6 +1,6 @@ @{ - RootModule = 'PSOPNSenseAPI.dll' - ModuleVersion = '2025.04.14.2246' + RootModule = 'PSOPNSenseAPI.psm1' + ModuleVersion = '2025.04.14.2253' GUID = '1f0e4b77-cc7c-4a1e-b45a-d7c51a3c562e' Author = 'PSOPNSenseAPI Contributors' CompanyName = 'PSOPNSenseAPI' diff --git a/output/PSOPNSenseAPI/PSOPNSenseAPI.psm1 b/output/PSOPNSenseAPI/PSOPNSenseAPI.psm1 new file mode 100644 index 0000000..46b3d00 --- /dev/null +++ b/output/PSOPNSenseAPI/PSOPNSenseAPI.psm1 @@ -0,0 +1,25 @@ +# Load assemblies from the lib folder using System.Reflection.Assembly::LoadBytes +# This avoids file lock issues when the module is loaded + +$libPath = Join-Path $PSScriptRoot "lib" +$dllFiles = Get-ChildItem -Path $libPath -Filter "*.dll" + +foreach ($dll in $dllFiles) { + try { + $dllBytes = [System.IO.File]::ReadAllBytes($dll.FullName) + [System.Reflection.Assembly]::Load($dllBytes) | Out-Null + Write-Verbose "Loaded assembly: $($dll.Name)" + } + catch { + Write-Warning "Failed to load assembly $($dll.Name): $_" + } +} + +# Export all cmdlets +$cmdlets = [System.AppDomain]::CurrentDomain.GetAssemblies() | + Where-Object { $_.FullName -like "*PSOPNSenseAPI*" } | + ForEach-Object { $_.GetTypes() } | + Where-Object { $_.IsPublic -and $_.IsClass -and $_.Name -like "*Cmdlet" } | + ForEach-Object { $_.Name } + +Export-ModuleMember -Cmdlet $cmdlets diff --git a/output/PSOPNSenseAPI/Newtonsoft.Json.dll b/output/PSOPNSenseAPI/lib/Newtonsoft.Json.dll similarity index 100% rename from output/PSOPNSenseAPI/Newtonsoft.Json.dll rename to output/PSOPNSenseAPI/lib/Newtonsoft.Json.dll diff --git a/output/PSOPNSenseAPI/PSOPNSenseAPI.dll b/output/PSOPNSenseAPI/lib/PSOPNSenseAPI.dll similarity index 85% rename from output/PSOPNSenseAPI/PSOPNSenseAPI.dll rename to output/PSOPNSenseAPI/lib/PSOPNSenseAPI.dll index 9bde645..46c59f8 100644 Binary files a/output/PSOPNSenseAPI/PSOPNSenseAPI.dll and b/output/PSOPNSenseAPI/lib/PSOPNSenseAPI.dll differ diff --git a/output/PSOPNSenseAPI/System.Buffers.dll b/output/PSOPNSenseAPI/lib/System.Buffers.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Buffers.dll rename to output/PSOPNSenseAPI/lib/System.Buffers.dll diff --git a/output/PSOPNSenseAPI/System.Management.Automation.dll b/output/PSOPNSenseAPI/lib/System.Management.Automation.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Management.Automation.dll rename to output/PSOPNSenseAPI/lib/System.Management.Automation.dll diff --git a/output/PSOPNSenseAPI/System.Memory.dll b/output/PSOPNSenseAPI/lib/System.Memory.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Memory.dll rename to output/PSOPNSenseAPI/lib/System.Memory.dll diff --git a/output/PSOPNSenseAPI/System.Net.IPNetwork.dll b/output/PSOPNSenseAPI/lib/System.Net.IPNetwork.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Net.IPNetwork.dll rename to output/PSOPNSenseAPI/lib/System.Net.IPNetwork.dll diff --git a/output/PSOPNSenseAPI/System.Numerics.Vectors.dll b/output/PSOPNSenseAPI/lib/System.Numerics.Vectors.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Numerics.Vectors.dll rename to output/PSOPNSenseAPI/lib/System.Numerics.Vectors.dll diff --git a/output/PSOPNSenseAPI/System.Runtime.CompilerServices.Unsafe.dll b/output/PSOPNSenseAPI/lib/System.Runtime.CompilerServices.Unsafe.dll similarity index 100% rename from output/PSOPNSenseAPI/System.Runtime.CompilerServices.Unsafe.dll rename to output/PSOPNSenseAPI/lib/System.Runtime.CompilerServices.Unsafe.dll diff --git a/output/release-notes.md b/output/release-notes.md new file mode 100644 index 0000000..8214bd8 --- /dev/null +++ b/output/release-notes.md @@ -0,0 +1,12 @@ +## What's New + +### Added +- Port forwarding management (Get, New, Set, Remove) +- Added unit tests for interface management + +### Changed +- Updated IPNetwork2 library from version 2.6.618 to 3.1.764 +- Updated code to use the new namespace (System.Net) for IPNetwork2 +- Added support for .NET 8.0 and .NET 9.0 +- Improved XML documentation for all classes and methods +- Made OPNSenseApiClient more testable by introducing an interface diff --git a/src/PSOPNSenseAPI/PSOPNSenseAPI.csproj b/src/PSOPNSenseAPI/PSOPNSenseAPI.csproj index 4514995..51e99b2 100644 --- a/src/PSOPNSenseAPI/PSOPNSenseAPI.csproj +++ b/src/PSOPNSenseAPI/PSOPNSenseAPI.csproj @@ -4,7 +4,7 @@ netstandard2.0;net472 PSOPNSenseAPI PSOPNSenseAPI - 2025.04.14.2246 + 2025.04.14.2253 PSOPNSenseAPI Contributors PSOPNSenseAPI PowerShell module for interacting with the OPNSense API to configure firewalls diff --git a/tests/PSOPNSenseAPI.Tests/InterfaceServiceTests.cs b/tests/PSOPNSenseAPI.Tests/InterfaceServiceTests.cs index 972eb59..4192224 100644 --- a/tests/PSOPNSenseAPI.Tests/InterfaceServiceTests.cs +++ b/tests/PSOPNSenseAPI.Tests/InterfaceServiceTests.cs @@ -11,9 +11,9 @@ namespace PSOPNSenseAPI.Tests [TestClass] public class InterfaceServiceTests { - private Mock _mockApiClient; - private Mock _mockLogger; - private InterfaceService _interfaceService; + private Mock? _mockApiClient; + private Mock? _mockLogger; + private InterfaceService? _interfaceService; [TestInitialize] public void Setup() @@ -43,11 +43,11 @@ namespace PSOPNSenseAPI.Tests } }; - _mockApiClient.Setup(x => x.GetAsync("interfaces/overview/searchInterfaces")) + _mockApiClient!.Setup(x => x.GetAsync("interfaces/overview/searchInterfaces")) .ReturnsAsync(response); // Act - var result = await _interfaceService.GetInterfacesAsync(); + var result = await _interfaceService!.GetInterfacesAsync(); // Assert Assert.IsNotNull(result); @@ -78,11 +78,11 @@ namespace PSOPNSenseAPI.Tests } }; - _mockApiClient.Setup(x => x.GetAsync($"interfaces/overview/getInterface/{interfaceName}")) + _mockApiClient!.Setup(x => x.GetAsync($"interfaces/overview/getInterface/{interfaceName}")) .ReturnsAsync(response); // Act - var result = await _interfaceService.GetInterfaceDetailAsync(interfaceName); + var result = await _interfaceService!.GetInterfaceDetailAsync(interfaceName); // Assert Assert.IsNotNull(result); @@ -114,11 +114,11 @@ namespace PSOPNSenseAPI.Tests Result = "saved" }; - _mockApiClient.Setup(x => x.PostAsync($"interfaces/overview/setInterface/{interfaceName}", It.IsAny())) + _mockApiClient!.Setup(x => x.PostAsync($"interfaces/overview/setInterface/{interfaceName}", It.IsAny())) .ReturnsAsync(response); // Act - var result = await _interfaceService.UpdateInterfaceAsync(interfaceName, interfaceConfig); + var result = await _interfaceService!.UpdateInterfaceAsync(interfaceName, interfaceConfig); // Assert Assert.IsNotNull(result);