|
236 | 236 | "@{ ModuleVersion='1.0'; RootModule='$moduleFilePathI' }" | Out-File $moduleManifestPathI |
237 | 237 |
|
238 | 238 | # Module with using directive |
239 | | - $sriptModuleNameJ = "ModuleWithUsing_System32" |
240 | | - $moduleFilePathJ = Join-Path $TestModulePath ($sriptModuleNameJ + ".psm1") |
| 239 | + $scriptModuleNameJ = "ModuleWithUsing_System32" |
| 240 | + $moduleFilePathJ = Join-Path $TestModulePath ($scriptModuleNameJ + ".psm1") |
241 | 241 | @' |
242 | 242 | using module {0} |
243 | 243 | function PublicUsingFn {{ [Class1]::GetMessage() }} |
|
247 | 247 | Write-Verbose "Test module files created" |
248 | 248 | } |
249 | 249 |
|
| 250 | + AfterAll { |
| 251 | + Remove-Module $scriptModuleNameA -Force -ErrorAction SilentlyContinue |
| 252 | + Remove-Module $scriptModuleNameB -Force -ErrorAction SilentlyContinue |
| 253 | + Remove-Module $scriptModuleNameC -Force -ErrorAction SilentlyContinue |
| 254 | + Remove-Module $scriptModuleNameD -Force -ErrorAction SilentlyContinue |
| 255 | + Remove-Module $scriptModuleNameE -Force -ErrorAction SilentlyContinue |
| 256 | + Remove-Module $scriptModuleNameF -Force -ErrorAction SilentlyContinue |
| 257 | + Remove-Module $scriptModuleNameG -Force -ErrorAction SilentlyContinue |
| 258 | + Remove-Module $scriptModuleNameH -Force -ErrorAction SilentlyContinue |
| 259 | + Remove-Module $scriptModuleNameI -Force -ErrorAction SilentlyContinue |
| 260 | + Remove-Module $scriptModuleNameJ -Force -ErrorAction SilentlyContinue |
| 261 | + } |
| 262 | + |
250 | 263 | It "Verifies that importing trusted module in system lockdown which dot sources a ps1 file while exporting all functions with wildcard throws expected error" { |
251 | 264 |
|
252 | 265 | try |
|
457 | 470 | "@{ ModuleVersion = '1.0'; RootModule = '$moduleFileName'; FunctionsToExport = 'PublicFn' }" > $manifestFileName |
458 | 471 | } |
459 | 472 |
|
| 473 | + AfterAll { |
| 474 | + Remove-Module ImportTrustedManifestWithCallOperator_System32 -Force -ErrorAction SilentlyContinue |
| 475 | + } |
| 476 | + |
460 | 477 | It "Verifies expected error when call operator attempts to access trusted module scope function" { |
461 | 478 |
|
462 | 479 | try |
|
638 | 655 | finally |
639 | 656 | { |
640 | 657 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 658 | + Remove-Module ImportUnTrustedManifestWithFnExport_System32 -Force -ErrorAction SilentlyContinue |
641 | 659 | } |
642 | 660 |
|
643 | 661 | $expectedError.FullyQualifiedErrorId | Should -BeExactly "Modules_MismatchedLanguageModes,Microsoft.PowerShell.Commands.ImportModuleCommand" |
|
807 | 825 | finally |
808 | 826 | { |
809 | 827 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 828 | + Remove-Module ImportTrustedModuleWithNoFnExport_System32 -Force -ErrorAction SilentlyContinue |
810 | 829 | } |
811 | 830 |
|
812 | 831 | $module.ExportedCommands.Count | Should -Be 0 |
|
837 | 856 | finally |
838 | 857 | { |
839 | 858 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 859 | + Remove-Module ImportTrustedModuleWithFnExport_System32 -Force -ErrorAction SilentlyContinue |
840 | 860 | } |
841 | 861 |
|
842 | 862 | $module.ExportedCommands.Count | Should -Be 1 |
|
868 | 888 | finally |
869 | 889 | { |
870 | 890 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 891 | + Remove-Module ImportTrustedModuleWithWildcardFnExport_System32 -Force -ErrorAction SilentlyContinue |
871 | 892 | } |
872 | 893 |
|
873 | 894 | $module.ExportedCommands.Count | Should -Be 2 |
|
927 | 948 | finally |
928 | 949 | { |
929 | 950 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 951 | + Remove-Module ImportTrustedManifestWithNoFnExport_System32 -Force -ErrorAction SilentlyContinue |
930 | 952 | } |
931 | 953 |
|
932 | 954 | $module.ExportedCommands.Count | Should -Be 0 |
|
957 | 979 | finally |
958 | 980 | { |
959 | 981 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 982 | + Remove-Module ImportTrustedManifestWithWildcardFnExport1_System32 -Force -ErrorAction SilentlyContinue |
960 | 983 | } |
961 | 984 |
|
962 | 985 | $module.ExportedCommands.Count | Should -Be 0 |
|
987 | 1010 | finally |
988 | 1011 | { |
989 | 1012 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1013 | + Remove-Module ImportTrustedManifestWithWildcardNameFnExport_System32 -Force -ErrorAction SilentlyContinue |
990 | 1014 | } |
991 | 1015 |
|
992 | 1016 | $module.ExportedCommands.Count | Should -Be 0 |
@@ -1019,6 +1043,7 @@ try |
1019 | 1043 | finally |
1020 | 1044 | { |
1021 | 1045 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1046 | + Remove-Module ImportTrustedManifestWithWildcardModFnExport_System32 -Force -ErrorAction SilentlyContinue |
1022 | 1047 | } |
1023 | 1048 |
|
1024 | 1049 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1050,6 +1075,7 @@ try |
1050 | 1075 | finally |
1051 | 1076 | { |
1052 | 1077 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1078 | + Remove-Module ImportTrustedManifestWithCmdletExport_System32 -Force -ErrorAction SilentlyContinue |
1053 | 1079 | } |
1054 | 1080 |
|
1055 | 1081 | $module.ExportedCommands.Count | Should -Be 0 |
@@ -1092,6 +1118,7 @@ try |
1092 | 1118 | finally |
1093 | 1119 | { |
1094 | 1120 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1121 | + Remove-Module ImportTrustedManifestWithTwoMods_System32 -Force -ErrorAction SilentlyContinue |
1095 | 1122 | } |
1096 | 1123 |
|
1097 | 1124 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1124,6 +1151,7 @@ try |
1124 | 1151 | finally |
1125 | 1152 | { |
1126 | 1153 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1154 | + Remove-Module ImportTrustedManifestWithExportFn_System32 -Force -ErrorAction SilentlyContinue |
1127 | 1155 | } |
1128 | 1156 |
|
1129 | 1157 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1155,6 +1183,7 @@ try |
1155 | 1183 | finally |
1156 | 1184 | { |
1157 | 1185 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1186 | + Remove-Module ImportTrustedManifestWithNestedModsAndFnExport_System32 -Force -ErrorAction SilentlyContinue |
1158 | 1187 | } |
1159 | 1188 |
|
1160 | 1189 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1186,6 +1215,7 @@ try |
1186 | 1215 | finally |
1187 | 1216 | { |
1188 | 1217 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1218 | + Remove-Module ImportTrustedManifestWithNestedModsAndNoFnExport_System32 -Force -ErrorAction SilentlyContinue |
1189 | 1219 | } |
1190 | 1220 |
|
1191 | 1221 | $module.ExportedCommands.Count | Should -Be 0 |
@@ -1216,6 +1246,7 @@ try |
1216 | 1246 | finally |
1217 | 1247 | { |
1218 | 1248 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1249 | + Remove-Module ImportTrustedManifestWithNestedModsAndNoExtNoFnExport_System32 -Force -ErrorAction SilentlyContinue |
1219 | 1250 | } |
1220 | 1251 |
|
1221 | 1252 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1260,6 +1291,7 @@ try |
1260 | 1291 | finally |
1261 | 1292 | { |
1262 | 1293 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1294 | + Remove-Module ImportTrustedManifestWithDotSourceModAndFnExport_System32 -Force -ErrorAction SilentlyContinue |
1263 | 1295 | } |
1264 | 1296 |
|
1265 | 1297 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1305,6 +1337,7 @@ try |
1305 | 1337 | finally |
1306 | 1338 | { |
1307 | 1339 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1340 | + Remove-Module ImportUntrustedManifestWithNoFnExport -Force -ErrorAction SilentlyContinue |
1308 | 1341 | } |
1309 | 1342 |
|
1310 | 1343 | $module.ExportedCommands.Count | Should -Be 2 |
@@ -1335,6 +1368,7 @@ try |
1335 | 1368 | finally |
1336 | 1369 | { |
1337 | 1370 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1371 | + Remove-Module ImportUntrustedManifestWithFnExport -Force -ErrorAction SilentlyContinue |
1338 | 1372 | } |
1339 | 1373 |
|
1340 | 1374 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1365,6 +1399,7 @@ try |
1365 | 1399 | finally |
1366 | 1400 | { |
1367 | 1401 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1402 | + Remove-Module ImportUnTrustedModuleWithNoFnExport -Force -ErrorAction SilentlyContinue |
1368 | 1403 | } |
1369 | 1404 |
|
1370 | 1405 | $module.ExportedCommands.Count | Should -Be 2 |
@@ -1395,6 +1430,7 @@ try |
1395 | 1430 | finally |
1396 | 1431 | { |
1397 | 1432 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1433 | + Remove-Module ImportUnTrustedModuleWithFnExport -Force -ErrorAction SilentlyContinue |
1398 | 1434 | } |
1399 | 1435 |
|
1400 | 1436 | $module.ExportedCommands.Count | Should -Be 1 |
@@ -1518,6 +1554,7 @@ try |
1518 | 1554 | finally |
1519 | 1555 | { |
1520 | 1556 | Invoke-LanguageModeTestingSupportCmdlet -RevertLockdownMode -EnableFullLanguageMode |
| 1557 | + Remove-Module UntrustedScriptFoo -Force -ErrorAction SilentlyContinue |
1521 | 1558 | } |
1522 | 1559 |
|
1523 | 1560 | $result | Should -BeExactly "ConstrainedLanguage" |
|
0 commit comments