Add unit tests for HasAmsi()

This commit is contained in:
Andrew Schwartzmeyer
2015-06-11 15:52:42 -07:00
parent 13cccf51cc
commit f7ffcd561a
5 changed files with 42 additions and 2 deletions
+1 -1
View File
@@ -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)
+6
View File
@@ -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");
}
}
+5
View File
@@ -15,5 +15,10 @@ namespace PSTests
{
Assert.False(Platform.HasCom());
}
public static void TestHasAmsi()
{
Assert.False(Platform.HasAmsi());
}
}
}
+29
View File
@@ -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();
}
}
}