Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent ResourceHelper and Common cmdlets from being exported - Fixes #33 #34

Merged
merged 5 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}