diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cfaa48..248fbdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Fixed xDFSNamespaceServerConfiguration by converting LocalHost to ComputerName instead. +- Added integration test to test for conflicts with other common resource kit modules. +- Prevented ResourceHelper and Common module cmdlets from being exported to resolve + conflicts with other resource modules. ## 3.2.0.0 diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceFolder/MSFT_xDFSNamespaceFolder.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceFolder/MSFT_xDFSNamespaceFolder.psm1 index f2b3230..7888191 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceFolder/MSFT_xDFSNamespaceFolder.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceFolder/MSFT_xDFSNamespaceFolder.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceRoot/MSFT_xDFSNamespaceRoot.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceRoot/MSFT_xDFSNamespaceRoot.psm1 index 053a722..cb21e41 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceRoot/MSFT_xDFSNamespaceRoot.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceRoot/MSFT_xDFSNamespaceRoot.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceServerConfiguration/MSFT_xDFSNamespaceServerConfiguration.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceServerConfiguration/MSFT_xDFSNamespaceServerConfiguration.psm1 index 50c2c99..cd8c171 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceServerConfiguration/MSFT_xDFSNamespaceServerConfiguration.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSNamespaceServerConfiguration/MSFT_xDFSNamespaceServerConfiguration.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroup/MSFT_xDFSReplicationGroup.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroup/MSFT_xDFSReplicationGroup.psm1 index a0daea0..efb6528 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroup/MSFT_xDFSReplicationGroup.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroup/MSFT_xDFSReplicationGroup.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupConnection/MSFT_xDFSReplicationGroupConnection.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupConnection/MSFT_xDFSReplicationGroupConnection.psm1 index 3876d5e..200b424 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupConnection/MSFT_xDFSReplicationGroupConnection.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupConnection/MSFT_xDFSReplicationGroupConnection.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupFolder/MSFT_xDFSReplicationGroupFolder.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupFolder/MSFT_xDFSReplicationGroupFolder.psm1 index 56114c9..1cd1b58 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupFolder/MSFT_xDFSReplicationGroupFolder.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupFolder/MSFT_xDFSReplicationGroupFolder.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupMembership/MSFT_xDFSReplicationGroupMembership.psm1 b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupMembership/MSFT_xDFSReplicationGroupMembership.psm1 index 2cd6264..8258399 100644 --- a/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupMembership/MSFT_xDFSReplicationGroupMembership.psm1 +++ b/Modules/xDFS/DSCResources/MSFT_xDFSReplicationGroupMembership/MSFT_xDFSReplicationGroupMembership.psm1 @@ -1,7 +1,9 @@ -$script:ResourceRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) +$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the xCertificate Resource Module (to import the common modules) -Import-Module -Name (Join-Path -Path $script:ResourceRootPath -ChildPath 'xDFS.psd1') +# Import the Certificate Resource Helper Module +Import-Module -Name (Join-Path -Path $modulePath ` + -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` + -ChildPath 'DFSDsc.ResourceHelper.psm1')) # Import Localization Strings $localizedData = Get-LocalizedData ` diff --git a/Modules/xDFS/xDFS.psd1 b/Modules/xDFS/xDFS.psd1 index f1b3a92..0dd6016 100644 --- a/Modules/xDFS/xDFS.psd1 +++ b/Modules/xDFS/xDFS.psd1 @@ -27,7 +27,7 @@ ProcessorArchitecture = 'None' # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - NestedModules = @('Modules\DFSDsc.ResourceHelper\DFSDsc.ResourceHelper.psm1') + # NestedModules = @() # Functions to export from this module FunctionsToExport = '*' diff --git a/Tests/Integration/ModuleConflict.Tests.ps1 b/Tests/Integration/ModuleConflict.Tests.ps1 new file mode 100644 index 0000000..a475bb5 --- /dev/null +++ b/Tests/Integration/ModuleConflict.Tests.ps1 @@ -0,0 +1,47 @@ +$script:DSCModuleName = 'xDFS' +<# + These integration tests ensure that exported cmdlets names do not conflict + with any other names that are exposed by other common resource kit modules. +#> +$script:ModulesToTest = @( 'xNetworking','xComputerManagement' ) + +#region HEADER +# Integration Test Template Version: 1.1.0 +[string] $script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\xDFS' + +if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +{ + & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) +} + +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName 'All' ` + -TestType Integration + +#endregion + +# Using try/finally to always cleanup even if something awful happens. +try +{ + Describe "$($script:DSCModuleName)_CommonModuleConflict" { + + foreach ($moduleToTest in $script:ModulesToTest) + { + It "Should be able to install DSC Resource module '$moduleToTest'" { + { + Install-Module -Name $moduleToTest -ErrorAction Stop + } | Should Not Throw + } + } + } +} +finally +{ + #region FOOTER + Restore-TestEnvironment -TestEnvironment $TestEnvironment + #endregion +}