Skip to content

Commit 9b00d76

Browse files
authored
Update resource module to standard (#15)
- Changes to xBitlocker - Added Codecov support. - Updated appveyor.yml to use the one in template. - Added folders for future unit and integration tests. - Added Visual Studio Code formatting settings. - Added .gitignore file. - Added markdown lint rules. - Fixed encoding on README.md. - Added `PowerShellVersion = '4.0'`, and updated copyright information, in the module manifest.
1 parent f718d81 commit 9b00d76

File tree

10 files changed

+380
-113
lines changed

10 files changed

+380
-113
lines changed

.codecov.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
codecov:
2+
notify:
3+
require_ci_to_pass: no
4+
5+
comment:
6+
layout: "reach, diff"
7+
behavior: default
8+
9+
coverage:
10+
range: 50..80
11+
round: down
12+
precision: 0
13+
14+
status:
15+
project:
16+
default:
17+
# Set the overall project code coverage requirement to 70%
18+
target: 70
19+
patch:
20+
default:
21+
# Set the pull request requirement to not regress overall coverage by more than 5%
22+
# and let codecov.io set the goal for the code changed in the patch.
23+
target: auto
24+
threshold: 5

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DSCResource.Tests
2+
.vs
3+
.vscode
4+
node_modules

.markdownlint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"default": true,
3+
"MD029": {
4+
"style": "one"
5+
},
6+
"MD013": true,
7+
"MD024": false,
8+
"MD034": false,
9+
"no-hard-tabs": true
10+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"powershell.codeFormatting.openBraceOnSameLine": false,
3+
"powershell.codeFormatting.newLineAfterOpenBrace": false,
4+
"powershell.codeFormatting.newLineAfterCloseBrace": true,
5+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
6+
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
7+
"powershell.codeFormatting.whitespaceAroundOperator": true,
8+
"powershell.codeFormatting.whitespaceAfterSeparator": true,
9+
"powershell.codeFormatting.ignoreOneLineBlock": false,
10+
"powershell.codeFormatting.preset": "Custom",
11+
"files.trimTrailingWhitespace": true,
12+
"files.insertFinalNewline": true
13+
}

README.md

