Skip to content

Commit

Permalink
Merge pull request #34 from PlagueHO/Issue-33
Browse files Browse the repository at this point in the history
Prevent ResourceHelper and Common cmdlets from being exported - Fixes #33
  • Loading branch information
PlagueHO authored Jun 1, 2017
2 parents 8c9031e + 1bedded commit f07eb8b
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
Original file line number Diff line number Diff line change
@@ -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 `
Expand Down
2 changes: 1 addition & 1 deletion Modules/xDFS/xDFS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '*'
Expand Down
47 changes: 47 additions & 0 deletions Tests/Integration/ModuleConflict.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit f07eb8b

Please sign in to comment.