mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add unit tests for HasAmsi()
This commit is contained in:
+1
-1
@@ -113,7 +113,7 @@ dotnetlibs/xunit.console.exe: $(MONAD_EXT)/xunit/xunit.console.netcore.exe
|
||||
cp -f $^ $@
|
||||
|
||||
TEST_FOLDER=../src/ps_test
|
||||
TEST_SRCS=$(addprefix $(TEST_FOLDER)/, test_CorePsPlatform.cs test_ExtensionMethods.cs)
|
||||
TEST_SRCS=$(addprefix $(TEST_FOLDER)/, test_CorePsPlatform.cs test_ExtensionMethods.cs test_SecuritySupport.cs)
|
||||
|
||||
dotnetlibs/ps_test.dll: $(TEST_SRCS) dotnetlibs/xunit.core.dll dotnetlibs/xunit.assert.dll dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET)
|
||||
$(CSC) -out:$@ -noconfig -nostdlib -target:library -r:dotnetlibs/System.Management.Automation.dll -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) -r:dotnetlibs/xunit.core.dll -r:dotnetlibs/xunit.assert.dll ${COREREF} $(TEST_SRCS)
|
||||
|
||||
+1
-1
Submodule src/monad updated: f8a9615707...fbfb5a555a
@@ -11,9 +11,15 @@ namespace PSTests
|
||||
{
|
||||
PlatformTests.TestIsLinux();
|
||||
PlatformTests.TestHasCom();
|
||||
PlatformTests.TestHasAmsi();
|
||||
|
||||
PSTypeExtensionsTests.TestIsComObject();
|
||||
|
||||
SecuritySupportTests.TestScanContent();
|
||||
SecuritySupportTests.TestCurrentDomain_ProcessExit();
|
||||
SecuritySupportTests.TestCloseSession();
|
||||
SecuritySupportTests.TestUninitialize();
|
||||
|
||||
Console.WriteLine("Finished running tests");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,10 @@ namespace PSTests
|
||||
{
|
||||
Assert.False(Platform.HasCom());
|
||||
}
|
||||
|
||||
public static void TestHasAmsi()
|
||||
{
|
||||
Assert.False(Platform.HasAmsi());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Xunit;
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace PSTests
|
||||
{
|
||||
public static class SecuritySupportTests
|
||||
{
|
||||
public static void TestScanContent()
|
||||
{
|
||||
Assert.Equal(AmsiUtils.ScanContent("", ""), AmsiUtils.AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED);
|
||||
}
|
||||
|
||||
public static void TestCurrentDomain_ProcessExit()
|
||||
{
|
||||
AmsiUtils.CurrentDomain_ProcessExit(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public static void TestCloseSession()
|
||||
{
|
||||
AmsiUtils.CloseSession();
|
||||
}
|
||||
|
||||
public static void TestUninitialize()
|
||||
{
|
||||
AmsiUtils.Uninitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user