Lines changed: 80 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
[![Build status](https://ci.appveyor.com/api/projects/status/wi5i60tojfd7056b/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xbitlocker/branch/master)
2-
31
# xBitlocker
2+
43
The **xBitlocker** module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team.
54
This module contains the **xBLAutoBitlocker, xBLBitlocker, xBLTpm** resources.
65
This DSC Module allows you to configure Bitlocker on a single disk, configure a TPM chip, or automatically enable Bitlocker on multiple disks.
76

87
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
98
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
109

10+
## Branches
11+
12+
### master
13+
14+
[![Build status](https://ci.appveyor.com/api/projects/status/wi5i60tojfd7056b/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xBitlocker/branch/master)
15+
[![codecov](https://codecov.io/gh/PowerShell/xBitlocker/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xBitlocker/branch/master)
16+
17+
This is the branch containing the latest release -
18+
no contributions should be made directly to this branch.
19+
20+
### dev
21+
22+
[![Build status](https://ci.appveyor.com/api/projects/status/wi5i60tojfd7056b/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/xBitlocker/branch/dev)
23+
[![codecov](https://codecov.io/gh/PowerShell/xBitlocker/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xBitlocker/branch/dev)
24+
25+
This is the development branch
26+
to which contributions should be proposed by contributors as pull requests.
27+
This development branch will periodically be merged to the master branch,
28+
and be released to [PowerShell Gallery](https://www.powershellgallery.com/).
29+
1130
## Contributing
1231
Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).
1332

@@ -17,9 +36,9 @@ To install **xBitlocker** module
1736

1837
* Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder
1938

20-
To confirm installation:
39+
To confirm installation:
2140

22-
* Run **Get-DSCResource** to see that **xBLAutoBitlocker, xBLBitlocker, xBLTpm** are among the DSC Resources listed
41+
* Run **Get-DSCResource** to see that **xBLAutoBitlocker, xBLBitlocker, xBLTpm** are among the DSC Resources listed
2342

2443
## Requirements
2544

@@ -40,68 +59,78 @@ It does not work on Operating System drives.
4059
**xBLAutoBitlocker** has the following properties.
4160
Where no description is listed, properties correspond directly to [Enable-Bitlocker](http://technet.microsoft.com/en-us/library/jj649837.aspx) parameters.
4261

43-
* *DriveType:The type of volume, as reported by Get-Volume, to auto apply Bitlocker to
62+
* *DriveType:The type of volume, as reported by Get-Volume, to auto apply Bitlocker to
4463
* *PrimaryProtector:The primary protector type to be used for AutoBitlocker.
45-
Valid values are: "AdAccountOrGroupProtector", "PasswordProtector", "Pin", "RecoveryKeyProtector", "RecoveryPasswordProtector", "StartupKeyProtector", or "TpmProtector"
46-
* MinDiskCapacityGB:If specified, only disks this size or greater will auto apply Bitlocker
47-
* AutoUnlock:Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
48-
* AdAccountOrGroup
49-
* AdAccountOrGroupProtector
50-
* EncryptionMethod
51-
* HardwareEncryption
52-
* Password
53-
* PasswordProtector
54-
* Pin
55-
* RecoveryKeyPath
56-
* RecoveryKeyProtector
57-
* RecoveryPasswordProtector
58-
* Service
59-
* SkipHardwareTest
60-
* StartupKeyPath
61-
* StartupKeyProtector
62-
* TpmProtector
63-
* UsedSpaceOnly
64+
Valid values are: "AdAccountOrGroupProtector", "PasswordProtector", "Pin", "RecoveryKeyProtector", "RecoveryPasswordProtector", "StartupKeyProtector", or "TpmProtector"
65+
* MinDiskCapacityGB:If specified, only disks this size or greater will auto apply Bitlocker
66+
* AutoUnlock:Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
67+
* AdAccountOrGroup
68+
* AdAccountOrGroupProtector
69+
* EncryptionMethod
70+
* HardwareEncryption
71+
* Password
72+
* PasswordProtector
73+
* Pin
74+
* RecoveryKeyPath
75+
* RecoveryKeyProtector
76+
* RecoveryPasswordProtector
77+
* Service
78+
* SkipHardwareTest
79+
* StartupKeyPath
80+
* StartupKeyProtector
81+
* TpmProtector
82+
* UsedSpaceOnly
6483

6584
**xBLBitlocker** has the following properties.
6685
Where no description is listed, properties correspond directly to [Enable-Bitlocker](http://technet.microsoft.com/en-us/library/jj649837.aspx) parameters.
6786

68-
* *MountPoint:The MountPoint name as reported in Get-BitLockerVolume
87+
* *MountPoint:The MountPoint name as reported in Get-BitLockerVolume
6988
* *PrimaryProtector:The primary protector type to be used for AutoBitlocker.
70-
Valid values are: "AdAccountOrGroupProtector", "PasswordProtector", "Pin", "RecoveryKeyProtector", "RecoveryPasswordProtector", "StartupKeyProtector", or "TpmProtector"
71-
* AutoUnlock:Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
89+
Valid values are: "AdAccountOrGroupProtector", "PasswordProtector", "Pin", "RecoveryKeyProtector", "RecoveryPasswordProtector", "StartupKeyProtector", or "TpmProtector"
90+
* AutoUnlock:Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
7291
* AllowImmediateReboot:Whether the computer can be immediately rebooted after enabling Bitlocker on an OS drive.
7392
Defaults to false.
7493

75-
* AdAccountOrGroup
76-
* AdAccountOrGroupProtector
77-
* EncryptionMethod
78-
* HardwareEncryption
79-
* Password
80-
* PasswordProtector
81-
* Pin
82-
* RecoveryKeyPath
83-
* RecoveryKeyProtector
84-
* RecoveryPasswordProtector
85-
* Service
86-
* SkipHardwareTest
87-
* StartupKeyPath
88-
* StartupKeyProtector
89-
* TpmProtector
90-
* UsedSpaceOnly
94+
* AdAccountOrGroup
95+
* AdAccountOrGroupProtector
96+
* EncryptionMethod
97+
* HardwareEncryption
98+
* Password
99+
* PasswordProtector
100+
* Pin
101+
* RecoveryKeyPath
102+
* RecoveryKeyProtector
103+
* RecoveryPasswordProtector
104+
* Service
105+
* SkipHardwareTest
106+
* StartupKeyPath
107+
* StartupKeyProtector
108+
* TpmProtector
109+
* UsedSpaceOnly
91110

92111
**xBLTpm** is used to initialize a TPM chip using [Initialize-TPM](http://technet.microsoft.com/en-us/library/jj603112.aspx).
93112
**xBLTpm** has the following properties.
94113

95-
* *Identity:Not actually used, so could be anything
96-
* AllowClear:Indicates that the provisioning process clears the TPM, if necessary, to move the TPM closer to complying with Windows Server® 2012 standards
114+
* *Identity:Not actually used, so could be anything
115+
* AllowClear:Indicates that the provisioning process clears the TPM, if necessary, to move the TPM closer to complying with Windows Server® 2012 standards
97116
* AllowPhysicalPresence:Indicates that the provisioning process may send physical presence commands that require a user to be present in order to continue.
98117

99-
* AllowImmediateReboot:Whether the computer can rebooted immediately after initializing the TPM
118+
* AllowImmediateReboot:Whether the computer can rebooted immediately after initializing the TPM
100119

101120
## Versions
102121

103122
### Unreleased
123+
104124
* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
125+
* Added Codecov support.
126+
* Updated appveyor.yml to use the one in template.
127+
* Added folders for future unit and integration tests.
128+
* Added Visual Studio Code formatting settings.
129+
* Added .gitignore file.
130+
* Added markdown lint rules.
131+
* Fixed encoding on README.md.
132+
* Added `PowerShellVersion = '4.0'`, and updated copyright information, in the
133+
module manifest.
105134

106135
### 1.1.0.0
107136

@@ -116,10 +145,10 @@ Defaults to false.
116145

117146
### 1.0.0.0
118147

119-
* Initial release with the following resources
120-
* xBLAutoBitlocker
121-
* xBLBitlocker
122-
* xBLTpm
148+
* Initial release with the following resources
149+
* xBLAutoBitlocker
150+
* xBLBitlocker
151+
* xBLTpm
123152

124153
## Examples
125154

@@ -132,4 +161,4 @@ The example code for ConfigureBitlockerOnOSDrive is located in [`ConfigureBitloc
132161

133162
Enables Bitlocker on an Operating System drive, and automatically enables Bitlocker on all drives of type 'Fixed'.
134163
The example code for ConfigureBitlockerAndAutoBitlocker is located in [`ConfigureBitlockerAndAutoBitlocker.ps1`](Examples/ConfigureBitlockerAndAutoBitlocker/ConfigureBitlockerAndAutoBitlocker.ps1).
135-
164+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<#
2+
.Synopsis
3+
DSC Configuration Template for DSC Resource Integration tests.
4+
.DESCRIPTION
5+
To Use:
6+
1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_Firewall.config.ps1)
7+
2. Customize TODO sections.
8+
9+
.NOTES
10+
#>
11+
12+
# Integration Test Config Template Version: 1.0.1
13+
14+
# TODO: Modify ResourceName (e.g. MSFT_Firewall_config)
15+
configuration <ResourceName>_config {
16+
# TODO: Modify ModuleName (e.g. NetworkingDsc)
17+
Import-DscResource -ModuleName '<ModuleName>'
18+
node localhost {
19+
# TODO: Modify ResourceFriendlyName (e.g. Firewall_Integration_Test)
20+
<ResourceFriendlyName> Integration_Test {
21+
# TODO: Fill Configuration Code Here
22+
}
23+
}
24+
}
25+
26+
# TODO: (Optional): Add More Configuration Templates
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<#
2+
.Synopsis
3+
Template for creating DSC Resource Integration Tests
4+
.DESCRIPTION
5+
To Use:
6+
1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_Firewall.Integration.tests.ps1)
7+
2. Customize TODO sections.
8+
3. Create test DSC Configuration file <ResourceName>.config.ps1 (e.g. MSFT_Firewall.config.ps1) from integration_config_template.ps1 file.
9+
10+
.NOTES
11+
Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into
12+
DSCResource.Tools in Future and therefore should not be altered if possible.
13+
#>
14+
15+
# TODO: Customize these parameters...
16+
$script:DSCModuleName = '<ModuleName>' # Example NetworkingDsc
17+
$script:DSCResourceName = '<ResourceName>' # Example MSFT_Firewall
18+
19+
#region HEADER
20+
# Integration Test Template Version: 1.2.1
21+
[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
22+
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or `
23+
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
24+
{
25+
& git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))
26+
}
27+
28+
Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force
29+
$TestEnvironment = Initialize-TestEnvironment `
30+
-DSCModuleName $script:DSCModuleName `
31+
-DSCResourceName $script:DSCResourceName `
32+
-TestType Integration
33+
34+
#endregion
35+
36+
# TODO: Other Init Code Goes Here...
37+
38+
# Using try/finally to always cleanup.
39+
try
40+
{
41+
#region Integration Tests
42+
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1"
43+
. $configFile
44+
45+
Describe "$($script:DSCResourceName)_Integration" {
46+
#region DEFAULT TESTS
47+
It 'Should compile and apply the MOF without throwing' {
48+
{
49+
& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive
50+
51+
$startDscConfigurationParameters = @{
52+
Path = $TestDrive
53+
ComputerName = 'localhost'
54+
Wait = $true
55+
Verbose = $true
56+
Force = $true
57+
ErrorAction = 'Stop'
58+
}
59+
60+
Start-DscConfiguration @startDscConfigurationParameters
61+
} | Should -Not -Throw
62+
}
63+
64+
It 'Should be able to call Get-DscConfiguration without throwing' {
65+
{
66+
Get-DscConfiguration -Verbose -ErrorAction Stop
67+
} | Should -Not -Throw
68+
}
69+
#endregion
70+
71+
It 'Should have set the resource and all the parameters should match' {
72+
# TODO: Validate the Config was Set Correctly Here...
73+
}
74+
}
75+
#endregion
76+
77+
}
78+
finally
79+
{
80+
#region FOOTER
81+
82+
Restore-TestEnvironment -TestEnvironment $TestEnvironment
83+
84+
#endregion
85+
86+
# TODO: Other Optional Cleanup Code Goes Here...
87+
}

0 commit comments

Comments
 (0)