Skip to content
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
10 changes: 0 additions & 10 deletions .vscode/RunAllTests.ps1

This file was deleted.

19 changes: 0 additions & 19 deletions .vscode/launch.json

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Enabled PSSA rule violations to fail build - Fixes [Issue #6](https://github.com/PlagueHO/FileContentDsc/issues/6).
- Updated tests to meet Pester v4 standard.
- Added Open Code of Conduct.
- Refactored module folder structure to move resource
to root folder of repository and remove test harness - Fixes [Issue #11](https://github.com/PlagueHO/FileContentDsc/issues/11).

## 1.0.0.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set the `Level` entry in the [Logging] section to `Information`
in the file `c:\myapp\myapp.ini`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost'
)

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
IniSettingsFile SetLogging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set the `ConnectionString` entry in the [Database] section to the password
provided in the $Secret credential object in the file `c:\myapp\myapp.ini`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',

[Parameter()]
[ValidateNotNullorEmpty()]
[PSCredential]
Expand All @@ -19,7 +17,7 @@ Configuration Example

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
IniSettingsFile SetConnectionString
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Remove all `Core.Logging` keys in the file `c:\myapp\myapp.conf`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost'
)

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
KeyValuePairFile RemoveCoreLogging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set all `Core.Logging` keys to `Information` or add it
if it is missing in the file `c:\myapp\myapp.conf`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost'
)

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
KeyValuePairFile SetCoreLogging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set all `Core.Password` keys to the password provided in the $Secret
credential object or add it if it is missing in the file `c:\myapp\myapp.conf`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',

[Parameter()]
[ValidateNotNullorEmpty()]
[PSCredential]
Expand All @@ -19,7 +17,7 @@ Configuration Example

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
KeyValuePairFile SetCorePassword
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set all occrurances of the string `%secret%` to be the value in
the password set in the parameter $Secret PSCredential object
in the file `c:\inetpub\wwwroot\default.htm`.
Expand All @@ -8,10 +10,6 @@ Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',

[Parameter()]
[ValidateNotNullorEmpty()]
[PSCredential]
Expand All @@ -20,7 +18,7 @@ Configuration Example

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
ReplaceText SetSecretText
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
.DESCRIPTION
Set all occrurances of the string `%appname%` to be Awesome App`
in the file `c:\inetpub\wwwroot\default.htm`.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost'
)

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
ReplaceText SetText
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#Requires -module FileContentDsc

<#
.EXAMPLE
Set all occrurances of a string matching the regular expression
.DESCRIPTION
Set all occrurances of a string matching the regular expression
`<img src=['``"][a-zA-Z0-9.]*['``"]>` with the text `<img src="imgs/placeholder.jpg">`
in the file `c:\inetpub\wwwroot\default.htm`
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost'
)

Import-DSCResource -ModuleName FileContentDsc

Node $NodeName
Node localhost
{
ReplaceText SetTextWithRegex
{
Expand Down
File renamed without changes.
47 changes: 37 additions & 10 deletions Tests/Integration/DSR_IniSettingsFile.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param ()

Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1')
$script:DSCModuleName = 'FileContentDsc'
$script:DSCResourceName = 'DSR_IniSettingsFile'

$script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceModuleName 'FileContentDsc' `
-DscResourceName 'DSR_IniSettingsFile' `
-TestType 'Integration'
#region HEADER
# Integration Test Template Version: 1.1.1
[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)

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 $script:DSCResourceName `
-TestType Integration
#endregion

try
{
Expand Down Expand Up @@ -84,8 +98,14 @@ SettingThree=Value3
-OutputPath $TestDrive `
-ConfigurationData $configData

Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force -Verbose
} | Should -Not -Throw
Start-DscConfiguration `
-Path $TestDrive `
-ComputerName localhost `
-Wait `
-Verbose `
-Force `
-ErrorAction Stop
} | Should -Not -Throw
}

It 'Should be able to call Get-DscConfiguration without throwing' {
Expand Down Expand Up @@ -146,7 +166,13 @@ SettingThree=Value3
-OutputPath $TestDrive `
-ConfigurationData $configData

Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force -Verbose
Start-DscConfiguration `
-Path $TestDrive `
-ComputerName localhost `
-Wait `
-Verbose `
-Force `
-ErrorAction Stop
} | Should -Not -Throw
}

Expand Down Expand Up @@ -180,6 +206,7 @@ SettingThree=Value3
}
finally
{
Exit-DscResourceTestEnvironment -TestEnvironment $script:testEnvironment
Remove-Module -Name CommonTestHelper
#region FOOTER
Restore-TestEnvironment -TestEnvironment $TestEnvironment
#endregion
}
2 changes: 1 addition & 1 deletion Tests/Integration/DSR_IniSettingsFile.config.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param
param
(
[Parameter(Mandatory = $true)]
[String]
Expand Down
Loading