From 87bf3fcddaa496c8b6289c345efe63c4d3fe8b0a Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 29 Dec 2019 22:38:43 +0100 Subject: [PATCH] Added continuous delivery with a new CI pipeline (#549) --- .MetaTestOptIn.json | 11 - .codecov.yml | 24 - .gitattributes | 6 + .../ISSUE_TEMPLATE/Problem_with_resource.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 22 +- .gitignore | 2 +- .markdownlint.json | 10 + .vscode/RunGlobalTests.ps1 | 11 - .vscode/RunPesterTests.ps1 | 9 - .vscode/analyzersettings.psd1 | 15 +- .vscode/settings.json | 28 +- CHANGELOG.md | 433 ++-------------- CODE_OF_CONDUCT.md | 3 + GitVersion.yml | 26 + HISTORIC_CHANGELOG.md | 392 ++++++++++++++ LICENSE | 4 +- README.md | 34 +- RequiredModules.psd1 | 20 + Resolve-Dependency.ps1 | 289 +++++++++++ Resolve-Dependency.psd1 | 5 + ..._xWebAppPoolDefaults.Integration.Tests.ps1 | 115 ----- Tests/TestHelper/CommonTestHelper.psm1 | 135 ----- appveyor.yml | 43 -- azure-pipelines.yml | 170 +++++++ build.ps1 | 353 +++++++++++++ build.yaml | 88 ++++ .../MSFT_WebApplicationHandler.psm1 | 0 .../MSFT_WebApplicationHandler.schema.mof | 0 .../MSFT_WebApplicationHandler.strings.psd1 | 0 .../MSFT_xIIsHandler/MSFT_xIisHandler.psm1 | 0 .../MSFT_xIisHandler.schema.mof | 0 .../en-US/MSFT_xIIsHandler.strings.psd1 | 1 - .../MSFT_xIisFeatureDelegation.psm1 | 0 .../MSFT_xIisFeatureDelegation.schema.mof | 0 .../MSFT_xIisFeatureDelegation.strings.psd1 | 1 - .../MSFT_xIisLogging/MSFT_xIisLogging.psm1 | 0 .../MSFT_xIisLogging.schema.mof | 0 .../en-US/MSFT_xIisLogging.strings.psd1 | 0 .../MSFT_xIisMimeTypeMapping.psm1 | 0 .../MSFT_xIisMimeTypeMapping.schema.mof | 0 .../MSFT_xIisMimeTypeMapping.strings.psd1 | 1 - .../MSFT_xIisModule/MSFT_xIisModule.psm1 | 0 .../MSFT_xIisModule.schema.mof | 0 .../en-US/MSFT_xIisModule.strings.psd1 | 0 .../MSFT_xIisModule/xIisModuleDesigner.ps1 | 18 +- .../MSFT_xSslSettings/MSFT_xSslSettings.psm1 | 0 .../MSFT_xSslSettings.schema.mof | 0 .../en-US/MSFT_xSslSettings.strings.psd1 | 0 .../MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 | 64 +-- .../MSFT_xWebAppPool.schema.mof | 0 .../en-US/MSFT_xWebAppPool.strings.psd1 | 0 .../MSFT_xWebAppPoolDefaults.psm1 | 7 +- .../MSFT_xWebAppPoolDefaults.schema.mof | 0 .../MSFT_xWebAppPoolDefaults.strings.psd1 | 1 - .../MSFT_xWebApplication.psm1 | 8 +- .../MSFT_xWebApplication.schema.mof | 0 .../en-US/MSFT_xWebApplication.strings.psd1 | 1 - .../MSFT_xWebConfigKeyValue.psm1 | 0 .../MSFT_xWebConfigKeyValue.schema.mof | 0 .../MSFT_xWebConfigKeyValue.strings.psd1 | 0 .../MSFT_xWebConfigProperty.psm1 | 10 +- .../MSFT_xWebConfigProperty.schema.mof | 0 .../MSFT_xWebConfigProperty.strings.psd1 | 0 .../MSFT_xWebConfigPropertyCollection.psm1 | 0 ...FT_xWebConfigPropertyCollection.schema.mof | 0 ..._xWebConfigPropertyCollection.strings.psd1 | 0 .../MSFT_xWebSite/MSFT_xWebSite.psm1 | 173 ++++--- .../MSFT_xWebSite/MSFT_xWebSite.schema.mof | 0 .../en-US/MSFT_xWebSite.strings.psd1 | 6 +- .../MSFT_xWebSiteDefaults.psm1 | 0 .../MSFT_xWebSiteDefaults.schema.mof | 0 .../en-US/MSFT_xWebSiteDefaults.strings.psd1 | 1 - .../MSFT_xWebVirtualDirectory.psm1 | 0 .../MSFT_xWebVirtualDirectory.schema.mof | 0 .../MSFT_xWebVirtualDirectory.strings.psd1 | 0 .../Sample_EndToEndxWebAdministration.ps1 | 0 .../Sample_WebApplicationHandler.ps1 | 0 ...eDelegation_IisConfigurationPathFormat.ps1 | 0 ...sFeatureDelegation_IisModulePathFormat.ps1 | 0 .../Sample_xIisHandler_Remove32Bit.ps1 | 0 .../Sample_xIisLogging_Rollover.ps1 | 0 .../Sample_xIisLogging_Truncate.ps1 | 0 ...Sample_xIisMimeTypeMapping_RemoveVideo.ps1 | 0 .../Sample_xIisServerDefaults.ps1 | 0 .../Sample_xSslSettings_RequireCert.ps1 | 0 .../xWebAppPool/Sample_xWebAppPool.ps1 | 0 .../Sample_xWebAppPoolDefaults.ps1 | 0 .../Sample_xWebApplication.ps1 | 0 ...mple_xWebApplication_NewWebApplication.ps1 | 0 ...ample_xWebConfigKeyValue_AddAppSetting.ps1 | 0 ...le_xWebConfigKeyValue_RemoveAppSetting.ps1 | 0 .../Sample_xWebConfigProperty_Add.ps1 | 0 .../Sample_xWebConfigProperty_Remove.ps1 | 0 ...ample_xWebConfigPropertyCollection_Add.ps1 | 0 ...le_xWebConfigPropertyCollection_Remove.ps1 | 0 .../xWebSite/Sample_xWebSite_NewWebsite.ps1 | 0 ...ebSite_NewWebsiteFromConfigurationData.ps1 | 0 ...ite_NewWebsite_UsingCertificateSubject.ps1 | 0 ..._NewWebsite_UsingCertificateThumbprint.ps1 | 0 .../Sample_xWebSite_RemoveDefault.ps1 | 0 .../xWebSite/Sample_xWebSite_StopDefault.ps1 | 0 .../xWebSite/Sample_xWebSite_WithSSLFlags.ps1 | 0 .../Sample_xWebSiteDefaults.ps1 | 0 ...ebVirtualDirectory_NewVirtualDirectory.ps1 | 0 .../xWebAdministration.Common.strings.psd1 | 0 .../xWebAdministration.Common.psd1 | 60 +++ .../xWebAdministration.Common.psm1 | 50 +- source/build.psd1 | 4 + .../en-US/about_xWebAdministration.help.txt | 26 + source/xWebAdministration.psd1 | 81 +++ .../MSFT_WebApplicationHandler.Config.ps1 | 0 ...ebApplicationHandler.Integration.Tests.ps1 | 52 +- .../MSFT_XIISLogging.Integration.Tests.ps1 | 56 +- .../Integration/MSFT_XIISLogging.config.ps1 | 0 ...IISFeatureDelegation.Integration.Tests.ps1 | 47 +- .../MSFT_xIISFeatureDelegation.config.ps1 | 0 .../MSFT_xIISHandler.Integration.Tests.ps1 | 49 +- .../Integration/MSFT_xIISHandler.config.ps1 | 0 ..._xIISMimeTypeMapping.Integration.Tests.ps1 | 57 +-- .../MSFT_xIISMimeTypeMapping.config.ps1 | 0 .../MSFT_xSslSettings.Integration.Tests.ps1 | 55 +- .../Integration/MSFT_xSslSettings.config.ps1 | 0 .../Integration/MSFT_xSslSettings.config.psd1 | 0 .../MSFT_xWebAppPool.Integration.Tests.ps1 | 52 +- .../Integration/MSFT_xWebAppPool.config.ps1 | 0 ..._xWebAppPoolDefaults.Integration.Tests.ps1 | 227 +++++++++ .../MSFT_xWebAppPoolDefaults.config.ps1 | 0 ...MSFT_xWebApplication.Integration.Tests.ps1 | 64 ++- .../MSFT_xWebApplication.config.ps1 | 0 .../MSFT_xWebApplication.config.psd1 | 0 ...T_xWebConfigKeyValue.Integration.Tests.ps1 | 51 +- .../MSFT_xWebConfigKeyValue.config.ps1 | 0 ...T_xWebConfigProperty.Integration.Tests.ps1 | 42 +- .../MSFT_xWebConfigProperty.config.ps1 | 0 ...igPropertyCollection.Integration.Tests.ps1 | 43 +- ...FT_xWebConfigPropertyCollection.config.ps1 | 0 .../MSFT_xWebSite.Integration.Tests.ps1 | 68 +-- .../Integration/MSFT_xWebSite.config.ps1 | 0 .../Integration/MSFT_xWebSite.config.psd1 | 0 ...SFT_xWebSiteDefaults.Integration.Tests.ps1 | 45 +- .../MSFT_xWebSiteDefaults.config.ps1 | 0 ...xWebVirtualDirectory.Integration.Tests.ps1 | 65 ++- .../MSFT_xWebVirtualDirectory.config.ps1 | 0 .../MSFT_xWebVirtualDirectory.config.psd1 | 0 .../MockWebAdministrationWindowsFeature.psm1 | 478 +++++++++--------- tests/TestHelper/CommonTestHelper.psm1 | 121 +++++ .../Unit/MSFT_WebApplicationHandler.Tests.ps1 | 45 +- .../Unit/MSFT_xIISFeatureDelegation.Tests.ps1 | 58 ++- .../Unit/MSFT_xIISHandler.Tests.ps1 | 56 +- .../Unit/MSFT_xIISLogging.Tests.ps1 | 62 +-- .../Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 | 50 +- .../Unit/MSFT_xSslSettings.Tests.ps1 | 61 +-- .../Unit/MSFT_xWebAppPool.Tests.ps1 | 58 ++- .../Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 | 108 +++- .../Unit/MSFT_xWebApplication.Tests.ps1 | 81 +-- .../Unit/MSFT_xWebConfigKeyValue.Tests.ps1 | 84 +-- .../Unit/MSFT_xWebConfigProperty.Tests.ps1 | 99 ++-- ...SFT_xWebConfigPropertyCollection.Tests.ps1 | 93 ++-- .../Unit/MSFT_xWebVirtualDirectory.Tests.ps1 | 51 +- {Tests => tests}/Unit/MSFT_xWebsite.Tests.ps1 | 137 ++--- .../Unit/xWebAdministration.Common.Tests.ps1 | 21 +- .../xWebAdministration.TestHarness.psm1 | 0 xWebAdministration.psd1 | 165 ------ 163 files changed, 3375 insertions(+), 2189 deletions(-) delete mode 100644 .MetaTestOptIn.json delete mode 100644 .codecov.yml create mode 100644 .markdownlint.json delete mode 100644 .vscode/RunGlobalTests.ps1 delete mode 100644 .vscode/RunPesterTests.ps1 create mode 100644 CODE_OF_CONDUCT.md create mode 100644 GitVersion.yml create mode 100644 HISTORIC_CHANGELOG.md create mode 100644 RequiredModules.psd1 create mode 100644 Resolve-Dependency.ps1 create mode 100644 Resolve-Dependency.psd1 delete mode 100644 Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 delete mode 100644 Tests/TestHelper/CommonTestHelper.psm1 delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml create mode 100644 build.ps1 create mode 100644 build.yaml rename {DSCResources => source/DSCResources}/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_WebApplicationHandler/en-US/MSFT_WebApplicationHandler.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIIsHandler/MSFT_xIisHandler.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIIsHandler/MSFT_xIisHandler.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 (83%) rename {DSCResources => source/DSCResources}/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 (79%) rename {DSCResources => source/DSCResources}/MSFT_xIisLogging/MSFT_xIisLogging.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisLogging/MSFT_xIisLogging.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisLogging/en-US/MSFT_xIisLogging.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 (84%) rename {DSCResources => source/DSCResources}/MSFT_xIisModule/MSFT_xIisModule.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisModule/MSFT_xIisModule.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xIisModule/xIisModuleDesigner.ps1 (90%) rename {DSCResources => source/DSCResources}/MSFT_xSslSettings/MSFT_xSslSettings.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xSslSettings/MSFT_xSslSettings.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xSslSettings/en-US/MSFT_xSslSettings.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 (91%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPool/MSFT_xWebAppPool.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPool/en-US/MSFT_xWebAppPool.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 (74%) rename {DSCResources => source/DSCResources}/MSFT_xWebApplication/MSFT_xWebApplication.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_xWebApplication/MSFT_xWebApplication.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 (95%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigKeyValue/en-US/MSFT_xWebConfigKeyValue.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 (97%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigProperty/en-US/MSFT_xWebConfigProperty.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebConfigPropertyCollection/en-US/MSFT_xWebConfigPropertyCollection.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebSite/MSFT_xWebSite.psm1 (90%) rename {DSCResources => source/DSCResources}/MSFT_xWebSite/MSFT_xWebSite.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 (94%) rename {DSCResources => source/DSCResources}/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 (74%) rename {DSCResources => source/DSCResources}/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_xWebVirtualDirectory/en-US/MSFT_xWebVirtualDirectory.strings.psd1 (100%) rename {Examples => source/Examples}/Resources/Sample_EndToEndxWebAdministration.ps1 (100%) rename {Examples => source/Examples}/Resources/WebApplicationHandler/Sample_WebApplicationHandler.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisConfigurationPathFormat.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisModulePathFormat.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisHandler/Sample_xIisHandler_Remove32Bit.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisLogging/Sample_xIisLogging_Rollover.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisLogging/Sample_xIisLogging_Truncate.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisMimeTypeMapping/Sample_xIisMimeTypeMapping_RemoveVideo.ps1 (100%) rename {Examples => source/Examples}/Resources/xIisServerDefaults/Sample_xIisServerDefaults.ps1 (100%) rename {Examples => source/Examples}/Resources/xSslSettings/Sample_xSslSettings_RequireCert.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebAppPool/Sample_xWebAppPool.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebAppPoolDefaults/Sample_xWebAppPoolDefaults.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebApplication/Sample_xWebApplication.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebApplication/Sample_xWebApplication_NewWebApplication.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_AddAppSetting.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_RemoveAppSetting.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Add.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Remove.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Add.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Remove.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_NewWebsite.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_NewWebsiteFromConfigurationData.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateSubject.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateThumbprint.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_RemoveDefault.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_StopDefault.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSite/Sample_xWebSite_WithSSLFlags.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebSiteDefaults/Sample_xWebSiteDefaults.ps1 (100%) rename {Examples => source/Examples}/Resources/xWebVirtualDirectory/Sample_xWebVirtualDirectory_NewVirtualDirectory.ps1 (100%) rename {Modules => source/Modules}/xWebAdministration.Common/en-US/xWebAdministration.Common.strings.psd1 (100%) create mode 100644 source/Modules/xWebAdministration.Common/xWebAdministration.Common.psd1 rename {Modules => source/Modules}/xWebAdministration.Common/xWebAdministration.Common.psm1 (96%) create mode 100644 source/build.psd1 create mode 100644 source/en-US/about_xWebAdministration.help.txt create mode 100644 source/xWebAdministration.psd1 rename {Tests => tests}/Integration/MSFT_WebApplicationHandler.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 (86%) rename {Tests => tests}/Integration/MSFT_XIISLogging.Integration.Tests.ps1 (71%) rename {Tests => tests}/Integration/MSFT_XIISLogging.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 (78%) rename {Tests => tests}/Integration/MSFT_xIISFeatureDelegation.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xIISHandler.Integration.Tests.ps1 (56%) rename {Tests => tests}/Integration/MSFT_xIISHandler.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 (83%) rename {Tests => tests}/Integration/MSFT_xIISMimeTypeMapping.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xSslSettings.Integration.Tests.ps1 (64%) rename {Tests => tests}/Integration/MSFT_xSslSettings.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xSslSettings.config.psd1 (100%) rename Tests/Integration/MSFT_xWebAppPool.Integration.tests.ps1 => tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 (60%) rename {Tests => tests}/Integration/MSFT_xWebAppPool.config.ps1 (100%) create mode 100644 tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 rename {Tests => tests}/Integration/MSFT_xWebAppPoolDefaults.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebApplication.Integration.Tests.ps1 (76%) rename {Tests => tests}/Integration/MSFT_xWebApplication.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebApplication.config.psd1 (100%) rename {Tests => tests}/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 (65%) rename {Tests => tests}/Integration/MSFT_xWebConfigKeyValue.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 (83%) rename {Tests => tests}/Integration/MSFT_xWebConfigProperty.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 (85%) rename {Tests => tests}/Integration/MSFT_xWebConfigPropertyCollection.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebSite.Integration.Tests.ps1 (88%) rename {Tests => tests}/Integration/MSFT_xWebSite.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebSite.config.psd1 (100%) rename {Tests => tests}/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 (56%) rename {Tests => tests}/Integration/MSFT_xWebSiteDefaults.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 (62%) rename {Tests => tests}/Integration/MSFT_xWebVirtualDirectory.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_xWebVirtualDirectory.config.psd1 (100%) rename {Tests => tests}/MockWebAdministrationWindowsFeature.psm1 (91%) create mode 100644 tests/TestHelper/CommonTestHelper.psm1 rename Tests/Unit/MSFT_WebApplicationHandler.tests.ps1 => tests/Unit/MSFT_WebApplicationHandler.Tests.ps1 (93%) rename {Tests => tests}/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 (82%) rename {Tests => tests}/Unit/MSFT_xIISHandler.Tests.ps1 (79%) rename {Tests => tests}/Unit/MSFT_xIISLogging.Tests.ps1 (95%) rename {Tests => tests}/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 (82%) rename {Tests => tests}/Unit/MSFT_xSslSettings.Tests.ps1 (74%) rename {Tests => tests}/Unit/MSFT_xWebAppPool.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 (96%) rename {Tests => tests}/Unit/MSFT_xWebApplication.Tests.ps1 (96%) rename {Tests => tests}/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 (90%) rename Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 => tests/Unit/MSFT_xWebConfigProperty.Tests.ps1 (80%) rename Tests/Unit/MSFT_xWebConfigPropertyCollection.tests.ps1 => tests/Unit/MSFT_xWebConfigPropertyCollection.Tests.ps1 (89%) rename {Tests => tests}/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 (86%) rename {Tests => tests}/Unit/MSFT_xWebsite.Tests.ps1 (96%) rename {Tests => tests}/Unit/xWebAdministration.Common.Tests.ps1 (98%) rename {Tests => tests}/xWebAdministration.TestHarness.psm1 (100%) delete mode 100644 xWebAdministration.psd1 diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index d34ff23a2..000000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - "Common Tests - Relative Path Length", - "Common Tests - Validate Script Files", - "Common Tests - Validate Module Files", - "Common Tests - Validate Markdown Files", - "Common Tests - Validate Markdown Links", - "Common Tests - Custom Script Analyzer Rules", - "Common Tests - Flagged Script Analyzer Rules", - "Common Tests - Required Script Analyzer Rules", - "Common Tests - Validate Example Files" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 29a05dd15..000000000 --- a/.codecov.yml +++ /dev/null @@ -1,24 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no - -comment: - layout: "reach, diff" - behavior: default - -coverage: - range: 50..80 - round: down - precision: 0 - - status: - project: - default: - # Set the overall project code coverage requirement to 70% - target: 70 - patch: - default: - # Set the pull request requirement to not regress overall coverage by more than 5% - # and let codecov.io set the goal for the code changed in the patch. - target: auto - threshold: 5 diff --git a/.gitattributes b/.gitattributes index 5613d5331..d49b050c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,8 @@ # Needed for publishing of examples, build worker defaults to core.autocrlf=input. * text eol=crlf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.md b/.github/ISSUE_TEMPLATE/Problem_with_resource.md index 2431f65c0..159e81cbe 100644 --- a/.github/ISSUE_TEMPLATE/Problem_with_resource.md +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.md @@ -54,4 +54,4 @@ about: If you have a problem, bug, or enhancement with a resource in this resour $PSVersionTable --> -#### Version of the DSC module that was used ('dev' if using current dev branch) +#### Version of the DSC module that was used diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4070fc02c..73031e9cb 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ #### Pull Request (PR) description @@ -23,9 +23,10 @@ #### Task list @@ -37,15 +38,16 @@ Change to [x] for each task in the task list that applies to your PR. For those task that don't apply to you PR, leave those as is. --> -- [ ] Added an entry to the change log under the Unreleased section of the CHANGELOG.md. - Entry should say what was changed and how that affects users (if applicable), and - reference the issue being resolved (if applicable). +- [ ] Added an entry to the change log under the Unreleased section of the + file CHANGELOG.md. Entry should say what was changed and how that + affects users (if applicable), and reference the issue being resolved + (if applicable). - [ ] Resource documentation added/updated in README.md. - [ ] Resource parameter descriptions added/updated in README.md, schema.mof and comment-based help. - [ ] Comment-based help added/updated. - [ ] Localization strings added/updated in all localization files as appropriate. - [ ] Examples appropriately added/updated. -- [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). +- [ ] Unit tests added/updated. See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] Integration tests added/updated (where possible). See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] New/changed code adheres to [DSC Community Style Guidelines](https://dsccommunity.org/styleguidelines). diff --git a/.gitignore b/.gitignore index 3a3f4110d..13893f882 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -DSCResource.Tests *.vscode *.vs +output/* diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 000000000..87b7da562 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "default": true, + "MD029": { + "style": "one" + }, + "MD013": true, + "MD024": false, + "MD034": false, + "no-hard-tabs": true +} diff --git a/.vscode/RunGlobalTests.ps1 b/.vscode/RunGlobalTests.ps1 deleted file mode 100644 index 135c0ee4c..000000000 --- a/.vscode/RunGlobalTests.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -Import-Module (Join-Path $PSScriptRoot "..\Tests\xWebAdministration.TestHarness.psm1" -Resolve) - -$DscTestsPath = Join-Path $PSScriptRoot "..\DSCResource.Tests" -Resolve -if ((Test-Path $DscTestsPath) -eq $false) { - throw "Unable to locate DscResource.Tests repo at '$DscTestsPath', common DSC resource tests will not be executed" -} -Import-Module (Join-Path $PSScriptRoot "..\DscResource.Tests\TestHelper.psm1") - -Set-Location (Join-Path $PSScriptRoot "..\DscResource.Tests") - -Invoke-Pester diff --git a/.vscode/RunPesterTests.ps1 b/.vscode/RunPesterTests.ps1 deleted file mode 100644 index e1e345252..000000000 --- a/.vscode/RunPesterTests.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -Import-Module (Join-Path $PSScriptRoot "..\Tests\xWebAdministration.TestHarness.psm1" -Resolve) - -$DscTestsPath = Join-Path $PSScriptRoot "..\Tests\Unit" -Resolve -if ((Test-Path $DscTestsPath) -eq $false) { - Write-Warning "Unable to locate DscResource.Tests repo at '$DscTestsPath', common DSC resource tests will not be executed" - Invoke-xWebAdministrationTests -} else { - Invoke-xWebAdministrationTests -DscTestsPath $DscTestsPath -} diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 index be415e4d5..78312d2ca 100644 --- a/.vscode/analyzersettings.psd1 +++ b/.vscode/analyzersettings.psd1 @@ -1,11 +1,6 @@ @{ - <# - For the custom rules to work, the DscResource.Tests repo must be - cloned. It is automatically clone as soon as any unit or - integration tests are run. - #> - CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' - + CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules' + includeDefaultRules = $true IncludeRules = @( # DSC Resource Kit style guideline rules. 'PSAvoidDefaultValueForMandatoryParameter', @@ -43,11 +38,7 @@ 'PSUseDeclaredVarsMoreThanAssignments', 'PSUsePSCredentialType', - <# - This is to test all the DSC Resource Kit custom rules. - The name of the function-blocks of each custom rule start - with 'Measure*'. - #> 'Measure-*' ) + } diff --git a/.vscode/settings.json b/.vscode/settings.json index 0969e57b0..93d9aae73 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "powershell.codeFormatting.openBraceOnSameLine": false, - "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, "powershell.codeFormatting.newLineAfterCloseBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenParen": true, @@ -8,7 +8,31 @@ "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.trimTrailingWhitespace": false, + "files.encoding": "utf8" + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index f10fee667..0dc9e8b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,393 +1,44 @@ # Change log for xWebAdministration -## Unreleased - -- Changes to xWebAdministration - - Changes to WebApplicationHandler - - Fix Test-TargetResource to compare only properties that are specified in the configuration. ([issue #544](https://github.com/PowerShell/xWebAdministration/issues/544)) - -## 3.0.0.0 - -- Changes to xWebAdministration - - Changes to PULL\_REQUEST\_TEMPLATE.md - - Improving descriptive text around the CHANGELOG.md entry. - - Adding note that entry in CHANGELOG.md is mandatory for all PRs. - - Resolved custom Script Analyzer rules that was added to the test - framework. - - Moved change log from README.md to a separate CHANGELOG.md ([issue #446](https://github.com/PowerShell/xWebAdministration/issues/446)). - - Remove example 'Creating the default website using configuration - data' from README.md ([issue #488](https://github.com/PowerShell/xWebAdministration/issues/488)). - - Removed examples README.md as it was obsolete ([issue #482](https://github.com/PowerShell/xWebAdministration/issues/482)). - - Updated `Ensure` property description for `xIisHandler` resource to - match schema.mof - - Moved examples from Readme.md to respective `/Examples/Resources/` - folders ([issue #486](https://github.com/PowerShell/xWebAdministration/issues/486)). - - Created new folder structure for examples so that examples will be - placed in `/Examples/Resources/$resourceName` ([issue #483](https://github.com/PowerShell/xWebAdministration/issues/483)). - - Added a table of contents for the resource list ([issue #450](https://github.com/PowerShell/xWebAdministration/issues/450)). - - Alphabetized the resource list in the README.md ([issue #449](https://github.com/PowerShell/xWebAdministration/issues/449)). - - Optimized exporting in the module manifest for best performance ([issue #448](https://github.com/PowerShell/xWebAdministration/issues/448)). - - Updated hashtables in the repo to adhere to the style guidelines - described at https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#correct-format-for-hashtables-or-objects - ([issue #524](https://github.com/PowerShell/xWebAdministration/issues/524)) - - Moved example Sample_EndToEndxWebAdministration from readme.md to a - separate .ps1 in `/examples/` ([issue #491](https://github.com/PowerShell/xWebAdministration/issues/491)) - - Removed example 'Create and configure an application pool' from - README.md ([issue #489](https://github.com/PowerShell/xWebAdministration/issues/489)). -- Changes to xIisHandler - - Updated schema.mof to include descriptions for each property ([issue #453](https://github.com/PowerShell/xWebAdministration/issues/453)). - - Moved MSFT_xIisHandler localization strings to strings.psd1 ([issue #463](https://github.com/PowerShell/xWebAdministration/issues/463)). -- Changes to xWebSite - - Fix `Get-TargetResource` so that `LogFlags` are returned as expected - array of strings (one for each flag) rather than an array containing - a single comma-separated string of flags' ([issue #332](https://github.com/PowerShell/xWebAdministration/issues/332)). - - Moved localization strings to strings.psd1 file ([issue #475](https://github.com/PowerShell/xWebAdministration/issues/475)) - - Updated schema.mof so that each property has an appropriate description ([issue #456](https://github.com/PowerShell/xWebAdministration/issues/456)). - - Updated schema.mof and README so that `SourceType` and `SourceName` - properties for `MSFT_xLogCustomFieldInformation` are associated with - the appropriate descriptions and valuemaps/values ([issue #456](https://github.com/PowerShell/xWebAdministration/issues/456)). - - Move examples from README.md to resource examples folder ([issue #487](https://github.com/PowerShell/xWebAdministration/issues/487)). - - Fix case of resource name from `xWebsite` to `xWebSite` ([issue #535](https://github.com/PowerShell/xWebAdministration/issues/535)). -- Changes to xIISLogging - - Fix `Get-TargetResource` so that `LogFlags` are returned as expected - array of strings (one for each flag) rather than an array containing - a single comma-separated string of flags ([issue #332](https://github.com/PowerShell/xWebAdministration/issues/332)). - - Moved MSFT_xIisLogging localization strings to strings.psd1 ([issue #464](https://github.com/PowerShell/xWebAdministration/issues/464)). -- Changes to xSslSettings - - Updated casing of `xSslSettings` in all file names, folder names, - schema, and documentation ([issue #461](https://github.com/PowerShell/xWebAdministration/issues/461)). - - Updated casing of `xSslSettings` in all file names, folder names, - schema, and documentation ([issue #536](https://github.com/PowerShell/xWebAdministration/issues/536)). - - Moved MSFT_xSslSettings localization strings to strings.psd1 ([issue #467](https://github.com/PowerShell/xWebAdministration/issues/467)). -- Changes to xWebConfigKeyValue - - Updated schema.mof to include a description for the Ensure property ([issue #455](https://github.com/PowerShell/xWebAdministration/issues/455)). - - Move localization strings to strings.psd1 file ([issue #472](https://github.com/PowerShell/xWebAdministration/issues/472)). -- Changes to xWebAppPoolDefaults - - Move localization strings to strings.psd1 file ([issue #470](https://github.com/PowerShell/xWebAdministration/issues/470)). - - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` - to bring the resource into compliance with published best practices ([issue #462](https://github.com/PowerShell/xWebAdministration/issues/462)). -- Changes to xWebApplication - - Move localization strings to strings.psd1 file ([issue #468](https://github.com/PowerShell/xWebAdministration/issues/468)) - - Add description on class MSFT_xWebApplicationAuthenticationInformation ([issue #454](https://github.com/PowerShell/xWebAdministration/issues/454)). -- Changes to xIisModule entry - - Moved xIisModule localization strings to strings.psd1 ([issue #466](https://github.com/PowerShell/xWebAdministration/issues/466)). -- Changes to xIisMimeTypeMapping - - Moved MSFT_xIisMimeTypeMapping localization strings to strings.psd1 ([issue #465](https://github.com/PowerShell/xWebAdministration/issues/465)). -- Changes to xWebVirtualDirectory - - Moved MSFT_xWebVirtualDirectory localization strings to strings.psd1 ([issue #477](https://github.com/PowerShell/xWebAdministration/issues/477)). -- Changes to xWebSiteDefaults - - Move localization strings to strings.psd1 file ([issue #475](https://github.com/PowerShell/xWebAdministration/issues/475)). - - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` - to bring the resource into compliance with published best practices ([issue #457](https://github.com/PowerShell/xWebAdministration/issues/457)). - - Fix case of resource name from `xWebsiteDefaults` to `xWebSiteDefaults` ([issue #535](https://github.com/PowerShell/xWebAdministration/issues/535)). -- Changes to xWebConfigProperty - - Move localization strings to strings.psd1 file ([issue #473](https://github.com/PowerShell/xWebAdministration/issues/473)). -- Changes to xWebConfigPropertyCollection - - Move localization strings to strings.psd1 file ([issue #474](https://github.com/PowerShell/xWebAdministration/issues/474)). -- Changes to xIisFeatureDelegation - - Moved MSFT_xIisFeatureDelegation localization strings to strings.psd1 ([issue #459](https://github.com/PowerShell/xWebAdministration/issues/459)). -- Changes to xWebAppPool - - Moved MSFT_xWebAppPool localization strings to strings.psd1 ([issue #469](https://github.com/PowerShell/xWebAdministration/issues/469)). - -## 2.8.0.0 - -- Fix multiple HTTPS bindings on one xWebsite receiving the first binding's certificate [#332](https://github.com/PowerShell/xWebAdministration/issues/332) - - Added unit regression test -- Changes to xWebsite - - Added ServerAutoStart (controls website autostart) and changed documentation for ServiceAutoStartEnabled (controls application auto-initialization). Fixes #325. - - Fix multiple HTTPS bindings on one xWebsite receiving the first binding's certificate [#332](https://github.com/PowerShell/xWebAdministration/issues/332) - - Added unit regression test -- Changes to xWebAppPool - - Fix false `Test-TargetResource` failure for `logEventOnRecycle` if items in the Configuration property are specified in a different order than IIS natively stores them [#434](https://github.com/PowerShell/xWebAdministration/issues/434) -- Changes to xIisModule - - Fixed the parameters specification for the internal Get-IISHandler and Remove-IISHandler function - -## 2.7.0.0 - -- Changes to xWebAdministration - - Opt-in to the following DSC Resource Common Meta Tests: - - Common Tests - Relative Path Length - - Common Tests - Validate Script Files - - Common Tests - Validate Module Files - - Common Tests - Validate Markdown Files - - Common Tests - Validate Markdown Links - - Common Tests - Custom Script Analyzer Rules - - Common Tests - Flagged Script Analyzer Rules - - Common Tests - Required Script Analyzer Rules - - Common Tests - Validate Example Files - - Add ConfigurationPath to xIisMimeTypeMapping examples since it is now a required field. - -## 2.6.0.0 - -- Changed order of classes in schema.mof files to workaround [#423](https://github.com/PowerShell/xWebAdministration/issues/423) -- Fix subject comparison multiple entries for helper function `Find-Certificate` that could not find the test - helper function `Install-NewSelfSignedCertificateExScript`. -- Updated unit test for helper function `Find-Certificate` to check for multiple - subject names in different orders. - -## 2.5.0.0 - -- Added SiteId to xWebSite to address [396] -- xWebSite: Full path is used to get list of default documents -- xIISLogging: Added support for LogTargetW3C -- xWebsite: Added support for LogTargetW3C - -## 2.4.0.0 - -- Explicitly removed extra hidden files from release package - -## 2.3.0.0 - -- Update appveyor.yml to use the default template. -- Added default template file .gitattributes, and added default settings for - Visual Studio Code. -- Line endings was fixed in files that was committed with wrong line ending. - -## 2.2.0.0 - -- Added new parameter 'Location' to **WebApplcationHandler** extending functionality to address [392] -- Changes to xWebAdministration - - Update section header for WebApplicationHandler in README. - - Fix tests for helper function `Get-LocalizedData` in Helper.Tests.ps1 - that referenced the wrong path. -- Remove duplication in MSFT_xWebsite.psm1. [Krzysztof Morcinek (@kmorcinek)](https://github.com/kmorcinek) -- Updates **xIISMimeTypeMapping** to add MIME type mapping for nested paths - -## 2.1.0.0 - -- Added new resources **xWebConfigProperty** and **xWebConfigPropertyCollection** extending functionality provided by **xWebConfigKeyValue**, addresses #249. -- Fixed Get-DscConfiguration throw in xWebSite; addresses [#372](https://github.com/PowerShell/xWebAdministration/issues/372). [Reggie Gibson (@regedit32)](https://github.com/regedit32) -- Added **WebApplicationHandler** resource for creating and modifying IIS Web Handlers. Fixes #337 -- Added **WebApplicationHandler** integration tests -- Added **WebApplicationHandler** unit tests -- Deprecated xIISHandler resource. This resource will be removed in future release - -## 2.0.0.0 - -- Changes to xWebAdministration - - Moved file Codecov.yml that was added to the wrong path in previous release. -- Updated **xWebSite** to include ability to manage custom logging fields. - [Reggie Gibson (@regedit32)](https://github.com/regedit32) -- Updated **xIISLogging** to include ability to manage custom logging fields - ([issue #267](https://github.com/PowerShell/xWebAdministration/issues/267)). - [@ldillonel](https://github.com/ldillonel) -- BREAKING CHANGE: Updated **xIisFeatureDelegation** to be able to manage any - configuration section. - [Reggie Gibson (@regedit32)](https://github.com/regedit32) - -## 1.20.0.0 - -- Fix Get-DscConfiguration failure with xWebApplication and xWebSite resources - (issue #302 and issue #314). -- Add Codecov support. -- Added .vscode\settings.json so that code can be easily formatted in VSCode - closer according to the style guideline. -- Updated README.md with a branches section, and added Codecov badges. -- Fix unit test for helper function `Find-Certificate` that could not find the test - helper function `Install-NewSelfSignedCertificateExScript`. -- Fix unit tests for xWebSite that failed because `Get-Command` and 'Stop-WebStie` - wasn't properly mocked. - -## 1.19.0.0 - -- **xWebAppPoolDefaults** now returns values. Fixes #311. -- Added unit tests for **xWebAppPoolDefaults**. Fixes #183. - -## 1.18.0.0 - -- Added sample for **xWebVirtualDirectory** for creating a new virtual directory. Bugfix for #195. -- Added integration tests for **xWebVirtualDirectory**. Fixes #188. -- xWebsite: - - Fixed bugs when setting log properties, fixes #299. - -## 1.17.0.0 - -- Added removal of self signed certificate to the integration tests of **xWebsite**, fixes #276. -- Added EnabledProtocols to **xWebApplication**. -- Changed SSLFlags for **xWebApplication** to comma seperate multiple SSL flags, fixes #232. - -## 1.16.0.0 - -- Log directory configuration on **xWebsite** used the logPath attribute instead of the directory attribute. Bugfix for #256. -- Changed **xWebConfigKeyValue** to use the key for changing existing values. Bugfix for #107. -- Changed validation of LogTruncateSize for **xIisLogging** and **xWebsite** to UInt64 validation. -- Make PhysicalPath optional in **xWebsite**. Bugfix for #264. - -## 1.15.0.0 - -- Corrected name of AuthenticationInfo parameter in Readme.md. -- Added sample for **xWebApplication** for adding new web application. -- Corrected description for AuthenticationInfo for xWebApplication and xWebsite. -- Added samples for **xWebConfigKeyValue** for adding and removing appSettings. -- Added sample for **xWebAppPoolDefaults** for configuring the application pool defaults. -- Added sample for **xWebSiteDefaults** for configuring the site defaults. -- Updated Readme.md for **xWebConfigKeyValue**. Added **xIISHandler** and **xWebSiteDefaults**. - -## 1.14.0.0 - -- xWebApplication: - - Fixed bug when setting PhysicalPath and WebAppPool - - Changes to the application pool property are now applied correctly - -## 1.13.0.0 - -- Added unit tests for **xWebConfigKeyValue** and cleaned up style formatting. -- Added a stubs file for the WebAdministration functions so that the unit tests do not require a server to run -- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. -- Updated appveyor.yml to use the default image. - -## 1.12.0.0 - -- **xWebAppPool** updates: - -Replaced 3 calls to Invoke-Expression with a call to a new helper function - Get-Property - -- **xWebsite** updates: - - Bugfix for #131 The site name should be passed in as argument for Test-AuthenticationInfo - - Improved **BindingInfo** validation: the **HostName** property is required for use with Server Name Indication (i.e., when the **SslFlags** property is set to `1` or `3`). -- Adding conditional logic to install the test helper module from the gallery if the user downloaded the module from the gallery. -- Added **xSslSettings** integration tests -- Added fixes to **xSslSettings**. Corrected spelling and formatting in base resource and tests. Added misc comments. Added ValidateSet to bindings param. - -- Added **xIISLogging** resource which supports for the following options: - - LogPath - - LogFlags - - LogPeriod - - LogTruncateSize - - LoglocalTimeRollover - - LogFormat -- Added IIS Logging to **xWebsite** which support for the following options: - - LogPath - - LogFlags - - LogPeriod - - LogTruncateSize - - LoglocalTimeRollover - - LogFormat - -- **xWebApplication** updates: - - xWebApplication integration tests updated - - Added fixes to **xWebApplication**. Formatted resources to DSC StyleGuideLines, fixed logging statements, fixed incorrect Get-TargetResource param block, fixed Test-SslFlags validation, fixed unit test mocking of Test-SslFlags, added Ssl128 option to SslFlags - - Added EnabledProtocols - - Fixed: - - Formatted resources to DSC StyleGuideLines - - Logging statements - - Incorrect Get-TargetResource param block - - Test-SslFlags validation - - Unit test mocking of Test-SslFlags - -## 1.11.0.0 - -- **xWebAppPool** updates: - - Bug fixes, error handling and input validation improvements. - - The following properties were added: **idleTimeoutAction**, **logEventOnProcessModel**, **setProfileEnvironment**. - - The resource was updated to ensure a specific state only for the explicitly specified properties. - - The type of the following properties was changed to **Boolean**: **autoStart**, **enable32BitAppOnWin64**, **enableConfigurationOverride**, - **passAnonymousToken**, **cpuSmpAffinitized**, **loadUserProfile**, **manualGroupMembership**, **pingingEnabled**, **setProfileEnvironment**, - **orphanWorkerProcess**, **rapidFailProtection**, **disallowOverlappingRotation**, **disallowRotationOnConfigChange**. - - Unit and integration tests updated. -- **xWebsite** updated to remove invisible Unicode "LEFT-TO-RIGHT MARK" character from the **CertificateThumbprint*- property value. -- Added Preload and ServiceAutoStart functionality to **xWebsite** and **xWebApplication** -- Added AuthenticationInformation to **xWebsite** and **xWebApplication** -- Added SslFlags to **xWebApplication** - -## 1.10.0.0 - -- Fixed script analyzer failures in examples -- **xWebsite**: Fixed an issue in BindingInfo validation that caused multiple bindings with the same port and protocol treated as invalid. -- Changed PhysicalPath in xWebsite to be optional -- Changed WebApplication in xWebVirtualDirectory to accept empty strings for referring to the top-level IIS site - -## 1.9.0.0 - -- Added the following resources: - - xSslSettings -- Fixed an issue in xWebApplication where Set-TargetResource attempted to modify a folder instead of an application. - - Added Tests to xWebApplication which will allow more changes if desired. -- Modified README.MD to clean up Code Formatting -- Modified all unit/integration tests to utilize template system. -- xWebAppPool is now has feature parity to cWebAppPool - should now support most changes. -- Added Unit tests to IISFeatureDelegation, general script clean up -- Refactored xIisHandle to load script variables once, added unit tests. -- xWebsite updated: - - Added support for the following binding protocols: `msmq.formatname`, `net.msmq`, `net.pipe`, `net.tcp`. - - Added support for setting the `EnabledProtocols` property. - - Fixed an issue in bindings comparison which was causing bindings to be reassigned on every consistency check. - - Fixed an issue where binding conflict was not properly detected and handled. Stopped websites will not be checked for conflicting bindings anymore. - - The qualifier for the Protocol property of the MSFT_xWebBindingInformation CIM class was changed from Write to Required. - -## 1.8.0.0 - -- Modified xWebsite to allow Server Name Indication when specifiying SSL certificates. -- Change Test Get-Website to match other function -- Removed xDscResourceDesigner tests -- Suppress extra verbose messages when -verbose is specified to Start-DscConfiguration -- Moved tests into child folders Unit and Integration -- Added PSDesiredStateConfiguration to Import-DscResource statement -- Fixed issue where Set-TargetResource was being run unexpectedly -- Added Tests to MSFT_xWebVirtualDirectory -- xWebsite tests updates -- xWebVirtualDirectory tests updates - -## 1.7.0.0 - -- Added following resources: - - xIisHandler - - xIisFeatureDelegation - - xIisMimeTypeMapping - - xWebAppPoolDefaults - - xWebSiteDefaults -- Modified xWebsite schema to make PhysicalPath required - -## 1.6.0.0 - -- Fixed bug in xWebsite resource regarding incorrect name of personal certificate store. - -## 1.5.0.0 - -- xWebsite: - - Fix issue with Get-Website when there are multiple sites. - - Fix issue when trying to add a new website when no websites currently exist. - - Fix typos. - -## 1.4.0.0 - -Changed Key property in MSFT_xWebConfigKeyValue to be a Key, instead of Required. This allows multiple keys to be configured within the same web.config file. - -## 1.3.2.4 - -- Fixed the confusion with mismatched versions and xWebDeploy resources -- Removed BakeryWebsite.zip for legal reasons. Please read Examples\README.md for the workaround. - -## 1.3.2.3 - -- Fixed variable name typo in MSFT_xIisModule. -- Added OutputType attribute to Test-TargetResource and Get-TargetResource in MSFT_xWebSite. - -## 1.3.2.2 - -- Documentation only change. - -Module manifest metadata changed to improve PowerShell Gallery experience. - -## 1.3.2.1 - -- Documentation-only change, added metadata to module manifest - -## 1.3.2 - -- Added **xIisModule** - -## 1.2 - -- Added the **xWebAppPool**, **xWebApplication**, **xWebVirtualDirectory**, and **xWebConfigKeyValue**. - -## 1.1.0.0 - -- Added support for HTTPS protocol -- Updated binding information to include Certificate information for HTTPS -- Removed protocol property. Protocol is included in binding information -- Bug fixes - -## 1.0.0.0 - -- Initial release with the following resources - - **xWebsite** +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- xWebAdministration + - Added continuous delivery with a new CI pipeline + ([issue #547](https://github.com/PowerShell/xWebAdministration/issues/547)). + +### Changed + +- xWebAdministration.Common + - Added new helper function `Get-WebConfigurationPropertyValue` to + help return a value of a `WebConfigurationProperty`. *This helper* + *function is unable to be unit tested because it is using a type* + *that cannot be mocked.* +- xWebAppPoolDefaults + - Changed to use the new helper function `Get-WebConfigurationPropertyValue` + so that the resource can be properly unit tested. +- xWebConfigProperty + - Changed to use the new helper function `Get-WebConfigurationPropertyValue` + so that the resource can be properly unit tested. + +### Fixed + +- WebApplicationHandler + - Fix Test-TargetResource to compare only properties that are specified + in the configuration ([issue #544](https://github.com/PowerShell/xWebAdministration/issues/544)). +- xWebConfigProperty + - In some cases a verbose message was not outputted with any text, now + all verbose messages are correctly shown. +- xWebSite + - In some cases a verbose message was not outputted with any text, now + all verbose messages are correctly shown. + +### Removed + +- CommonTestHelper + - Removed unused functions `Get-InvalidArgumentRecord` and + `Get-InvalidOperationRecord`. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..d7589ddbb --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +This project has adopted the [DSC Community Code of Conduct](https://dsccommunity.org/code_of_conduct). diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 000000000..e38dce5fd --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDelivery +next-version: 3.1.0 +major-version-bump-message: '\s?(breaking|major|breaking\schange)' +minor-version-bump-message: '\s?(add|feature|minor)' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} diff --git a/HISTORIC_CHANGELOG.md b/HISTORIC_CHANGELOG.md new file mode 100644 index 000000000..0e568fe5b --- /dev/null +++ b/HISTORIC_CHANGELOG.md @@ -0,0 +1,392 @@ +# Historic change log for xWebAdministration + +The release notes in the PowerShell Module manifest cannot exceed 10000 +characters. Due to a bug in the CI deploy pipeline this is not handled. +This file is to temporary move the older change log history to keep the +change log short. + +## [3.0.0.0] - 2019-10-30 + +- Changes to xWebAdministration + - Changes to PULL\_REQUEST\_TEMPLATE.md + - Improving descriptive text around the CHANGELOG.md entry. + - Adding note that entry in CHANGELOG.md is mandatory for all PRs. + - Resolved custom Script Analyzer rules that was added to the test + framework. + - Moved change log from README.md to a separate CHANGELOG.md ([issue #446](https://github.com/PowerShell/xWebAdministration/issues/446)). + - Remove example 'Creating the default website using configuration + data' from README.md ([issue #488](https://github.com/PowerShell/xWebAdministration/issues/488)). + - Removed examples README.md as it was obsolete ([issue #482](https://github.com/PowerShell/xWebAdministration/issues/482)). + - Updated `Ensure` property description for `xIisHandler` resource to + match schema.mof + - Moved examples from Readme.md to respective `/Examples/Resources/` + folders ([issue #486](https://github.com/PowerShell/xWebAdministration/issues/486)). + - Created new folder structure for examples so that examples will be + placed in `/Examples/Resources/$resourceName` ([issue #483](https://github.com/PowerShell/xWebAdministration/issues/483)). + - Added a table of contents for the resource list ([issue #450](https://github.com/PowerShell/xWebAdministration/issues/450)). + - Alphabetized the resource list in the README.md ([issue #449](https://github.com/PowerShell/xWebAdministration/issues/449)). + - Optimized exporting in the module manifest for best performance ([issue #448](https://github.com/PowerShell/xWebAdministration/issues/448)). + - Updated hashtables in the repo to adhere to the style guidelines + described at https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#correct-format-for-hashtables-or-objects + ([issue #524](https://github.com/PowerShell/xWebAdministration/issues/524)) + - Moved example Sample_EndToEndxWebAdministration from readme.md to a + separate .ps1 in `/examples/` ([issue #491](https://github.com/PowerShell/xWebAdministration/issues/491)) + - Removed example 'Create and configure an application pool' from + README.md ([issue #489](https://github.com/PowerShell/xWebAdministration/issues/489)). +- Changes to xIisHandler + - Updated schema.mof to include descriptions for each property ([issue #453](https://github.com/PowerShell/xWebAdministration/issues/453)). + - Moved MSFT_xIisHandler localization strings to strings.psd1 ([issue #463](https://github.com/PowerShell/xWebAdministration/issues/463)). +- Changes to xWebSite + - Fix `Get-TargetResource` so that `LogFlags` are returned as expected + array of strings (one for each flag) rather than an array containing + a single comma-separated string of flags' ([issue #332](https://github.com/PowerShell/xWebAdministration/issues/332)). + - Moved localization strings to strings.psd1 file ([issue #475](https://github.com/PowerShell/xWebAdministration/issues/475)) + - Updated schema.mof so that each property has an appropriate description ([issue #456](https://github.com/PowerShell/xWebAdministration/issues/456)). + - Updated schema.mof and README so that `SourceType` and `SourceName` + properties for `MSFT_xLogCustomFieldInformation` are associated with + the appropriate descriptions and valuemaps/values ([issue #456](https://github.com/PowerShell/xWebAdministration/issues/456)). + - Move examples from README.md to resource examples folder ([issue #487](https://github.com/PowerShell/xWebAdministration/issues/487)). + - Fix case of resource name from `xWebsite` to `xWebSite` ([issue #535](https://github.com/PowerShell/xWebAdministration/issues/535)). +- Changes to xIISLogging + - Fix `Get-TargetResource` so that `LogFlags` are returned as expected + array of strings (one for each flag) rather than an array containing + a single comma-separated string of flags ([issue #332](https://github.com/PowerShell/xWebAdministration/issues/332)). + - Moved MSFT_xIisLogging localization strings to strings.psd1 ([issue #464](https://github.com/PowerShell/xWebAdministration/issues/464)). +- Changes to xSslSettings + - Updated casing of `xSslSettings` in all file names, folder names, + schema, and documentation ([issue #461](https://github.com/PowerShell/xWebAdministration/issues/461)). + - Updated casing of `xSslSettings` in all file names, folder names, + schema, and documentation ([issue #536](https://github.com/PowerShell/xWebAdministration/issues/536)). + - Moved MSFT_xSslSettings localization strings to strings.psd1 ([issue #467](https://github.com/PowerShell/xWebAdministration/issues/467)). +- Changes to xWebConfigKeyValue + - Updated schema.mof to include a description for the Ensure property ([issue #455](https://github.com/PowerShell/xWebAdministration/issues/455)). + - Move localization strings to strings.psd1 file ([issue #472](https://github.com/PowerShell/xWebAdministration/issues/472)). +- Changes to xWebAppPoolDefaults + - Move localization strings to strings.psd1 file ([issue #470](https://github.com/PowerShell/xWebAdministration/issues/470)). + - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` + to bring the resource into compliance with published best practices ([issue #462](https://github.com/PowerShell/xWebAdministration/issues/462)). +- Changes to xWebApplication + - Move localization strings to strings.psd1 file ([issue #468](https://github.com/PowerShell/xWebAdministration/issues/468)) + - Add description on class MSFT_xWebApplicationAuthenticationInformation ([issue #454](https://github.com/PowerShell/xWebAdministration/issues/454)). +- Changes to xIisModule entry + - Moved xIisModule localization strings to strings.psd1 ([issue #466](https://github.com/PowerShell/xWebAdministration/issues/466)). +- Changes to xIisMimeTypeMapping + - Moved MSFT_xIisMimeTypeMapping localization strings to strings.psd1 ([issue #465](https://github.com/PowerShell/xWebAdministration/issues/465)). +- Changes to xWebVirtualDirectory + - Moved MSFT_xWebVirtualDirectory localization strings to strings.psd1 ([issue #477](https://github.com/PowerShell/xWebAdministration/issues/477)). +- Changes to xWebSiteDefaults + - Move localization strings to strings.psd1 file ([issue #475](https://github.com/PowerShell/xWebAdministration/issues/475)). + - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` + to bring the resource into compliance with published best practices ([issue #457](https://github.com/PowerShell/xWebAdministration/issues/457)). + - Fix case of resource name from `xWebsiteDefaults` to `xWebSiteDefaults` ([issue #535](https://github.com/PowerShell/xWebAdministration/issues/535)). +- Changes to xWebConfigProperty + - Move localization strings to strings.psd1 file ([issue #473](https://github.com/PowerShell/xWebAdministration/issues/473)). +- Changes to xWebConfigPropertyCollection + - Move localization strings to strings.psd1 file ([issue #474](https://github.com/PowerShell/xWebAdministration/issues/474)). +- Changes to xIisFeatureDelegation + - Moved MSFT_xIisFeatureDelegation localization strings to strings.psd1 ([issue #459](https://github.com/PowerShell/xWebAdministration/issues/459)). +- Changes to xWebAppPool + - Moved MSFT_xWebAppPool localization strings to strings.psd1 ([issue #469](https://github.com/PowerShell/xWebAdministration/issues/469)). + +## [2.8.0.0] - 2019-09-18 + +- Fix multiple HTTPS bindings on one xWebsite receiving the first binding's certificate [#332](https://github.com/PowerShell/xWebAdministration/issues/332) + - Added unit regression test +- Changes to xWebsite + - Added ServerAutoStart (controls website autostart) and changed documentation for ServiceAutoStartEnabled (controls application auto-initialization). Fixes #325. + - Fix multiple HTTPS bindings on one xWebsite receiving the first binding's certificate [#332](https://github.com/PowerShell/xWebAdministration/issues/332) + - Added unit regression test +- Changes to xWebAppPool + - Fix false `Test-TargetResource` failure for `logEventOnRecycle` if items in the Configuration property are specified in a different order than IIS natively stores them [#434](https://github.com/PowerShell/xWebAdministration/issues/434) +- Changes to xIisModule + - Fixed the parameters specification for the internal Get-IISHandler and Remove-IISHandler function + +## [2.7.0.0] - 2019-08-07 + +- Changes to xWebAdministration + - Opt-in to the following DSC Resource Common Meta Tests: + - Common Tests - Relative Path Length + - Common Tests - Validate Script Files + - Common Tests - Validate Module Files + - Common Tests - Validate Markdown Files + - Common Tests - Validate Markdown Links + - Common Tests - Custom Script Analyzer Rules + - Common Tests - Flagged Script Analyzer Rules + - Common Tests - Required Script Analyzer Rules + - Common Tests - Validate Example Files + - Add ConfigurationPath to xIisMimeTypeMapping examples since it is now a required field. + +## [2.6.0.0] - 2019-05-15 + +- Changed order of classes in schema.mof files to workaround [#423](https://github.com/PowerShell/xWebAdministration/issues/423) +- Fix subject comparison multiple entries for helper function `Find-Certificate` that could not find the test + helper function `Install-NewSelfSignedCertificateExScript`. +- Updated unit test for helper function `Find-Certificate` to check for multiple + subject names in different orders. + +## [2.5.0.0] - 2019-02-20 + +- Added SiteId to xWebSite to address [396] +- xWebSite: Full path is used to get list of default documents +- xIISLogging: Added support for LogTargetW3C +- xWebsite: Added support for LogTargetW3C + +## [2.4.0.0] - 2019-01-10 + +- Explicitly removed extra hidden files from release package + +## [2.3.0.0] - 2018-10-25 + +- Update appveyor.yml to use the default template. +- Added default template file .gitattributes, and added default settings for + Visual Studio Code. +- Line endings was fixed in files that was committed with wrong line ending. + +## [2.2.0.0] - 2018-09-05 + +- Added new parameter 'Location' to **WebApplcationHandler** extending functionality to address [392] +- Changes to xWebAdministration + - Update section header for WebApplicationHandler in README. + - Fix tests for helper function `Get-LocalizedData` in Helper.Tests.ps1 + that referenced the wrong path. +- Remove duplication in MSFT_xWebsite.psm1. [Krzysztof Morcinek (@kmorcinek)](https://github.com/kmorcinek) +- Updates **xIISMimeTypeMapping** to add MIME type mapping for nested paths + +## [2.1.0.0] - 2018-07-25 + +- Added new resources **xWebConfigProperty** and **xWebConfigPropertyCollection** extending functionality provided by **xWebConfigKeyValue**, addresses #249. +- Fixed Get-DscConfiguration throw in xWebSite; addresses [#372](https://github.com/PowerShell/xWebAdministration/issues/372). [Reggie Gibson (@regedit32)](https://github.com/regedit32) +- Added **WebApplicationHandler** resource for creating and modifying IIS Web Handlers. Fixes #337 +- Added **WebApplicationHandler** integration tests +- Added **WebApplicationHandler** unit tests +- Deprecated xIISHandler resource. This resource will be removed in future release + +## [2.0.0.0] - 2018-05-02 + +- Changes to xWebAdministration + - Moved file Codecov.yml that was added to the wrong path in previous release. +- Updated **xWebSite** to include ability to manage custom logging fields. + [Reggie Gibson (@regedit32)](https://github.com/regedit32) +- Updated **xIISLogging** to include ability to manage custom logging fields + ([issue #267](https://github.com/PowerShell/xWebAdministration/issues/267)). + [@ldillonel](https://github.com/ldillonel) +- BREAKING CHANGE: Updated **xIisFeatureDelegation** to be able to manage any + configuration section. + [Reggie Gibson (@regedit32)](https://github.com/regedit32) + +## [1.20.0.0] - 2017-11-15 + +- Fix Get-DscConfiguration failure with xWebApplication and xWebSite resources + (issue #302 and issue #314). +- Add Codecov support. +- Added .vscode\settings.json so that code can be easily formatted in VSCode + closer according to the style guideline. +- Updated README.md with a branches section, and added Codecov badges. +- Fix unit test for helper function `Find-Certificate` that could not find the test + helper function `Install-NewSelfSignedCertificateExScript`. +- Fix unit tests for xWebSite that failed because `Get-Command` and 'Stop-WebStie` + wasn't properly mocked. + +## [1.19.0.0] - + +- **xWebAppPoolDefaults** now returns values. Fixes #311. +- Added unit tests for **xWebAppPoolDefaults**. Fixes #183. + +## [1.18.0.0] - 2017-01-26 + +- Added sample for **xWebVirtualDirectory** for creating a new virtual directory. Bugfix for #195. +- Added integration tests for **xWebVirtualDirectory**. Fixes #188. +- xWebsite: + - Fixed bugs when setting log properties, fixes #299. + +## [1.17.0.0] - + +- Added removal of self signed certificate to the integration tests of **xWebsite**, fixes #276. +- Added EnabledProtocols to **xWebApplication**. +- Changed SSLFlags for **xWebApplication** to comma seperate multiple SSL flags, fixes #232. + +## [1.16.0.0] - 2016-06-29 + +- Log directory configuration on **xWebsite** used the logPath attribute instead of the directory attribute. Bugfix for #256. +- Changed **xWebConfigKeyValue** to use the key for changing existing values. Bugfix for #107. +- Changed validation of LogTruncateSize for **xIisLogging** and **xWebsite** to UInt64 validation. +- Make PhysicalPath optional in **xWebsite**. Bugfix for #264. + +## [1.15.0.0] - 2016-11-05 + +- Corrected name of AuthenticationInfo parameter in Readme.md. +- Added sample for **xWebApplication** for adding new web application. +- Corrected description for AuthenticationInfo for xWebApplication and xWebsite. +- Added samples for **xWebConfigKeyValue** for adding and removing appSettings. +- Added sample for **xWebAppPoolDefaults** for configuring the application pool defaults. +- Added sample for **xWebSiteDefaults** for configuring the site defaults. +- Updated Readme.md for **xWebConfigKeyValue**. Added **xIISHandler** and **xWebSiteDefaults**. + +## [1.14.0.0] - 2016-09-21 + +- xWebApplication: + - Fixed bug when setting PhysicalPath and WebAppPool + - Changes to the application pool property are now applied correctly + +## [1.13.0.0] - 2016-08-10 + +- Added unit tests for **xWebConfigKeyValue** and cleaned up style formatting. +- Added a stubs file for the WebAdministration functions so that the unit tests do not require a server to run +- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. +- Updated appveyor.yml to use the default image. + +## [1.12.0.0] - 2016-06-29 + +- **xWebAppPool** updates: + -Replaced 3 calls to Invoke-Expression with a call to a new helper function - Get-Property + +- **xWebsite** updates: + - Bugfix for #131 The site name should be passed in as argument for Test-AuthenticationInfo + - Improved **BindingInfo** validation: the **HostName** property is required for use with Server Name Indication (i.e., when the **SslFlags** property is set to `1` or `3`). +- Adding conditional logic to install the test helper module from the gallery if the user downloaded the module from the gallery. +- Added **xSslSettings** integration tests +- Added fixes to **xSslSettings**. Corrected spelling and formatting in base resource and tests. Added misc comments. Added ValidateSet to bindings param. + +- Added **xIISLogging** resource which supports for the following options: + - LogPath + - LogFlags + - LogPeriod + - LogTruncateSize + - LoglocalTimeRollover + - LogFormat +- Added IIS Logging to **xWebsite** which support for the following options: + - LogPath + - LogFlags + - LogPeriod + - LogTruncateSize + - LoglocalTimeRollover + - LogFormat + +- **xWebApplication** updates: + - xWebApplication integration tests updated + - Added fixes to **xWebApplication**. Formatted resources to DSC StyleGuideLines, fixed logging statements, fixed incorrect Get-TargetResource param block, fixed Test-SslFlags validation, fixed unit test mocking of Test-SslFlags, added Ssl128 option to SslFlags + - Added EnabledProtocols + - Fixed: + - Formatted resources to DSC StyleGuideLines + - Logging statements + - Incorrect Get-TargetResource param block + - Test-SslFlags validation + - Unit test mocking of Test-SslFlags + +## [1.11.0.0] - 2016-05-11 + +- **xWebAppPool** updates: + - Bug fixes, error handling and input validation improvements. + - The following properties were added: **idleTimeoutAction**, **logEventOnProcessModel**, **setProfileEnvironment**. + - The resource was updated to ensure a specific state only for the explicitly specified properties. + - The type of the following properties was changed to **Boolean**: **autoStart**, **enable32BitAppOnWin64**, **enableConfigurationOverride**, + **passAnonymousToken**, **cpuSmpAffinitized**, **loadUserProfile**, **manualGroupMembership**, **pingingEnabled**, **setProfileEnvironment**, + **orphanWorkerProcess**, **rapidFailProtection**, **disallowOverlappingRotation**, **disallowRotationOnConfigChange**. + - Unit and integration tests updated. +- **xWebsite** updated to remove invisible Unicode "LEFT-TO-RIGHT MARK" character from the **CertificateThumbprint*- property value. +- Added Preload and ServiceAutoStart functionality to **xWebsite** and **xWebApplication** +- Added AuthenticationInformation to **xWebsite** and **xWebApplication** +- Added SslFlags to **xWebApplication** + +## [1.10.0.0] - 2016-03-31 + +- Fixed script analyzer failures in examples +- **xWebsite**: Fixed an issue in BindingInfo validation that caused multiple bindings with the same port and protocol treated as invalid. +- Changed PhysicalPath in xWebsite to be optional +- Changed WebApplication in xWebVirtualDirectory to accept empty strings for referring to the top-level IIS site + +## [1.9.0.0] - 2016-02-03 + +- Added the following resources: + - xSslSettings +- Fixed an issue in xWebApplication where Set-TargetResource attempted to modify a folder instead of an application. + - Added Tests to xWebApplication which will allow more changes if desired. +- Modified README.MD to clean up Code Formatting +- Modified all unit/integration tests to utilize template system. +- xWebAppPool is now has feature parity to cWebAppPool - should now support most changes. +- Added Unit tests to IISFeatureDelegation, general script clean up +- Refactored xIisHandle to load script variables once, added unit tests. +- xWebsite updated: + - Added support for the following binding protocols: `msmq.formatname`, `net.msmq`, `net.pipe`, `net.tcp`. + - Added support for setting the `EnabledProtocols` property. + - Fixed an issue in bindings comparison which was causing bindings to be reassigned on every consistency check. + - Fixed an issue where binding conflict was not properly detected and handled. Stopped websites will not be checked for conflicting bindings anymore. + - The qualifier for the Protocol property of the MSFT_xWebBindingInformation CIM class was changed from Write to Required. + +## [1.8.0.0] - 2015-12-03 + +- Modified xWebsite to allow Server Name Indication when specifiying SSL certificates. +- Change Test Get-Website to match other function +- Removed xDscResourceDesigner tests +- Suppress extra verbose messages when -verbose is specified to Start-DscConfiguration +- Moved tests into child folders Unit and Integration +- Added PSDesiredStateConfiguration to Import-DscResource statement +- Fixed issue where Set-TargetResource was being run unexpectedly +- Added Tests to MSFT_xWebVirtualDirectory +- xWebsite tests updates +- xWebVirtualDirectory tests updates + +## [1.7.0.0] - 2015-07-24 + +- Added following resources: + - xIisHandler + - xIisFeatureDelegation + - xIisMimeTypeMapping + - xWebAppPoolDefaults + - xWebSiteDefaults +- Modified xWebsite schema to make PhysicalPath required + +## [1.6.0.0] - 2015-06-19 + +- Fixed bug in xWebsite resource regarding incorrect name of personal certificate store. + +## [1.5.0.0] - 2015-05-02 + +- xWebsite: + - Fix issue with Get-Website when there are multiple sites. + - Fix issue when trying to add a new website when no websites currently exist. + - Fix typos. + +## [1.4.0.0] - 2015-04-24 + +Changed Key property in MSFT_xWebConfigKeyValue to be a Key, instead of Required. This allows multiple keys to be configured within the same web.config file. + +## [1.3.2.4] - 2015-04-01 + +- Fixed the confusion with mismatched versions and xWebDeploy resources +- Removed BakeryWebsite.zip for legal reasons. Please read Examples\README.md for the workaround. + +## [1.3.2.3] - 2014-12-18 + +- Fixed variable name typo in MSFT_xIisModule. +- Added OutputType attribute to Test-TargetResource and Get-TargetResource in MSFT_xWebSite. + +## [1.3.2.2] - 2014-12-01 + +- Documentation only change. + +Module manifest metadata changed to improve PowerShell Gallery experience. + +## [1.3.2.1] - 2014-07-22 + +- Documentation-only change, added metadata to module manifest + +## [1.3.2].0 - 2014-07-22 + +- Added **xIisModule** + +## [1.2.0.0] - 2014-04-08 + +- Added the **xWebAppPool**, **xWebApplication**, **xWebVirtualDirectory**, and **xWebConfigKeyValue**. + +## [1.1.0.0] - 2014-04-08 + +- Added support for HTTPS protocol +- Updated binding information to include Certificate information for HTTPS +- Removed protocol property. Protocol is included in binding information +- Bug fixes + +## [1.0.0.0] - 2014-04-08 + +- Initial release with the following resources + - **xWebsite** diff --git a/LICENSE b/LICENSE index 567fd6a52..f4c3ee927 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Microsoft Corporation. +Copyright (c) DSC Community contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/README.md b/README.md index 54c8b26a2..59ac1f11b 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,27 @@ # xWebAdministration -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -## Branches +[![Build Status](https://dev.azure.com/dsccommunity/xWebAdministration/_apis/build/status/dsccommunity.xWebAdministration?branchName=master)](https://dev.azure.com/dsccommunity/xWebAdministration/_build/latest?definitionId=7&branchName=master) +![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/xWebAdministration/7/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/xWebAdministration/7/master)](https://dsccommunity.visualstudio.com/xWebAdministration/_test/analytics?definitionId=7&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/xWebAdministration?label=xWebAdministration%20Preview)](https://www.powershellgallery.com/packages/xWebAdministration/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/xWebAdministration?label=xWebAdministration)](https://www.powershellgallery.com/packages/xWebAdministration/) -### master - -[![Build status](https://ci.appveyor.com/api/projects/status/gnsxkjxht31ctan1/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xWebAdministration/branch/master) -[![codecov](https://codecov.io/gh/PowerShell/xWebAdministration/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xWebAdministration/branch/master) +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -This is the branch containing the latest release - -no contributions should be made directly to this branch. +## Code of Conduct -### dev +This project has adopted this [Code of Conduct](CODE_OF_CONDUCT.md). -[![Build status](https://ci.appveyor.com/api/projects/status/gnsxkjxht31ctan1/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/xWebAdministration/branch/dev) -[![codecov](https://codecov.io/gh/PowerShell/xWebAdministration/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xWebAdministration/branch/dev) +## Releases -This is the development branch -to which contributions should be proposed by contributors as pull requests. -This development branch will periodically be merged to the master branch, -and be released to [PowerShell Gallery](https://www.powershellgallery.com/). +For each merge to the branch `master` a preview release will be +deployed to [PowerShell Gallery](https://www.powershellgallery.com/). +Periodically a release version tag will be pushed which will deploy a +full release to [PowerShell Gallery](https://www.powershellgallery.com/). ## Contributing -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). ## Installation @@ -60,7 +56,7 @@ The minimum Windows Management Framework (PowerShell) version required is ## Examples -You can review the [Examples](/Examples) directory in the xWebAdministration +You can review the [Examples](/source/Examples) directory in the xWebAdministration module for some general use scenarios for all of the resources that are in the module. diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 000000000..c59e076a2 --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,20 @@ +@{ + PSDependOptions = @{ + AddToPath = $True + Target = 'output\RequiredModules' + Parameters = @{ + } + } + + invokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + pester = 'latest' + Plaster = 'latest' + ModuleBuilder = '1.0.0' + ChangelogManagement = 'latest' + Sampler = 'latest' + MarkdownLinkCheck = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + xDscResourceDesigner = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 000000000..4928e6242 --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,289 @@ +[CmdletBinding()] +param +( + + [Parameter()] + [String] + $DependencyFile = 'RequiredModules.psd1', + + [Parameter()] + [String] + # Path for PSDepend to be bootstrapped and save other dependencies. + # Can also be CurrentUser or AllUsers if you wish to install the modules in such scope + # Default to $PWD.Path/output/modules + $PSDependTarget = (Join-Path $PSScriptRoot './output/RequiredModules'), + + [Parameter()] + [uri] + # URI to use for Proxy when attempting to Bootstrap PackageProvider & PowerShellGet + $Proxy, + + [Parameter()] + # Credential to contact the Proxy when provided + [PSCredential]$ProxyCredential, + + [Parameter()] + [ValidateSet('CurrentUser', 'AllUsers')] + [String] + # Scope to bootstrap the PackageProvider and PSGet if not available + $Scope = 'CurrentUser', + + [Parameter()] + [String] + # Gallery to use when bootstrapping PackageProvider, PSGet and when calling PSDepend (can be overridden in Dependency files) + $Gallery = 'PSGallery', + + [Parameter()] + [PSCredential] + # Credentials to use with the Gallery specified above + $GalleryCredential, + + + [Parameter()] + [switch] + # Allow you to use a locally installed version of PowerShellGet older than 1.6.0 (not recommended, default to $False) + $AllowOldPowerShellGetModule, + + [Parameter()] + [String] + # Allow you to specify a minimum version fo PSDepend, if you're after specific features. + $MinimumPSDependVersion, + + [Parameter()] + [Switch] + $AllowPrerelease, + + [Parameter()] + [Switch] + $WithYAML +) + +# Load Defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter +try +{ + Write-Verbose -Message "Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'." + $ResolveDependencyDefaults = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1' -Resolve -ErrorAction Stop) + $ParameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName }.Parameters.Keys + if ($ParameterToDefault.Count -eq 0) + { + $ParameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option + foreach ($ParamName in $ParameterToDefault) + { + if (-Not $PSBoundParameters.Keys.Contains($ParamName) -and $ResolveDependencyDefaults.ContainsKey($ParamName)) + { + Write-Verbose -Message "Setting $ParamName with $($ResolveDependencyDefaults[$ParamName])" + try + { + $variableValue = $ResolveDependencyDefaults[$ParamName] + if ($variableValue -is [string]) + { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + $PSBoundParameters.Add($ParamName, $variableValue) + Set-Variable -Name $ParamName -value $variableValue -Force -ErrorAction SilentlyContinue + } + catch + { + Write-Verbose -Message "Error adding default for $ParamName : $($_.Exception.Message)" + } + } + } +} +catch +{ + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from $(Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1'): $($_.Exception.Message)." +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 0 -CurrentOperation "NuGet Bootstrap" + +if (!(Get-PackageProvider -Name NuGet -ForceBootstrap -ErrorAction SilentlyContinue)) +{ + $providerBootstrapParams = @{ + Name = 'nuget' + force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $providerBootstrapParams.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $providerBootstrapParams.Add('ProxyCredential', $ProxyCredential) + } + 'Scope' + { + $providerBootstrapParams.Add('Scope', $Scope) + } + } + + if ($AllowPrerelease) + { + $providerBootstrapParams.Add('AllowPrerelease', $true) + } + + Write-Information "Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed)" + $null = Install-PackageProvider @providerBootstrapParams + $latestNuGetVersion = (Get-PackageProvider -Name NuGet -ListAvailable | Select-Object -First 1).Version.ToString() + Write-Information "Bootstrap: Importing NuGet Package Provider version $latestNuGetVersion to current session." + $Null = Import-PackageProvider -Name NuGet -RequiredVersion $latestNuGetVersion -Force +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + +# Fail if the given PSGallery is not Registered +$Policy = (Get-PSRepository $Gallery -ErrorAction Stop).InstallationPolicy +Set-PSRepository -Name $Gallery -InstallationPolicy Trusted -ErrorAction Ignore +try +{ + Write-Progress -Activity "Bootstrap:" -PercentComplete 25 -CurrentOperation "Checking PowerShellGet" + # Ensure the module is loaded and retrieve the version you have + $PowerShellGetVersion = (Import-Module PowerShellGet -PassThru -ErrorAction SilentlyContinue).Version + + Write-Verbose "Bootstrap: The PowerShellGet version is $PowerShellGetVersion" + # Versions below 1.6.0 are considered old, unreliable & not recommended + if (!$PowerShellGetVersion -or ($PowerShellGetVersion -lt [System.version]'1.6.0' -and !$AllowOldPowerShellGetModule)) + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 40 -CurrentOperation "Installing newer version of PowerShellGet" + $InstallPSGetParam = @{ + Name = 'PowerShellGet' + Force = $True + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $InstallPSGetParam.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $InstallPSGetParam.Add('ProxyCredential', $ProxyCredential) + } + 'GalleryCredential' + { + $InstallPSGetParam.Add('Credential', $GalleryCredential) + } + } + + Install-Module @InstallPSGetParam + Remove-Module PowerShellGet -force -ErrorAction SilentlyContinue + Import-Module PowerShellGet -Force + $NewLoadedVersion = (Get-Module PowerShellGet).Version.ToString() + Write-Information "Bootstrap: PowerShellGet version loaded is $NewLoadedVersion" + Write-Progress -Activity "Bootstrap:" -PercentComplete 60 -CurrentOperation "Installing newer version of PowerShellGet" + } + + # Try to import the PSDepend module from the available modules + try + { + $ImportPSDependParam = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($MinimumPSDependVersion) + { + $ImportPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + $null = Import-Module @ImportPSDependParam + } + catch + { + # PSDepend module not found, installing or saving it + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug "PSDepend module not found. Attempting to install from Gallery $Gallery" + Write-Warning "Installing PSDepend in $PSDependTarget Scope" + $InstallPSDependParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) + { + $InstallPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + Install-Module @InstallPSDependParam + } + else + { + Write-Debug "PSDepend module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + } + + if ($MinimumPSDependVersion) + { + $SaveModuleParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope" + Save-Module @SaveModuleParam + } + } + finally + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 100 -CurrentOperation "Loading PSDepend" + # We should have successfully bootstrapped PSDepend. Fail if not available + Import-Module PSDepend -ErrorAction Stop + } + + if ($WithYAML) + { + if (-Not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) + { + Write-Verbose "PowerShell-Yaml module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + } + + Save-Module @SaveModuleParam + Import-Module "PowerShell-Yaml" -ErrorAction Stop + } + else + { + Write-Verbose "PowerShell-Yaml is already available" + } + } + + Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies" + if (Test-Path $DependencyFile) + { + $PSDependParams = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified + Invoke-PSDepend @PSDependParams + } + Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed +} +finally +{ + # Reverting the Installation Policy for the given gallery + Set-PSRepository -Name $Gallery -InstallationPolicy $Policy + Write-Verbose "Project Bootstrapped, returning to Invoke-Build" +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 000000000..2ae8c0dac --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,5 @@ +@{ + Gallery = 'PSGallery' + AllowPrerelease = $false + WithYAML = $true +} diff --git a/Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 deleted file mode 100644 index cee617cc1..000000000 --- a/Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 +++ /dev/null @@ -1,115 +0,0 @@ -#requires -Version 4.0 - -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebAppPoolDefaults' - -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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 -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration - -#endregion - -# Test Setup -if ((Get-Service -Name 'W3SVC').Status -ne 'Running') -{ - Start-Service -Name 'W3SVC' -} - -$tempBackupName = "$($script:DSCResourceName)_$(Get-Date -Format 'yyyyMMdd_HHmmss')" - -# Using try/finally to always cleanup even if something awful happens. - -try -{ - # Create configuration backup - - Backup-WebConfiguration -Name $tempBackupName | Out-Null - - #region Integration Tests - - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $ConfigFile - - Describe "$($script:DSCResourceName)_Integration" { - - #region Default Tests - - It 'Should be able to compile and apply without throwing' { - { - Invoke-Expression -Command ( - '{0}_Config -OutputPath $TestDrive -ConfigurationData $ConfigData -ErrorAction Stop' -f - $script:DSCResourceName - ) - - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Force -Wait -Verbose - } | Should Not Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should Not Throw - } - - #endregion - - It 'Should have set the resource and all the parameters should match' { - - $currentConfiguration = Get-DscConfiguration - - foreach ($parameter in $TestParameters.GetEnumerator()) - { - Write-Verbose -Message "The $($parameter.Name) property should be set." - - if ($parameter.Name -eq 'Credential') - { - $appPoolDefaults = Get-WebConfiguration -Filter '/system.applicationHost/applicationPools/applicationPoolDefaults' - - $appPoolDefaults.processModel.userName | - Should Be $TestParameters['Credential'].UserName - - $appPoolDefaults.processModel.password | - Should Be $TestParameters['Credential'].GetNetworkCredential().Password - } - elseif ($parameter.Name -eq 'ApplyTo') - { - # ignored. - } - else - { - $currentConfiguration."$($parameter.Name)" | - Should Be $TestParameters[$parameter.Name] - } - } - - } - - It 'Actual configuration should match the desired configuration' { - Test-DscConfiguration -Verbose | Should Be $true - } - - } - - #endregion -} -finally -{ - #region FOOTER - Restore-WebConfiguration -Name $tempBackupName - Remove-WebConfigurationBackup -Name $tempBackupName - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/TestHelper/CommonTestHelper.psm1 b/Tests/TestHelper/CommonTestHelper.psm1 deleted file mode 100644 index 8dd376e4d..000000000 --- a/Tests/TestHelper/CommonTestHelper.psm1 +++ /dev/null @@ -1,135 +0,0 @@ -<# - .SYNOPSIS - Returns an invalid argument exception object - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ArgumentName - The name of the invalid argument that is causing this error to be thrown -#> -function Get-InvalidArgumentRecord -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [String] - $Message, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [String] - $ArgumentName - ) - - $argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message, - $ArgumentName ) - $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( $argumentException, $ArgumentName, 'InvalidArgument', $null ) - } - return New-Object @newObjectParams -} - -<# - .SYNOPSIS - Returns an invalid operation exception object - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error -#> -function Get-InvalidOperationRecord -{ - [CmdletBinding()] - param - ( - [ValidateNotNullOrEmpty()] - [String] - $Message, - - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $Message) - { - $invalidOperationException = New-Object -TypeName 'InvalidOperationException' - } - elseif ($null -eq $ErrorRecord) - { - $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message ) - } - else - { - $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, - $ErrorRecord.Exception ) - } - - $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect', - 'InvalidOperation', $null ) - } - return New-Object @newObjectParams -} - -<# - .SYNOPSIS - Some tests require a self-signed certificate to be created. However, the - New-SelfSignedCertificate cmdlet built into Windows Server 2012 R2 is too - limited to work for this process. - - Therefore an alternate method of creating self-signed certificates to meet the - reqirements. A script on Microsoft Script Center can be used for this but must - be downloaded: - https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6 - - This cmdlet will install the script if it is not available and dot source it. - - .PARAMETER OutputPath - The path to download the script to. If not provided will default to the current - users temp folder. - - .OUTPUTS - The path to the script that was downloaded. -#> -function Install-NewSelfSignedCertificateExScript -{ - [CmdletBinding()] - [OutputType([String])] - param - ( - [Parameter()] - [String] - $OutputPath = $env:Temp - ) - - $newSelfSignedCertURL = 'https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6/file/101251/2/New-SelfSignedCertificateEx.zip' - $newSelfSignedCertZip = Split-Path -Path $newSelfSignedCertURL -Leaf - $newSelfSignedCertZipPath = Join-Path -Path $OutputPath -ChildPath $newSelfSignedCertZip - $newSelfSignedCertScriptPath = Join-Path -Path $OutputPath -ChildPath 'New-SelfSignedCertificateEx.ps1' - if (-not (Test-Path -Path $newSelfSignedCertScriptPath)) - { - if (Test-Path -Path $newSelfSignedCertZip) - { - Remove-Item -Path $newSelfSignedCertZipPath -Force - } - Invoke-WebRequest -Uri $newSelfSignedCertURL -OutFile $newSelfSignedCertZipPath - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($newSelfSignedCertZipPath, $OutputPath) - } # if - return $newSelfSignedCertScriptPath -} # end function Install-NewSelfSignedCertificateExScript - -Export-ModuleMember -Function ` - Install-NewSelfSignedCertificateExScript, ` - Get-InvalidArgumentRecord, ` - Get-InvalidOperationRecord diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c85fa1ea6..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# - -version: 1.17.{build}.0 -environment: - gallery_api: - secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv - -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose - - ps: Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - - ps: Invoke-AppveyorInstallTask - - ps: Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -test_script: - - ps: | - Invoke-AppveyorTestScriptTask -CodeCoverage -CodeCovIo - -# scripts to run before deployment -after_test: - - ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -deploy_script: - - ps: | - Invoke-AppVeyorDeployTask diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..cf4f3a367 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,170 @@ +trigger: + branches: + include: + - master + tags: + include: + - "v*" + exclude: + - "*-*" +#variables: + +stages: + - stage: Build + jobs: + - job: BuildModuleJob + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: GitVersion@5 + name: gitversion + inputs: + runtime: 'core' + configFilePath: 'GitVersion.yml' + + - task: PowerShell@2 + name: Build + inputs: + filePath: './build.ps1' + arguments: '-ResolveDependency -tasks pack' + pwsh: true + env: + ModuleVersion: $(GitVersion.Informationalversion) + + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: 'output/' + ArtifactName: 'output' + publishLocation: 'Container' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_HQRM + pool: + vmImage: 'win1803' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: Test + inputs: + filePath: './build.ps1' + arguments: '-Tasks hqrmtest' + pwsh: false + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + + - job: Test_Unit + pool: + vmImage: 'win1803' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: DscBuildVariable + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: Test + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + - task: PublishCodeCoverageResults@1 + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(DscBuildVariable.RepositoryName)' + + - job: Test_Integration + pool: + vmImage: 'vs2017-win2016' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: ConfigureWinRM + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server' + name: InstallWebServerFeature + - task: PowerShell@2 + name: Test + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + + - stage: Deploy + dependsOn: Test + # Only execute deploy stage if we're on master and previous stage succeeded + condition: | + and( + succeeded(), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/master'), + startsWith(variables['Build.SourceBranch'], 'refs/tags/') + ) + ) + jobs: + - job: Deploy_Artefact + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: publish_prerelease + inputs: + filePath: './build.ps1' + arguments: '-tasks publish' + pwsh: true + env: + GitHubToken: $(GitHubToken) + GalleryApiToken: $(GalleryApiToken) + - task: PowerShell@2 + name: send_changelog_PR + inputs: + filePath: './build.ps1' + arguments: '-tasks Create_ChangeLog_GitHub_PR' + pwsh: true + env: + GitHubToken: $(GitHubToken) diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..a94f13bdd --- /dev/null +++ b/build.ps1 @@ -0,0 +1,353 @@ +<# + +.DESCRIPTION + Bootstrap and build script for PowerShell module pipeline + +#> +[CmdletBinding()] +param +( + [Parameter(Position = 0)] + [string[]]$Tasks = '.', + + [Parameter()] + [String] + $CodeCoverageThreshold = '', + + [Parameter()] + [validateScript( + { Test-Path -Path $_ } + )] + $BuildConfig = './build.yaml', + + [Parameter()] + # A Specific folder to build the artefact into. + $OutputDirectory = 'output', + + [Parameter()] + # Subdirectory name to build the module (under $OutputDirectory) + $BuiltModuleSubdirectory = '', + + # Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency & PSDepend where to save the required modules, + # or use CurrentUser, AllUsers to target where to install missing dependencies + # You can override the value for PSDepend in the Build.psd1 build manifest + # This defaults to $OutputDirectory/modules (by default: ./output/modules) + [Parameter()] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + # Filter which tags to run when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterTag, + + [Parameter()] + [string[]] + $PesterScript, + + # Filter which tags to exclude when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterExcludeTag, + + [Parameter()] + [Alias('bootstrap')] + [switch]$ResolveDependency, + + [Parameter(DontShow)] + [AllowNull()] + $BuildInfo, + + [Parameter()] + [switch] + $AutoRestore +) + +# The BEGIN block (at the end of this file) handles the Bootstrap of the Environment before Invoke-Build can run the tasks +# if the -ResolveDependency (aka Bootstrap) is specified, the modules are already available, and can be auto loaded + +process +{ + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (Look at the Begin block at the bottom of this script) + return + } + + # Execute the Build Process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName BeforeBuild + + try + { + Write-Host -ForeGroundColor magenta "[build] Parsing defined tasks" + + # Load Default BuildInfo if not provided as parameter + if (!$PSBoundParameters.ContainsKey('BuildInfo')) + { + try + { + if (Test-Path $BuildConfig) + { + $ConfigFile = (Get-Item -Path $BuildConfig) + Write-Host "[build] Loading Configuration from $ConfigFile" + $BuildInfo = switch -Regex ($ConfigFile.Extension) + { + # Native Support for PSD1 + '\.psd1' + { + Import-PowerShellDataFile -Path $BuildConfig + } + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' + { + Import-Module -ErrorAction Stop -Name 'powershell-yaml' + ConvertFrom-Yaml -Yaml (Get-Content -Raw $ConfigFile) + } + # Native Support for JSON and JSONC (by Removing comments) + '\.[json|jsonc]' + { + $JSONC = (Get-Content -Raw -Path $ConfigFile) + $JSON = $JSONC -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + # This should probably be converted to hashtable for splatting + $JSON | ConvertFrom-Json + } + default + { + Write-Error "Extension '$_' not supported. using @{}" + @{ } + } + } + } + else + { + Write-Host -Object "Configuration file $BuildConfig not found" -ForegroundColor Red + $BuildInfo = @{ } + } + } + catch + { + Write-Host -Object "Error loading Config $ConfigFile.`r`n Are you missing dependencies?" -ForegroundColor Yellow + Write-Host -Object "Make sure you run './build.ps1 -ResolveDependency -tasks noop' to restore the Required modules the first time" -ForegroundColor Yellow + $BuildInfo = @{ } + Write-Error $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it + if ($BuildInfo.TaskHeader) + { + Set-BuildHeader ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + # Import Tasks from modules via their exported aliases when defined in BUild Manifest + # https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + if ($BuildInfo.containsKey('ModuleBuildTasks')) + { + foreach ($Module in $BuildInfo['ModuleBuildTasks'].Keys) + { + try + { + Write-Host -ForegroundColor DarkGray -Verbose "Importing tasks from module $Module" + $LoadedModule = Import-Module $Module -PassThru -ErrorAction Stop + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($Module)) + { + $LoadedModule.ExportedAliases.GetEnumerator().Where{ + # using -like to support wildcard + Write-Host -ForegroundColor DarkGray "`t Loading $($_.Key)..." + $_.Key -like $TaskToExport + }.ForEach{ + # Dot sourcing the Tasks via their exported aliases + . (Get-Alias $_.Key) + } + } + } + catch + { + Write-Host -ForegroundColor Red -Object "Could not load tasks for module $Module." + Write-Error $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name) + Get-ChildItem -Path ".build/" -Recurse -Include *.ps1 -ErrorAction Ignore | ForEach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo + task . { + Write-Build Yellow "No sequence currently defined for the default task" + } + + # Load Invoke-Build task sequences/workflows from $BuildInfo + Write-Host -ForegroundColor DarkGray "Adding Workflow from configuration:" + foreach ($Workflow in $BuildInfo.BuildWorkflow.keys) + { + Write-Verbose "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')" + $WorkflowItem = $BuildInfo.BuildWorkflow.($Workflow) + if ($WorkflowItem.Trim() -match '^\{(?[\w\W]*)\}$') + { + $WorkflowItem = [ScriptBlock]::Create($Matches['sb']) + } + Write-Host -ForegroundColor DarkGray " +-> $Workflow" + task $Workflow $WorkflowItem + } + + Write-Host -ForeGroundColor magenta "[build] Executing requested workflow: $($Tasks -join ', ')" + + } + finally + { + Pop-Location -StackName BeforeBuild + } +} + +Begin +{ + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Host -foregroundColor Green "[pre-build] Starting Build Init" + Push-Location $PSScriptRoot -StackName BuildModule + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) + { + # Installing modules instead of saving them + Write-Host -foregroundColor Green "[pre-build] Required Modules will be installed for $RequiredModulesDirectory, not saved." + # Tell Resolve-Dependency to use provided scope as the -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesDirectory + } + else + { + if (-Not (Split-Path -IsAbsolute -Path $OutputDirectory)) + { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to + if (-Not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) + { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise + if (Resolve-Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) + { + Write-Debug "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + $RequiredModulesPath = Convert-Path $RequiredModulesDirectory + } + else + { + Write-Host -foregroundColor Green "[pre-build] Creating required modules directory $RequiredModulesDirectory." + $RequiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + # Prepending $RequiredModulesPath folder to PSModulePath to resolve from this folder FIRST + if ($RequiredModulesDirectory -notIn @('CurrentUser', 'AllUsers') -and + (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $RequiredModulesDirectory)) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$RequiredModulesDirectory' folder to PSModulePath" + $Env:PSModulePath = $RequiredModulesDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Checking if the user should -ResolveDependency + if ((!(Get-Module -ListAvailable powershell-yaml) -or !(Get-Module -ListAvailable InvokeBuild) -or !(Get-Module -ListAvailable PSDepend)) -and !$ResolveDependency) + { + if ($AutoRestore -or !$PSBoundParameters.ContainsKey('Tasks') -or $Tasks -contains 'build') + { + Write-Host -ForegroundColor Yellow "[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you `r`n" + $ResolveDependency = $true + } + else + { + Write-Warning "Some required Modules are missing, make sure you first run with the '-ResolveDependency' parameter." + Write-Warning "Running 'build.ps1 -ResolveDependency -Tasks noop' will pull required modules without running the build task." + } + } + + if ($BuiltModuleSubdirectory) + { + if (-Not (Split-Path -IsAbsolute $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path $OutputDirectory $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Prepending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder + if (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $BuildModuleOutput) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$BuildModuleOutput' folder to PSModulePath" + $Env:PSModulePath = $BuildModuleOutput + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Tell Resolve-Dependency to use $RequiredModulesPath as -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesPath + } + + if ($ResolveDependency) + { + Write-Host -Object "[pre-build] Resolving dependencies." -foregroundColor Green + $ResolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency + if ($BuildConfig -match '\.[yaml|yml]$') + { + $ResolveDependencyParams.add('WithYaml', $True) + } + + $ResolveDependencyAvailableParams = (Get-Command -Name '.\Resolve-Dependency.ps1').parameters.keys + foreach ($CmdParameter in $ResolveDependencyAvailableParams) + { + + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($CmdParameter)) + { + $ParamValue = $MyInvocation.BoundParameters.ContainsKey($CmdParameter) + Write-Debug " adding $CmdParameter :: $ParamValue [from user-provided parameters to Build.ps1]" + $ResolveDependencyParams.Add($CmdParameter, $ParamValue) + } + # Use defaults parameter value from Build.ps1, if any + else + { + if ($ParamValue = Get-Variable -Name $CmdParameter -ValueOnly -ErrorAction Ignore) + { + Write-Debug " adding $CmdParameter :: $ParamValue [from default Build.ps1 variable]" + $ResolveDependencyParams.add($CmdParameter, $ParamValue) + } + } + } + + Write-Host -foregroundColor Green "[pre-build] Starting bootstrap process." + .\Resolve-Dependency.ps1 @ResolveDependencyParams + } + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Verbose "Bootstrap completed. Handing back to InvokeBuild." + if ($PSBoundParameters.ContainsKey('ResolveDependency')) + { + Write-Verbose "Dependency already resolved. Removing task" + $null = $PSBoundParameters.Remove('ResolveDependency') + } + Write-Host -foregroundColor Green "[build] Starting build with InvokeBuild." + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + Pop-Location -StackName BuildModule + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 000000000..e04e06f28 --- /dev/null +++ b/build.yaml @@ -0,0 +1,88 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +CopyDirectories: + - en-US + - DSCResources + - Modules +Encoding: UTF8 +VersionedOutputDirectory: true + +#################################################### +# Sampler Pipeline Configuration # +#################################################### +BuildWorkflow: + '.': + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + + pack: + - build + - package_module_nupkg + + hqrmtest: + - DscResource_Tests_Stop_On_Fail + + test: + - Pester_Tests_Stop_On_Fail + - Pester_if_Code_Coverage_Under_Threshold + + publish: + - Publish_release_to_GitHub + - publish_module_to_gallery + + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: + OutputFormat: NUnitXML + ExcludeFromCodeCoverage: + Script: + - tests/Unit + ExcludeTag: + Tag: + CodeCoverageThreshold: 85 + +DscTest: + ExcludeTag: + - "Common Tests - New Error-Level Script Analyzer Rules" + Tag: + ExcludeSourceFile: + - output + ExcludeModuleFile: + +Resolve-Dependency: + Gallery: 'PSGallery' + AllowPrerelease: false + Verbose: false + +ModuleBuildTasks: + Sampler: + - '*.build.Sampler.ib.tasks' + +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" + +GitHubConfig: + GitHubFilesToAdd: + - 'CHANGELOG.md' + GitHubConfigUserName: dscbot + GitHubConfigUserEmail: dsccommunity@outlook.com + UpdateChangelogOnPrerelease: false diff --git a/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.psm1 b/source/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.psm1 similarity index 100% rename from DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.psm1 rename to source/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.psm1 diff --git a/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.schema.mof b/source/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.schema.mof similarity index 100% rename from DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.schema.mof rename to source/DSCResources/MSFT_WebApplicationHandler/MSFT_WebApplicationHandler.schema.mof diff --git a/DSCResources/MSFT_WebApplicationHandler/en-US/MSFT_WebApplicationHandler.strings.psd1 b/source/DSCResources/MSFT_WebApplicationHandler/en-US/MSFT_WebApplicationHandler.strings.psd1 similarity index 100% rename from DSCResources/MSFT_WebApplicationHandler/en-US/MSFT_WebApplicationHandler.strings.psd1 rename to source/DSCResources/MSFT_WebApplicationHandler/en-US/MSFT_WebApplicationHandler.strings.psd1 diff --git a/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.psm1 b/source/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.psm1 similarity index 100% rename from DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.psm1 rename to source/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.psm1 diff --git a/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.schema.mof b/source/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.schema.mof similarity index 100% rename from DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.schema.mof rename to source/DSCResources/MSFT_xIIsHandler/MSFT_xIisHandler.schema.mof diff --git a/DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 b/source/DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 similarity index 83% rename from DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 rename to source/DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 index e9cc00eeb..cafb6b4d2 100644 --- a/DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 +++ b/source/DSCResources/MSFT_xIIsHandler/en-US/MSFT_xIIsHandler.strings.psd1 @@ -1,5 +1,4 @@ ConvertFrom-StringData @' - NoWebAdministrationModule = Please ensure that WebAdministration module is installed. AddingHandler = Adding handler '{0}'. RemovingHandler = Removing handler '{0}'. HandlerExists = Handler with name '{0}' already exist. diff --git a/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1 b/source/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1 similarity index 100% rename from DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1 rename to source/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.psm1 diff --git a/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.schema.mof b/source/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.schema.mof similarity index 100% rename from DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.schema.mof rename to source/DSCResources/MSFT_xIisFeatureDelegation/MSFT_xIisFeatureDelegation.schema.mof diff --git a/DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 b/source/DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 similarity index 79% rename from DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 rename to source/DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 index 4e6d6bd52..92390ed70 100644 --- a/DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 +++ b/source/DSCResources/MSFT_xIisFeatureDelegation/en-US/MSFT_xIisFeatureDelegation.strings.psd1 @@ -2,7 +2,6 @@ ConvertFrom-StringData @' GetOverrideMode = Getting override mode for '{0}'. - NoWebAdministrationModule = Please ensure that WebAdministration module is installed. UnableToGetConfig = Unable to get configuration data for '{0}'. VerboseGetTargetResource = Get-TargetResource has been run. VerboseSetTargetResource = Changed overrideMode for '{0}' to '{1}'. diff --git a/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.psm1 b/source/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.psm1 similarity index 100% rename from DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.psm1 rename to source/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.psm1 diff --git a/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.schema.mof b/source/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.schema.mof similarity index 100% rename from DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.schema.mof rename to source/DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.schema.mof diff --git a/DSCResources/MSFT_xIisLogging/en-US/MSFT_xIisLogging.strings.psd1 b/source/DSCResources/MSFT_xIisLogging/en-US/MSFT_xIisLogging.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xIisLogging/en-US/MSFT_xIisLogging.strings.psd1 rename to source/DSCResources/MSFT_xIisLogging/en-US/MSFT_xIisLogging.strings.psd1 diff --git a/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.psm1 b/source/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.psm1 similarity index 100% rename from DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.psm1 rename to source/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.psm1 diff --git a/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.schema.mof b/source/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.schema.mof similarity index 100% rename from DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.schema.mof rename to source/DSCResources/MSFT_xIisMimeTypeMapping/MSFT_xIisMimeTypeMapping.schema.mof diff --git a/DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 b/source/DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 similarity index 84% rename from DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 rename to source/DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 index 2668667ec..32d46bf0d 100644 --- a/DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 +++ b/source/DSCResources/MSFT_xIisMimeTypeMapping/en-US/MSFT_xIisMimeTypeMapping.strings.psd1 @@ -1,6 +1,5 @@ # culture ="en-US" ConvertFrom-StringData -StringData @' - NoWebAdministrationModule = Please ensure that WebAdministration module is installed. AddingType = Adding MIMEType '{0}' for extension '{1}'. RemovingType = Removing MIMEType '{0}' for extension '{1}'. TypeExists = MIMEType '{0}' for extension '{1}' is in desired state. diff --git a/DSCResources/MSFT_xIisModule/MSFT_xIisModule.psm1 b/source/DSCResources/MSFT_xIisModule/MSFT_xIisModule.psm1 similarity index 100% rename from DSCResources/MSFT_xIisModule/MSFT_xIisModule.psm1 rename to source/DSCResources/MSFT_xIisModule/MSFT_xIisModule.psm1 diff --git a/DSCResources/MSFT_xIisModule/MSFT_xIisModule.schema.mof b/source/DSCResources/MSFT_xIisModule/MSFT_xIisModule.schema.mof similarity index 100% rename from DSCResources/MSFT_xIisModule/MSFT_xIisModule.schema.mof rename to source/DSCResources/MSFT_xIisModule/MSFT_xIisModule.schema.mof diff --git a/DSCResources/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1 b/source/DSCResources/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1 rename to source/DSCResources/MSFT_xIisModule/en-US/MSFT_xIisModule.strings.psd1 diff --git a/DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 b/source/DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 similarity index 90% rename from DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 rename to source/DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 index 3f9c39c61..02a12d4a6 100644 --- a/DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 +++ b/source/DSCResources/MSFT_xIisModule/xIisModuleDesigner.ps1 @@ -11,18 +11,18 @@ $moduleRoot = Join-Path $env:temp "$($originalModuleRootPath.path | split-path - $resources = @() #Key properties -$resources += New-xDscResourceProperty -Name Path -Type String -Attribute Key -Description "The path to the module, usually a dll, to be added to IIS." +$resources += New-xDscResourceProperty -Name Path -Type String -Attribute Key -Description "The path to the module, usually a dll, to be added to IIS." #Required Properites -$resources += New-xDscResourceProperty -Name Name -Type String -Attribute Required -Description "The logical name of the module to add to IIS." -$resources += New-xDscResourceProperty -Name RequestPath -Type String -Attribute Required -Description "The allowed request Path example: *.php" -$resources += New-xDscResourceProperty -Name Verb -Type String[] -Attribute Required -Description "The supported verbs for the module." +$resources += New-xDscResourceProperty -Name Name -Type String -Attribute Required -Description "The logical name of the module to add to IIS." +$resources += New-xDscResourceProperty -Name RequestPath -Type String -Attribute Required -Description "The allowed request Path example: *.php" +$resources += New-xDscResourceProperty -Name Verb -Type String[] -Attribute Required -Description "The supported verbs for the module." #Write Properties -$resources += New-xDscResourceProperty -Name SiteName -Type String -Attribute Write -Description "The IIS Site to register the module." -$resources += New-xDscResourceProperty -Name Ensure -Type String -Attribute Write -Description "Should the module be present or absent." -ValidateSet @("Present","Absent") -$resources += New-xDscResourceProperty -Name ModuleType -Type String -Attribute Write -Description "The type of the module." -ValidateSet @("FastCgiModule") +$resources += New-xDscResourceProperty -Name SiteName -Type String -Attribute Write -Description "The IIS Site to register the module." +$resources += New-xDscResourceProperty -Name Ensure -Type String -Attribute Write -Description "Should the module be present or absent." -ValidateSet @("Present","Absent") +$resources += New-xDscResourceProperty -Name ModuleType -Type String -Attribute Write -Description "The type of the module." -ValidateSet @("FastCgiModule") #Read Properties $resources += New-xDscResourceProperty -Name EndPointSetup -Type Boolean -Attribute Read -Description "The End Point is setup. Such as a Fast Cgi endpoint." @@ -37,9 +37,9 @@ New-xDscResource -Property $resources -ClassVersion $classVersion -Name $resourc # Use your favorite diff program to compare and merge the current resource and the existing resource -if((test-Path $diff)) +if ((test-Path $diff)) { - &$diff $originalModuleRoot $moduleRoot + &$diff $originalModuleRoot $moduleRoot } else { diff --git a/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.psm1 b/source/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.psm1 similarity index 100% rename from DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.psm1 rename to source/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.psm1 diff --git a/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.schema.mof b/source/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.schema.mof similarity index 100% rename from DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.schema.mof rename to source/DSCResources/MSFT_xSslSettings/MSFT_xSslSettings.schema.mof diff --git a/DSCResources/MSFT_xSslSettings/en-US/MSFT_xSslSettings.strings.psd1 b/source/DSCResources/MSFT_xSslSettings/en-US/MSFT_xSslSettings.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xSslSettings/en-US/MSFT_xSslSettings.strings.psd1 rename to source/DSCResources/MSFT_xSslSettings/en-US/MSFT_xSslSettings.strings.psd1 diff --git a/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 b/source/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 similarity index 91% rename from DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 rename to source/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 index 277b56fa1..926bb7b2d 100644 --- a/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 +++ b/source/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.psm1 @@ -250,13 +250,13 @@ function Get-TargetResource if ($null -eq $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolNotFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolNotFound -f $Name) $ensureResult = 'Absent' } else { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolFound -f $Name) $ensureResult = 'Present' @@ -527,8 +527,8 @@ function Set-TargetResource # Create Application Pool if ($null -eq $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolNotFound'] -f $Name) - Write-Verbose -Message ($script:localizedData['VerboseNewAppPool'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolNotFound -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseNewAppPool -f $Name) $appPool = New-WebAppPool -Name $Name -ErrorAction Stop } @@ -536,7 +536,7 @@ function Set-TargetResource # Set Application Pool Properties if ($null -ne $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolFound -f $Name) $PropertyData.Where( { @@ -554,7 +554,7 @@ function Set-TargetResource ) { Write-Verbose -Message ( - $script:localizedData['VerboseSetProperty'] -f $propertyName, $Name + $script:localizedData.VerboseSetProperty -f $propertyName, $Name ) Invoke-AppCmd -ArgumentList 'set', 'apppool', $Name, ( @@ -571,7 +571,7 @@ function Set-TargetResource if ($appPool.processModel.userName -ne $Credential.UserName) { Write-Verbose -Message ( - $script:localizedData['VerboseSetProperty'] -f 'Credential (userName)', $Name + $script:localizedData.VerboseSetProperty -f 'Credential (userName)', $Name ) Invoke-AppCmd -ArgumentList 'set', 'apppool', $Name, ( @@ -584,7 +584,7 @@ function Set-TargetResource if ($appPool.processModel.password -cne $clearTextPassword) { Write-Verbose -Message ( - $script:localizedData['VerboseSetProperty'] -f 'Credential (password)', $Name + $script:localizedData.VerboseSetProperty -f 'Credential (password)', $Name ) Invoke-AppCmd -ArgumentList 'set', 'apppool', $Name, ( @@ -594,7 +594,7 @@ function Set-TargetResource } else { - Write-Verbose -Message ($script:localizedData['VerboseCredentialToBeIgnored']) + Write-Verbose -Message ($script:localizedData.VerboseCredentialToBeIgnored) } } @@ -616,7 +616,7 @@ function Set-TargetResource ) ) { - Write-Verbose -Message ($script:localizedData['VerboseClearCredential'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseClearCredential -f $Name) Invoke-AppCmd -ArgumentList 'set', 'apppool', $Name, '/processModel.userName:' Invoke-AppCmd -ArgumentList 'set', 'apppool', $Name, '/processModel.password:' @@ -650,7 +650,7 @@ function Set-TargetResource if ($_.SideIndicator -eq '<=') { Write-Verbose -Message ( - $script:localizedData['VerboseRestartScheduleValueAdd'] -f + $script:localizedData.VerboseRestartScheduleValueAdd -f $_.InputObject, $Name ) @@ -662,7 +662,7 @@ function Set-TargetResource else { Write-Verbose -Message ( - $script:localizedData['VerboseRestartScheduleValueRemove'] -f + $script:localizedData.VerboseRestartScheduleValueRemove -f $_.InputObject, $Name ) @@ -678,13 +678,13 @@ function Set-TargetResource { if ($State -eq 'Started') { - Write-Verbose -Message ($script:localizedData['VerboseStartAppPool'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseStartAppPool -f $Name) Start-WebAppPool -Name $Name -ErrorAction Stop } else { - Write-Verbose -Message ($script:localizedData['VerboseStopAppPool'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseStopAppPool -f $Name) Stop-WebAppPool -Name $Name -ErrorAction Stop } @@ -696,22 +696,22 @@ function Set-TargetResource # Remove Application Pool if ($null -ne $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolFound -f $Name) if ($appPool.state -eq 'Started') { - Write-Verbose -Message ($script:localizedData['VerboseStopAppPool'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseStopAppPool -f $Name) Stop-WebAppPool -Name $Name -ErrorAction Stop } - Write-Verbose -Message ($script:localizedData['VerboseRemoveAppPool'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseRemoveAppPool -f $Name) Remove-WebAppPool -Name $Name -ErrorAction Stop } else { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolNotFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolNotFound -f $Name) } } } @@ -947,19 +947,19 @@ function Test-TargetResource if ($null -ne $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolFound -f $Name) } else { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolNotFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolNotFound -f $Name) } - Write-Verbose -Message ($script:localizedData['VerboseEnsureNotInDesiredState'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseEnsureNotInDesiredState -f $Name) } if ($Ensure -eq 'Present' -and $null -ne $appPool) { - Write-Verbose -Message ($script:localizedData['VerboseAppPoolFound'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseAppPoolFound -f $Name) $PropertyData.Where( { @@ -982,7 +982,7 @@ function Test-TargetResource if ($compareResult.Length -ne 0) { Write-Verbose -Message ( - $script:localizedData['VerbosePropertyNotInDesiredState'] -f $propertyName, $Name + $script:localizedData.VerbosePropertyNotInDesiredState -f $propertyName, $Name ) $inDesiredState = $false @@ -993,7 +993,7 @@ function Test-TargetResource ) { Write-Verbose -Message ( - $script:localizedData['VerbosePropertyNotInDesiredState'] -f $propertyName, $Name + $script:localizedData.VerbosePropertyNotInDesiredState -f $propertyName, $Name ) $inDesiredState = $false @@ -1008,7 +1008,7 @@ function Test-TargetResource if ($appPool.processModel.userName -ne $Credential.UserName) { Write-Verbose -Message ( - $script:localizedData['VerbosePropertyNotInDesiredState'] -f + $script:localizedData.VerbosePropertyNotInDesiredState -f 'Credential (userName)', $Name ) @@ -1020,7 +1020,7 @@ function Test-TargetResource if ($appPool.processModel.password -cne $clearTextPassword) { Write-Verbose -Message ( - $script:localizedData['VerbosePropertyNotInDesiredState'] -f + $script:localizedData.VerbosePropertyNotInDesiredState -f 'Credential (password)', $Name ) @@ -1029,7 +1029,7 @@ function Test-TargetResource } else { - Write-Verbose -Message ($script:localizedData['VerboseCredentialToBeIgnored']) + Write-Verbose -Message ($script:localizedData.VerboseCredentialToBeIgnored) } } @@ -1051,7 +1051,7 @@ function Test-TargetResource ) ) { - Write-Verbose -Message ($script:localizedData['VerboseCredentialToBeCleared'] -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseCredentialToBeCleared -f $Name) $inDesiredState = $false } @@ -1082,7 +1082,7 @@ function Test-TargetResource ) { Write-Verbose -Message ( - $script:localizedData['VerbosePropertyNotInDesiredState'] -f 'restartSchedule', $Name + $script:localizedData.VerbosePropertyNotInDesiredState -f 'restartSchedule', $Name ) $inDesiredState = $false @@ -1092,11 +1092,11 @@ function Test-TargetResource if ($inDesiredState -eq $true) { - Write-Verbose -Message ($script:localizedData['VerboseResourceInDesiredState']) + Write-Verbose -Message ($script:localizedData.VerboseResourceInDesiredState) } else { - Write-Verbose -Message ($script:localizedData['VerboseResourceNotInDesiredState']) + Write-Verbose -Message ($script:localizedData.VerboseResourceNotInDesiredState) } return $inDesiredState @@ -1164,7 +1164,7 @@ function Invoke-AppCmd if ($LASTEXITCODE -ne 0) { - $errorMessage = $script:localizedData['ErrorAppCmdNonZeroExitCode'] -f $LASTEXITCODE + $errorMessage = $script:localizedData.ErrorAppCmdNonZeroExitCode -f $LASTEXITCODE New-TerminatingError -ErrorId 'ErrorAppCmdNonZeroExitCode' ` -ErrorMessage $errorMessage ` diff --git a/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.schema.mof b/source/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.schema.mof rename to source/DSCResources/MSFT_xWebAppPool/MSFT_xWebAppPool.schema.mof diff --git a/DSCResources/MSFT_xWebAppPool/en-US/MSFT_xWebAppPool.strings.psd1 b/source/DSCResources/MSFT_xWebAppPool/en-US/MSFT_xWebAppPool.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xWebAppPool/en-US/MSFT_xWebAppPool.strings.psd1 rename to source/DSCResources/MSFT_xWebAppPool/en-US/MSFT_xWebAppPool.strings.psd1 diff --git a/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 b/source/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 similarity index 99% rename from DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 rename to source/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 index e90c42339..2f3e32a21 100644 --- a/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 +++ b/source/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.psm1 @@ -1045,12 +1045,7 @@ function Get-Value -Filter "system.applicationHost/applicationPools/applicationPoolDefaults$Path" ` -Name $Name - if ($result -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) - { - return $result.Value - } else { - return $result - } + return Get-WebConfigurationPropertyValue -WebConfigurationPropertyObject $result } #endregion diff --git a/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.schema.mof b/source/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.schema.mof rename to source/DSCResources/MSFT_xWebAppPoolDefaults/MSFT_xWebAppPoolDefaults.schema.mof diff --git a/DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 b/source/DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 similarity index 74% rename from DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 rename to source/DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 index 984a70db7..7d58d9591 100644 --- a/DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 +++ b/source/DSCResources/MSFT_xWebAppPoolDefaults/en-US/MSFT_xWebAppPoolDefaults.strings.psd1 @@ -1,6 +1,5 @@ # culture="en-US" ConvertFrom-StringData -StringData @' - NoWebAdministrationModule = Please ensure that WebAdministration module is installed. SettingValue = Changing default value '{0}' to '{1}' ValueOk = Default value '{0}' is already '{1}' VerboseGetTargetResource = Get-TargetResource has been run. diff --git a/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 b/source/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 similarity index 99% rename from DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 rename to source/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 index 8ec4bd249..4b8d5118d 100644 --- a/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 +++ b/source/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 @@ -165,8 +165,7 @@ function Set-TargetResource } # Update SslFlags if required - if ($PSBoundParameters.ContainsKey('SslFlags') -and ` - (-not (Test-SslFlags -Location "${Website}/${Name}" -SslFlags $SslFlags))) + if ($PSBoundParameters.ContainsKey('SslFlags') -and (-not (Test-SslFlags -Location "${Website}/${Name}" -SslFlags $SslFlags))) { Write-Verbose -Message ($script:localizedData.VerboseSetTargetSslFlags -f $Name) $params = @{ @@ -359,8 +358,7 @@ function Test-TargetResource } #Check SslFlags - if ($PSBoundParameters.ContainsKey('SslFlags') -and ` - (-not (Test-SslFlags -Location "${Website}/${Name}" -SslFlags $SslFlags))) + if ($PSBoundParameters.ContainsKey('SslFlags') -and (-not (Test-SslFlags -Location "${Website}/${Name}" -SslFlags $SslFlags))) { Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseSslFlags -f $Name) return $false @@ -419,11 +417,9 @@ function Test-TargetResource -f $Name) return $false } - } return $true - } <# diff --git a/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.schema.mof b/source/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.schema.mof rename to source/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.schema.mof diff --git a/DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 b/source/DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 similarity index 95% rename from DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 rename to source/DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 index 6863c3732..65ce34ab0 100644 --- a/DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 +++ b/source/DSCResources/MSFT_xWebApplication/en-US/MSFT_xWebApplication.strings.psd1 @@ -21,7 +21,6 @@ ConvertFrom-StringData -StringData @' VerboseTestTargetFalseAuthenticationInfo = AuthenticationInfo for web application "{0}" is not in the desired state. VerboseTestTargetFalsePreload = Preload for web application "{0}" is not in the desired state. VerboseTestTargetFalseAutostart = Autostart for web application "{0}" is not in the desired state. - VerboseTestTargetFalseAutoStartProviders = AutoStartProviders for web application "{0}" are not in the desired state. VerboseTestTargetFalseIISAutoStartProviders = AutoStartProviders for IIS are not in the desired state. VerboseTestTargetFalseWebApplicationAutoStartProviders = AutoStartProviders for web application "{0}" are not in the desired state. VerboseTestTargetFalseEnabledProtocols = EnabledProtocols for web application "{0}" are not in the desired state. diff --git a/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.psm1 b/source/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.psm1 similarity index 100% rename from DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.psm1 rename to source/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.psm1 diff --git a/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.schema.mof b/source/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.schema.mof rename to source/DSCResources/MSFT_xWebConfigKeyValue/MSFT_xWebConfigKeyValue.schema.mof diff --git a/DSCResources/MSFT_xWebConfigKeyValue/en-US/MSFT_xWebConfigKeyValue.strings.psd1 b/source/DSCResources/MSFT_xWebConfigKeyValue/en-US/MSFT_xWebConfigKeyValue.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xWebConfigKeyValue/en-US/MSFT_xWebConfigKeyValue.strings.psd1 rename to source/DSCResources/MSFT_xWebConfigKeyValue/en-US/MSFT_xWebConfigKeyValue.strings.psd1 diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/source/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 similarity index 97% rename from DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 rename to source/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 4c9ab5a60..28ba04240 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/source/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -236,14 +236,14 @@ function Test-TargetResource { # Property was found. Write-Verbose ` - -Message ($script:localizedData.VerboseTargetPropertyWasFound -f $PropertyName ) + -Message ($script:localizedData.VerboseTargetPropertyFound -f $PropertyName ) return $false } } Write-Verbose ` - -Message ($script:localizedData.VerboseTargetPropertyWasFound -f $PropertyName) + -Message ($script:localizedData.VerboseTargetPropertyFound -f $PropertyName) return $true } @@ -291,11 +291,7 @@ function Get-ItemValue -Name $PropertyName # Return the value of the property if located. - if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) - { - return $value.Value - } - return $value + return Get-WebConfigurationPropertyValue -WebConfigurationPropertyObject $value } <# diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/source/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof rename to source/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof diff --git a/DSCResources/MSFT_xWebConfigProperty/en-US/MSFT_xWebConfigProperty.strings.psd1 b/source/DSCResources/MSFT_xWebConfigProperty/en-US/MSFT_xWebConfigProperty.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xWebConfigProperty/en-US/MSFT_xWebConfigProperty.strings.psd1 rename to source/DSCResources/MSFT_xWebConfigProperty/en-US/MSFT_xWebConfigProperty.strings.psd1 diff --git a/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.psm1 b/source/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.psm1 similarity index 100% rename from DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.psm1 rename to source/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.psm1 diff --git a/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.schema.mof b/source/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.schema.mof rename to source/DSCResources/MSFT_xWebConfigPropertyCollection/MSFT_xWebConfigPropertyCollection.schema.mof diff --git a/DSCResources/MSFT_xWebConfigPropertyCollection/en-US/MSFT_xWebConfigPropertyCollection.strings.psd1 b/source/DSCResources/MSFT_xWebConfigPropertyCollection/en-US/MSFT_xWebConfigPropertyCollection.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xWebConfigPropertyCollection/en-US/MSFT_xWebConfigPropertyCollection.strings.psd1 rename to source/DSCResources/MSFT_xWebConfigPropertyCollection/en-US/MSFT_xWebConfigPropertyCollection.strings.psd1 diff --git a/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 b/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 similarity index 90% rename from DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 rename to source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 index 12871374f..e0ad6352a 100644 --- a/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 +++ b/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 @@ -36,12 +36,12 @@ function Get-TargetResource if ($website.Count -eq 0) { - Write-Verbose -Message ($LocalizedData.VerboseGetTargetAbsent) + Write-Verbose -Message ($script:localizedData.VerboseGetTargetAbsent) $ensureResult = 'Absent' } elseif ($website.Count -eq 1) { - Write-Verbose -Message ($LocalizedData.VerboseGetTargetPresent) + Write-Verbose -Message ($script:localizedData.VerboseGetTargetPresent) $ensureResult = 'Present' $cimBindings = @(ConvertTo-CimBinding -InputObject $website.bindings.Collection) @@ -68,7 +68,7 @@ function Get-TargetResource # Multiple websites with the same name exist. This is not supported and is an error else { - $errorMessage = $LocalizedData.ErrorWebsiteDiscoveryFailure -f $Name + $errorMessage = $script:localizedData.ErrorWebsiteDiscoveryFailure -f $Name New-TerminatingError -ErrorId 'WebsiteDiscoveryFailure' ` -ErrorMessage $errorMessage ` -ErrorCategory 'InvalidResult' @@ -241,7 +241,7 @@ function Set-TargetResource -Name id ` -Value $SiteId ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedSiteId ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedSiteId ` -f $Name, $SiteId) } @@ -253,7 +253,7 @@ function Set-TargetResource -Name physicalPath ` -Value $PhysicalPath ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedPhysicalPath ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedPhysicalPath ` -f $Name, $PhysicalPath) } @@ -265,7 +265,7 @@ function Set-TargetResource -Name applicationPool ` -Value $ApplicationPool ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedApplicationPool ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedApplicationPool ` -f $Name, $ApplicationPool) } @@ -278,7 +278,7 @@ function Set-TargetResource { Update-WebsiteBinding -Name $Name ` -BindingInfo $BindingInfo - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedBindingInfo ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedBindingInfo ` -f $Name) } } @@ -291,7 +291,7 @@ function Set-TargetResource -Name enabledProtocols ` -Value $EnabledProtocols ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedEnabledProtocols ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedEnabledProtocols ` -f $Name, $EnabledProtocols) } @@ -314,7 +314,7 @@ function Set-TargetResource if (-not (Confirm-UniqueBinding -Name $Name -ExcludeStopped)) { # Return error and do not start the website - $errorMessage = $LocalizedData.ErrorWebsiteBindingConflictOnStart ` + $errorMessage = $script:localizedData.ErrorWebsiteBindingConflictOnStart ` -f $Name New-TerminatingError -ErrorId 'WebsiteBindingConflictOnStart' ` -ErrorMessage $errorMessage ` @@ -327,7 +327,7 @@ function Set-TargetResource } catch { - $errorMessage = $LocalizedData.ErrorWebsiteStateFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteStateFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteStateFailure' ` -ErrorMessage $errorMessage ` @@ -342,7 +342,7 @@ function Set-TargetResource } catch { - $errorMessage = $LocalizedData.ErrorWebsiteStateFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteStateFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteStateFailure' ` -ErrorMessage $errorMessage ` @@ -350,7 +350,7 @@ function Set-TargetResource } } - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedState ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedState ` -f $Name, $State) } @@ -362,7 +362,7 @@ function Set-TargetResource -Name serverAutoStart ` -Value $ServerAutoStart ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsiteAutoStartUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteAutoStartUpdated ` -f $Name) } } @@ -399,12 +399,12 @@ function Set-TargetResource $website = New-Website @newWebsiteSplat -ErrorAction Stop } - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsiteCreated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteCreated ` -f $Name) } catch { - $errorMessage = $LocalizedData.ErrorWebsiteCreationFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteCreationFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteCreationFailure' ` -ErrorMessage $errorMessage ` @@ -421,7 +421,7 @@ function Set-TargetResource -BindingInfo $BindingInfo)) { Update-WebsiteBinding -Name $Name -BindingInfo $BindingInfo - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedBindingInfo ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedBindingInfo ` -f $Name) } } @@ -435,7 +435,7 @@ function Set-TargetResource -Name enabledProtocols ` -Value $EnabledProtocols ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdatedEnabledProtocols ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdatedEnabledProtocols ` -f $Name, $EnabledProtocols) } @@ -455,7 +455,7 @@ function Set-TargetResource if (-not (Confirm-UniqueBinding -Name $Name -ExcludeStopped)) { # Return error and do not start the website - $errorMessage = $LocalizedData.ErrorWebsiteBindingConflictOnStart ` + $errorMessage = $script:localizedData.ErrorWebsiteBindingConflictOnStart ` -f $Name New-TerminatingError -ErrorId 'WebsiteBindingConflictOnStart' ` -ErrorMessage $errorMessage ` @@ -465,12 +465,12 @@ function Set-TargetResource try { Start-Website -Name $Name -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsiteStarted ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteStarted ` -f $Name) } catch { - $errorMessage = $LocalizedData.ErrorWebsiteStateFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteStateFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteStateFailure' ` -ErrorMessage $errorMessage ` @@ -486,7 +486,7 @@ function Set-TargetResource -Name serverAutoStart ` -Value $ServerAutoStart ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsiteAutoStartUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteAutoStartUpdated ` -f $Name) } } @@ -499,7 +499,7 @@ function Set-TargetResource Set-AuthenticationInfo -Site $Name ` -AuthenticationInfo $AuthenticationInfo ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetAuthenticationInfoUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetAuthenticationInfoUpdated ` -f $Name) } @@ -511,7 +511,7 @@ function Set-TargetResource -Name applicationDefaults.preloadEnabled ` -Value $PreloadEnabled ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsitePreloadUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsitePreloadUpdated ` -f $Name) } @@ -523,7 +523,7 @@ function Set-TargetResource -Name applicationDefaults.serviceAutoStartEnabled ` -Value $ServiceAutoStartEnabled ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetServiceAutoStartUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteAutoStartUpdated ` -f $Name) } @@ -543,13 +543,13 @@ function Set-TargetResource } ` -ErrorAction Stop Write-Verbose -Message ` - ($LocalizedData.VerboseSetTargetIISAutoStartProviderUpdated) + ($script:localizedData.VerboseSetTargetIISAutoStartProviderUpdated) } Set-ItemProperty -Path "IIS:\Sites\$Name" ` -Name applicationDefaults.serviceAutoStartProvider ` -Value $ServiceAutoStartProvider -ErrorAction Stop Write-Verbose -Message ` - ($LocalizedData.VerboseSetTargetServiceAutoStartProviderUpdated ` + ($script:localizedData.VerboseSetTargetServiceAutoStartProviderUpdated ` -f $Name) } @@ -557,7 +557,7 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogFormat') -and ` ($LogFormat -ne $website.logfile.LogFormat)) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogFormat -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogFormat -f $Name) # In Windows Server 2008 R2, Set-ItemProperty only accepts index values to the LogFile.LogFormat property $site = Get-Item "IIS:\Sites\$Name" @@ -574,7 +574,7 @@ function Set-TargetResource -Name logfile.logTargetW3C ` -Value $LogTargetW3C ` -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogTargetW3C ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogTargetW3C ` -f $Name, $LogTargetW3C) } @@ -582,7 +582,7 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogFlags') -and ` (-not (Compare-LogFlags -Name $Name -LogFlags $LogFlags))) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogFlags ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogFlags ` -f $Name) # Set-ItemProperty has no effect with the LogFile.LogExtFileFlags property @@ -596,7 +596,7 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogPath') -and ` ($LogPath -ne $website.logfile.directory)) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogPath ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogPath ` -f $Name) Set-ItemProperty -Path "IIS:\Sites\$Name" ` -Name LogFile.directory -value $LogPath @@ -608,11 +608,11 @@ function Set-TargetResource { if ($PSBoundParameters.ContainsKey('LogTruncateSize')) { - Write-Verbose -Message ($LocalizedData.WarningLogPeriod ` + Write-Verbose -Message ($script:localizedData.WarningLogPeriod ` -f $Name) } - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogPeriod) + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogPeriod) # In Windows Server 2008 R2, Set-ItemProperty only accepts index values to the LogFile.Period property $site = Get-Item "IIS:\Sites\$Name" @@ -624,7 +624,7 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogTruncateSize') -and ` ($LogTruncateSize -ne $website.logfile.LogTruncateSize)) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogTruncateSize ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogTruncateSize ` -f $Name) Set-ItemProperty -Path "IIS:\Sites\$Name" ` -Name LogFile.truncateSize -Value $LogTruncateSize @@ -637,7 +637,7 @@ function Set-TargetResource ($LoglocalTimeRollover -ne ` ([System.Convert]::ToBoolean($website.logfile.LocalTimeRollover)))) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLoglocalTimeRollover ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLoglocalTimeRollover ` -f $Name) Set-ItemProperty -Path "IIS:\Sites\$Name" ` -Name LogFile.localTimeRollover -Value $LoglocalTimeRollover @@ -647,7 +647,7 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogCustomFields') -and ` (-not (Test-LogCustomField -Site $Name -LogCustomField $LogCustomFields))) { - Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogCustomFields ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetUpdateLogCustomFields ` -f $Name) Set-LogCustomField -Site $Name -LogCustomField $LogCustomFields } @@ -658,12 +658,12 @@ function Set-TargetResource try { Remove-Website -Name $Name -ErrorAction Stop - Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebsiteRemoved ` + Write-Verbose -Message ($script:localizedData.VerboseSetTargetWebsiteRemoved ` -f $Name) } catch { - $errorMessage = $LocalizedData.ErrorWebsiteRemovalFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteRemovalFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteRemovalFailure' ` -ErrorMessage $errorMessage ` @@ -803,7 +803,7 @@ function Test-TargetResource ($Ensure -eq 'Absent' -and $null -ne $website)) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseEnsure ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseEnsure ` -f $Name) } @@ -815,7 +815,7 @@ function Test-TargetResource if ($SiteId -gt 0 -and $website.Id -ne $SiteId) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseSiteId -f $Name) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseSiteId -f $Name) } # Check Physical Path property @@ -823,7 +823,7 @@ function Test-TargetResource $website.PhysicalPath -ne $PhysicalPath) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalsePhysicalPath ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalsePhysicalPath ` -f $Name) } @@ -831,7 +831,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('State') -and $website.State -ne $State) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseState ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseState ` -f $Name) } @@ -840,7 +840,7 @@ function Test-TargetResource $website.ApplicationPool -ne $ApplicationPool) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseApplicationPool ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseApplicationPool ` -f $Name) } @@ -851,7 +851,7 @@ function Test-TargetResource if (-not (Test-WebsiteBinding -Name $Name -BindingInfo $BindingInfo)) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseBindingInfo ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseBindingInfo ` -f $Name) } } @@ -861,7 +861,7 @@ function Test-TargetResource $website.EnabledProtocols -ne $EnabledProtocols) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseEnabledProtocols ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseEnabledProtocols ` -f $Name) } @@ -880,7 +880,7 @@ function Test-TargetResource if ($allDefaultPages -inotcontains $page) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseDefaultPage ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseDefaultPage ` -f $Name) } } @@ -891,7 +891,7 @@ function Test-TargetResource $website.serverAutoStart -ne $ServerAutoStart) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseAutoStart ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseAutoStart ` -f $Name) } @@ -901,7 +901,7 @@ function Test-TargetResource -AuthenticationInfo $AuthenticationInfo))) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseAuthenticationInfo) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseAuthenticationInfo) } #Check Preload @@ -909,7 +909,7 @@ function Test-TargetResource $website.applicationDefaults.preloadEnabled -ne $PreloadEnabled) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalsePreload ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalsePreload ` -f $Name) } @@ -918,7 +918,7 @@ function Test-TargetResource $website.applicationDefaults.serviceAutoStartEnabled -ne $ServiceAutoStartEnabled) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseServiceAutoStart ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseServiceAutoStart ` -f $Name) } @@ -931,7 +931,7 @@ function Test-TargetResource -ApplicationType $ApplicationType)) { $inDesiredState = $false - Write-Verbose -Message ($LocalizedData.VerboseSetTargetIISAutoStartProviderUpdated) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseIISAutoStartProvider) } } @@ -942,7 +942,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogFlags') -and ` $LogFormat -ne 'W3C') { - Write-Verbose -Message ($LocalizedData.WarningIncorrectLogFormat ` + Write-Verbose -Message ($script:localizedData.WarningIncorrectLogFormat ` -f $Name) } @@ -950,14 +950,14 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogFlags') -and ` $website.logfile.LogFormat -ne 'W3C') { - Write-Verbose -Message ($LocalizedData.WarningIncorrectLogFormat ` + Write-Verbose -Message ($script:localizedData.WarningIncorrectLogFormat ` -f $Name) } # Check Log Format if ($LogFormat -ne $website.logfile.LogFormat) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogFormat ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogFormat ` -f $Name) return $false } @@ -967,7 +967,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogFlags') -and ` (-not (Compare-LogFlags -Name $Name -LogFlags $LogFlags))) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogFlags) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogFlags) return $false } @@ -975,7 +975,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogPath') -and ` ($LogPath -ne $website.logfile.directory)) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogPath ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogPath ` -f $Name) return $false } @@ -986,11 +986,11 @@ function Test-TargetResource { if ($PSBoundParameters.ContainsKey('LogTruncateSize')) { - Write-Verbose -Message ($LocalizedData.WarningLogPeriod ` + Write-Verbose -Message ($script:localizedData.WarningLogPeriod ` -f $Name) } - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogPeriod ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogPeriod ` -f $Name) return $false } @@ -999,7 +999,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogTruncateSize') -and ` ($LogTruncateSize -ne $website.logfile.LogTruncateSize)) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogTruncateSize ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogTruncateSize ` -f $Name) return $false } @@ -1009,7 +1009,7 @@ function Test-TargetResource ($LoglocalTimeRollover -ne ` ([System.Convert]::ToBoolean($website.logfile.LocalTimeRollover)))) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLoglocalTimeRollover ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLoglocalTimeRollover ` -f $Name) return $false } @@ -1018,7 +1018,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogTargetW3C') -and ` ($LogTargetW3C -ne $website.logfile.LogTargetW3C)) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogTargetW3C ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseLogTargetW3C ` -f $Name) return $false } @@ -1027,7 +1027,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogCustomFields') -and ` (-not (Test-LogCustomField -Site $Name -LogCustomField $LogCustomFields))) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetUpdateLogCustomFields ` + Write-Verbose -Message ($script:localizedData.VerboseTestTargetUpdateLogCustomFields ` -f $Name) return $false } @@ -1035,11 +1035,11 @@ function Test-TargetResource if ($inDesiredState -eq $true) { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetTrueResult) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetTrueResult) } else { - Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseResult) + Write-Verbose -Message ($script:localizedData.VerboseTestTargetFalseResult) } return $inDesiredState @@ -1125,7 +1125,7 @@ function Confirm-UniqueBinding if (-not $website) { - $errorMessage = $LocalizedData.ErrorWebsiteNotFound ` + $errorMessage = $script:localizedData.ErrorWebsiteNotFound ` -f $Name New-TerminatingError -ErrorId 'WebsiteNotFound' ` -ErrorMessage $errorMessage ` @@ -1231,7 +1231,7 @@ function Confirm-UniqueServiceAutoStartProviders -DifferenceObject $proposedObject ` -Property type) { - $errorMessage = $LocalizedData.ErrorWebsiteTestAutoStartProviderFailure + $errorMessage = $script:localizedData.ErrorWebsiteTestAutoStartProviderFailure New-TerminatingError -ErrorId 'ErrorWebsiteTestAutoStartProviderFailure' ` -ErrorMessage $errorMessage ` -ErrorCategory 'InvalidResult'` @@ -1360,7 +1360,7 @@ function ConvertTo-WebBinding { $isJoinRequired = $true Write-Verbose -Message ` - ($LocalizedData.VerboseConvertToWebBindingIgnoreBindingInformation ` + ($script:localizedData.VerboseConvertToWebBindingIgnoreBindingInformation ` -f $binding.Protocol) } else @@ -1388,7 +1388,7 @@ function ConvertTo-WebBinding } Write-Verbose -Message ` - ($LocalizedData.VerboseConvertToWebBindingDefaultPort ` + ($script:localizedData.VerboseConvertToWebBindingDefaultPort ` -f $binding.Protocol, $portNumberString) } else @@ -1399,7 +1399,7 @@ function ConvertTo-WebBinding } else { - $errorMessage = $LocalizedData.ErrorWebBindingInvalidPort ` + $errorMessage = $script:localizedData.ErrorWebBindingInvalidPort ` -f $binding.Port New-TerminatingError -ErrorId 'WebBindingInvalidPort' ` -ErrorMessage $errorMessage ` @@ -1421,7 +1421,7 @@ function ConvertTo-WebBinding { if ([String]::IsNullOrEmpty($binding.BindingInformation)) { - $errorMessage = $LocalizedData.ErrorWebBindingMissingBindingInformation ` + $errorMessage = $script:localizedData.ErrorWebBindingMissingBindingInformation ` -f $binding.Protocol New-TerminatingError -ErrorId 'WebBindingMissingBindingInformation' ` -ErrorMessage $errorMessage ` @@ -1450,7 +1450,7 @@ function ConvertTo-WebBinding } else { - $errorMessage = $LocalizedData.ErrorWebBindingMissingCertificateThumbprint ` + $errorMessage = $script:localizedData.ErrorWebBindingMissingCertificateThumbprint ` -f $binding.Protocol New-TerminatingError -ErrorId 'WebBindingMissingCertificateThumbprint' ` -ErrorMessage $errorMessage ` @@ -1462,7 +1462,7 @@ function ConvertTo-WebBinding { $certificateStoreName = 'MY' Write-Verbose -Message ` - ($LocalizedData.VerboseConvertToWebBindingDefaultCertificateStoreName ` + ($script:localizedData.VerboseConvertToWebBindingDefaultCertificateStoreName ` -f $certificateStoreName) } else @@ -1481,7 +1481,7 @@ function ConvertTo-WebBinding } else { - $errorMessage = $LocalizedData.ErrorWebBindingInvalidCertificateSubject ` + $errorMessage = $script:localizedData.ErrorWebBindingInvalidCertificateSubject ` -f $binding.CertificateSubject, $binding.CertificateStoreName New-TerminatingError -ErrorId 'WebBindingInvalidCertificateSubject' ` -ErrorMessage $errorMessage ` @@ -1508,7 +1508,7 @@ function ConvertTo-WebBinding if ($sslFlags -in @(1, 3) -and [String]::IsNullOrEmpty($binding.HostName)) { - $errorMessage = $LocalizedData.ErrorWebBindingMissingSniHostName + $errorMessage = $script:localizedData.ErrorWebBindingMissingSniHostName New-TerminatingError -ErrorId 'WebBindingMissingSniHostName' ` -ErrorMessage $errorMessage ` -ErrorCategory 'InvalidArgument' @@ -1640,7 +1640,7 @@ function Format-IPAddressString } catch { - $errorMessage = $LocalizedData.ErrorWebBindingInvalidIPAddress ` + $errorMessage = $script:localizedData.ErrorWebBindingInvalidIPAddress ` -f $InputString, $_.Exception.Message New-TerminatingError -ErrorId 'WebBindingInvalidIPAddress' ` -ErrorMessage $errorMessage ` @@ -1914,12 +1914,11 @@ function Test-BindingInfo if ($standardBindings.Count -ne 0) { # IP address, port, and host name combination must be unique - if (($standardBindings | Group-Object -Property IPAddress, Port, HostName) | ` - Where-Object -FilterScript {$_.Count -ne 1}) + if (($standardBindings | Group-Object -Property IPAddress, Port, HostName) | Where-Object -FilterScript {$_.Count -ne 1}) { $isValid = $false Write-Verbose -Message ` - ($LocalizedData.VerboseTestBindingInfoSameIPAddressPortHostName) + ($script:localizedData.VerboseTestBindingInfoSameIPAddressPortHostName) } # A single port cannot be simultaneously specified for bindings with different protocols @@ -1929,7 +1928,7 @@ function Test-BindingInfo { $isValid = $false Write-Verbose -Message ` - ($LocalizedData.VerboseTestBindingInfoSamePortDifferentProtocol) + ($script:localizedData.VerboseTestBindingInfoSamePortDifferentProtocol) break } } @@ -1943,14 +1942,14 @@ function Test-BindingInfo { $isValid = $false Write-Verbose -Message ` - ($LocalizedData.VerboseTestBindingInfoSameProtocolBindingInformation) + ($script:localizedData.VerboseTestBindingInfoSameProtocolBindingInformation) } } } catch { $isValid = $false - Write-Verbose -Message ($LocalizedData.VerboseTestBindingInfoInvalidCatch ` + Write-Verbose -Message ($script:localizedData.VerboseTestBindingInfoInvalidCatch ` -f $_.Exception.Message) } @@ -2014,7 +2013,7 @@ function Test-WebsiteBinding # host name combinations). if (-not (Test-BindingInfo -BindingInfo $BindingInfo)) { - $errorMessage = $LocalizedData.ErrorWebsiteBindingInputInvalidation ` + $errorMessage = $script:localizedData.ErrorWebsiteBindingInputInvalidation ` -f $Name New-TerminatingError -ErrorId 'WebsiteBindingInputInvalidation' ` -ErrorMessage $errorMessage ` @@ -2052,7 +2051,7 @@ function Test-WebsiteBinding } catch { - $errorMessage = $LocalizedData.ErrorWebsiteCompareFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteCompareFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteCompareFailure' ` -ErrorMessage $errorMessage ` @@ -2146,7 +2145,7 @@ function Update-DefaultPage -Value @{ value = $page } - Write-Verbose -Message ($LocalizedData.VerboseUpdateDefaultPageUpdated ` + Write-Verbose -Message ($script:localizedData.VerboseUpdateDefaultPageUpdated ` -f $Name, $page) } } @@ -2178,7 +2177,7 @@ function Update-WebsiteBinding if (-not $website) { - $errorMessage = $LocalizedData.ErrorWebsiteNotFound ` + $errorMessage = $script:localizedData.ErrorWebsiteNotFound ` -f $Name New-TerminatingError -ErrorId 'WebsiteNotFound' ` -ErrorMessage $errorMessage ` @@ -2201,7 +2200,7 @@ function Update-WebsiteBinding } catch { - $errorMessage = $LocalizedData.ErrorWebsiteBindingUpdateFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteBindingUpdateFailure ` -f $Name, $_.Exception.Message New-TerminatingError -ErrorId 'WebsiteBindingUpdateFailure' ` -ErrorMessage $errorMessage ` @@ -2223,7 +2222,7 @@ function Update-WebsiteBinding } catch { - $errorMessage = $LocalizedData.ErrorWebsiteBindingUpdateFailure ` + $errorMessage = $script:localizedData.ErrorWebsiteBindingUpdateFailure ` -f $Name, $_.Exception.Message New-TerminatingError ` -ErrorId 'WebsiteBindingUpdateFailure' ` @@ -2242,7 +2241,7 @@ function Update-WebsiteBinding } catch { - $errorMessage = $LocalizedData.ErrorWebBindingCertificate ` + $errorMessage = $script:localizedData.ErrorWebBindingCertificate ` -f $properties.certificateHash, $_.Exception.Message New-TerminatingError ` -ErrorId 'WebBindingCertificate' ` diff --git a/DSCResources/MSFT_xWebSite/MSFT_xWebSite.schema.mof b/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebSite/MSFT_xWebSite.schema.mof rename to source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.schema.mof diff --git a/DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 b/source/DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 similarity index 94% rename from DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 rename to source/DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 index f4a177c7c..7812c3ba5 100644 --- a/DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 +++ b/source/DSCResources/MSFT_xWebSite/en-US/MSFT_xWebSite.strings.psd1 @@ -16,9 +16,6 @@ ConvertFrom-StringData -StringData @' ErrorWebBindingMissingCertificateThumbprint = The CertificateThumbprint property is required for bindings of type "{0}". ErrorWebBindingMissingSniHostName = The HostName property is required for use with Server Name Indication. ErrorWebBindingInvalidCertificateSubject = The Subject "{0}" provided is not found on this host in store "{1}" - ErrorWebsitePreloadFailure = Failure to set Preload on Website "{0}". Error: "{1}". - ErrorWebsiteAutoStartFailure = Failure to set AutoStart on Website "{0}". Error: "{1}". - ErrorWebsiteAutoStartProviderFailure = Failure to set AutoStartProvider on Website "{0}". Error: "{1}". ErrorWebsiteTestAutoStartProviderFailure = Desired AutoStartProvider is not valid due to a conflicting Global Property. Ensure that the serviceAutoStartProvider is a unique key." VerboseSetTargetUpdatedSiteId = Site Id for website "{0}" has been updated to "{1}". VerboseSetTargetUpdatedPhysicalPath = Physical Path for website "{0}" has been updated to "{1}". @@ -59,7 +56,6 @@ ConvertFrom-StringData -StringData @' VerboseTestTargetFalseServiceAutoStart = Application AutoStart for website "{0}" do not match the desired state. VerboseTestTargetFalseAuthenticationInfo = AuthenticationInfo for website "{0}" is not in the desired state. VerboseTestTargetFalseIISAutoStartProvider = AutoStartProvider for IIS is not in the desired state - VerboseTestTargetFalseWebsiteAutoStartProvider = AutoStartProvider for website "{0}" is not in the desired state VerboseTestTargetFalseLogPath = LogPath does not match desired state on Website "{0}". VerboseTestTargetFalseLogFlags = LogFlags does not match desired state on Website "{0}". VerboseTestTargetFalseLogPeriod = LogPeriod does not match desired state on Website "{0}". @@ -67,7 +63,6 @@ ConvertFrom-StringData -StringData @' VerboseTestTargetFalseLoglocalTimeRollover = LoglocalTimeRollover does not match desired state on Website "{0}". VerboseTestTargetFalseLogFormat = LogFormat does not match desired state on Website "{0}". VerboseTestTargetFalseLogTargetW3C = LogTargetW3C does not match desired state on Website "{0}". - VerboseTestTargetFalseLogCustomFields = LogCustomFields does not match desired state on Website "{0}". VerboseConvertToWebBindingIgnoreBindingInformation = BindingInformation is ignored for bindings of type "{0}" in case at least one of the following properties is specified: IPAddress, Port, HostName. VerboseConvertToWebBindingDefaultPort = Port is not specified. The default "{0}" port "{1}" will be used. VerboseConvertToWebBindingDefaultCertificateStoreName = CertificateStoreName is not specified. The default value "{0}" will be used. @@ -78,4 +73,5 @@ ConvertFrom-StringData -StringData @' VerboseUpdateDefaultPageUpdated = Default page for website "{0}" has been updated to "{1}". WarningLogPeriod = LogTruncateSize has is an input as will overwrite this desired state on Website "{0}". WarningIncorrectLogFormat = LogFormat is not W3C, as a result LogFlags will not be used on Website "{0}". + VerboseTestTargetUpdateLogCustomFields = LogCustomFields does not match desired state on Website "{0}". '@ diff --git a/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1 b/source/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1 similarity index 100% rename from DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1 rename to source/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.psm1 diff --git a/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.schema.mof b/source/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.schema.mof rename to source/DSCResources/MSFT_xWebSiteDefaults/MSFT_xWebSiteDefaults.schema.mof diff --git a/DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 b/source/DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 similarity index 74% rename from DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 rename to source/DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 index bc786e337..a8415efc3 100644 --- a/DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 +++ b/source/DSCResources/MSFT_xWebSiteDefaults/en-US/MSFT_xWebSiteDefaults.strings.psd1 @@ -1,6 +1,5 @@ # culture="en-US" ConvertFrom-StringData -StringData @' - NoWebAdministrationModule = Please ensure that WebAdministration module is installed. SettingValue = Changing default Value '{0}' to '{1}' ValueOk = Default Value '{0}' is already '{1}' VerboseGetTargetResource = Get-TargetResource has been run. diff --git a/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 b/source/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 similarity index 100% rename from DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 rename to source/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 diff --git a/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.schema.mof b/source/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.schema.mof similarity index 100% rename from DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.schema.mof rename to source/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.schema.mof diff --git a/DSCResources/MSFT_xWebVirtualDirectory/en-US/MSFT_xWebVirtualDirectory.strings.psd1 b/source/DSCResources/MSFT_xWebVirtualDirectory/en-US/MSFT_xWebVirtualDirectory.strings.psd1 similarity index 100% rename from DSCResources/MSFT_xWebVirtualDirectory/en-US/MSFT_xWebVirtualDirectory.strings.psd1 rename to source/DSCResources/MSFT_xWebVirtualDirectory/en-US/MSFT_xWebVirtualDirectory.strings.psd1 diff --git a/Examples/Resources/Sample_EndToEndxWebAdministration.ps1 b/source/Examples/Resources/Sample_EndToEndxWebAdministration.ps1 similarity index 100% rename from Examples/Resources/Sample_EndToEndxWebAdministration.ps1 rename to source/Examples/Resources/Sample_EndToEndxWebAdministration.ps1 diff --git a/Examples/Resources/WebApplicationHandler/Sample_WebApplicationHandler.ps1 b/source/Examples/Resources/WebApplicationHandler/Sample_WebApplicationHandler.ps1 similarity index 100% rename from Examples/Resources/WebApplicationHandler/Sample_WebApplicationHandler.ps1 rename to source/Examples/Resources/WebApplicationHandler/Sample_WebApplicationHandler.ps1 diff --git a/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisConfigurationPathFormat.ps1 b/source/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisConfigurationPathFormat.ps1 similarity index 100% rename from Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisConfigurationPathFormat.ps1 rename to source/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisConfigurationPathFormat.ps1 diff --git a/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisModulePathFormat.ps1 b/source/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisModulePathFormat.ps1 similarity index 100% rename from Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisModulePathFormat.ps1 rename to source/Examples/Resources/xIisFeatureDelegation/Sample_xIisFeatureDelegation_IisModulePathFormat.ps1 diff --git a/Examples/Resources/xIisHandler/Sample_xIisHandler_Remove32Bit.ps1 b/source/Examples/Resources/xIisHandler/Sample_xIisHandler_Remove32Bit.ps1 similarity index 100% rename from Examples/Resources/xIisHandler/Sample_xIisHandler_Remove32Bit.ps1 rename to source/Examples/Resources/xIisHandler/Sample_xIisHandler_Remove32Bit.ps1 diff --git a/Examples/Resources/xIisLogging/Sample_xIisLogging_Rollover.ps1 b/source/Examples/Resources/xIisLogging/Sample_xIisLogging_Rollover.ps1 similarity index 100% rename from Examples/Resources/xIisLogging/Sample_xIisLogging_Rollover.ps1 rename to source/Examples/Resources/xIisLogging/Sample_xIisLogging_Rollover.ps1 diff --git a/Examples/Resources/xIisLogging/Sample_xIisLogging_Truncate.ps1 b/source/Examples/Resources/xIisLogging/Sample_xIisLogging_Truncate.ps1 similarity index 100% rename from Examples/Resources/xIisLogging/Sample_xIisLogging_Truncate.ps1 rename to source/Examples/Resources/xIisLogging/Sample_xIisLogging_Truncate.ps1 diff --git a/Examples/Resources/xIisMimeTypeMapping/Sample_xIisMimeTypeMapping_RemoveVideo.ps1 b/source/Examples/Resources/xIisMimeTypeMapping/Sample_xIisMimeTypeMapping_RemoveVideo.ps1 similarity index 100% rename from Examples/Resources/xIisMimeTypeMapping/Sample_xIisMimeTypeMapping_RemoveVideo.ps1 rename to source/Examples/Resources/xIisMimeTypeMapping/Sample_xIisMimeTypeMapping_RemoveVideo.ps1 diff --git a/Examples/Resources/xIisServerDefaults/Sample_xIisServerDefaults.ps1 b/source/Examples/Resources/xIisServerDefaults/Sample_xIisServerDefaults.ps1 similarity index 100% rename from Examples/Resources/xIisServerDefaults/Sample_xIisServerDefaults.ps1 rename to source/Examples/Resources/xIisServerDefaults/Sample_xIisServerDefaults.ps1 diff --git a/Examples/Resources/xSslSettings/Sample_xSslSettings_RequireCert.ps1 b/source/Examples/Resources/xSslSettings/Sample_xSslSettings_RequireCert.ps1 similarity index 100% rename from Examples/Resources/xSslSettings/Sample_xSslSettings_RequireCert.ps1 rename to source/Examples/Resources/xSslSettings/Sample_xSslSettings_RequireCert.ps1 diff --git a/Examples/Resources/xWebAppPool/Sample_xWebAppPool.ps1 b/source/Examples/Resources/xWebAppPool/Sample_xWebAppPool.ps1 similarity index 100% rename from Examples/Resources/xWebAppPool/Sample_xWebAppPool.ps1 rename to source/Examples/Resources/xWebAppPool/Sample_xWebAppPool.ps1 diff --git a/Examples/Resources/xWebAppPoolDefaults/Sample_xWebAppPoolDefaults.ps1 b/source/Examples/Resources/xWebAppPoolDefaults/Sample_xWebAppPoolDefaults.ps1 similarity index 100% rename from Examples/Resources/xWebAppPoolDefaults/Sample_xWebAppPoolDefaults.ps1 rename to source/Examples/Resources/xWebAppPoolDefaults/Sample_xWebAppPoolDefaults.ps1 diff --git a/Examples/Resources/xWebApplication/Sample_xWebApplication.ps1 b/source/Examples/Resources/xWebApplication/Sample_xWebApplication.ps1 similarity index 100% rename from Examples/Resources/xWebApplication/Sample_xWebApplication.ps1 rename to source/Examples/Resources/xWebApplication/Sample_xWebApplication.ps1 diff --git a/Examples/Resources/xWebApplication/Sample_xWebApplication_NewWebApplication.ps1 b/source/Examples/Resources/xWebApplication/Sample_xWebApplication_NewWebApplication.ps1 similarity index 100% rename from Examples/Resources/xWebApplication/Sample_xWebApplication_NewWebApplication.ps1 rename to source/Examples/Resources/xWebApplication/Sample_xWebApplication_NewWebApplication.ps1 diff --git a/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_AddAppSetting.ps1 b/source/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_AddAppSetting.ps1 similarity index 100% rename from Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_AddAppSetting.ps1 rename to source/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_AddAppSetting.ps1 diff --git a/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_RemoveAppSetting.ps1 b/source/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_RemoveAppSetting.ps1 similarity index 100% rename from Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_RemoveAppSetting.ps1 rename to source/Examples/Resources/xWebConfigKeyValue/Sample_xWebConfigKeyValue_RemoveAppSetting.ps1 diff --git a/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Add.ps1 b/source/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Add.ps1 similarity index 100% rename from Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Add.ps1 rename to source/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Add.ps1 diff --git a/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Remove.ps1 b/source/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Remove.ps1 similarity index 100% rename from Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Remove.ps1 rename to source/Examples/Resources/xWebConfigProperty/Sample_xWebConfigProperty_Remove.ps1 diff --git a/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Add.ps1 b/source/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Add.ps1 similarity index 100% rename from Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Add.ps1 rename to source/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Add.ps1 diff --git a/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Remove.ps1 b/source/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Remove.ps1 similarity index 100% rename from Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Remove.ps1 rename to source/Examples/Resources/xWebConfigPropertyCollection/Sample_xWebConfigPropertyCollection_Remove.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsiteFromConfigurationData.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsiteFromConfigurationData.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_NewWebsiteFromConfigurationData.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsiteFromConfigurationData.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateSubject.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateSubject.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateSubject.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateSubject.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateThumbprint.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateThumbprint.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateThumbprint.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_NewWebsite_UsingCertificateThumbprint.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_RemoveDefault.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_RemoveDefault.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_RemoveDefault.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_RemoveDefault.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_StopDefault.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_StopDefault.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_StopDefault.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_StopDefault.ps1 diff --git a/Examples/Resources/xWebSite/Sample_xWebSite_WithSSLFlags.ps1 b/source/Examples/Resources/xWebSite/Sample_xWebSite_WithSSLFlags.ps1 similarity index 100% rename from Examples/Resources/xWebSite/Sample_xWebSite_WithSSLFlags.ps1 rename to source/Examples/Resources/xWebSite/Sample_xWebSite_WithSSLFlags.ps1 diff --git a/Examples/Resources/xWebSiteDefaults/Sample_xWebSiteDefaults.ps1 b/source/Examples/Resources/xWebSiteDefaults/Sample_xWebSiteDefaults.ps1 similarity index 100% rename from Examples/Resources/xWebSiteDefaults/Sample_xWebSiteDefaults.ps1 rename to source/Examples/Resources/xWebSiteDefaults/Sample_xWebSiteDefaults.ps1 diff --git a/Examples/Resources/xWebVirtualDirectory/Sample_xWebVirtualDirectory_NewVirtualDirectory.ps1 b/source/Examples/Resources/xWebVirtualDirectory/Sample_xWebVirtualDirectory_NewVirtualDirectory.ps1 similarity index 100% rename from Examples/Resources/xWebVirtualDirectory/Sample_xWebVirtualDirectory_NewVirtualDirectory.ps1 rename to source/Examples/Resources/xWebVirtualDirectory/Sample_xWebVirtualDirectory_NewVirtualDirectory.ps1 diff --git a/Modules/xWebAdministration.Common/en-US/xWebAdministration.Common.strings.psd1 b/source/Modules/xWebAdministration.Common/en-US/xWebAdministration.Common.strings.psd1 similarity index 100% rename from Modules/xWebAdministration.Common/en-US/xWebAdministration.Common.strings.psd1 rename to source/Modules/xWebAdministration.Common/en-US/xWebAdministration.Common.strings.psd1 diff --git a/source/Modules/xWebAdministration.Common/xWebAdministration.Common.psd1 b/source/Modules/xWebAdministration.Common/xWebAdministration.Common.psd1 new file mode 100644 index 000000000..6c24f4915 --- /dev/null +++ b/source/Modules/xWebAdministration.Common/xWebAdministration.Common.psd1 @@ -0,0 +1,60 @@ +@{ + # Script module or binary module file associated with this manifest. + RootModule = 'xWebAdministration.Common.psm1' + + # Version number of this module. + ModuleVersion = '1.0.0' + + # ID used to uniquely identify this module + GUID = 'e32b82a0-ef75-4a64-9a98-e261758e3b71' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Functions used by the DSC resources in SqlServerDsc.' + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + 'New-InvalidArgumentException', + 'New-InvalidOperationException', + 'New-ObjectNotFoundException', + 'New-InvalidResultException', + 'Get-LocalizedData' + 'Start-ProcessWithTimeout' + 'Assert-Module' + 'Compare-ResourcePropertyState' + 'Test-DscPropertyState' + 'New-CimCredentialInstance' + 'Get-CurrentUser' + 'Find-Certificate' + 'New-TerminatingError' + 'Get-WebConfigurationPropertyValue' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @() + + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + } # End of PSData hashtable + + } # End of PrivateData hashtable +} + diff --git a/Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 b/source/Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 similarity index 96% rename from Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 rename to source/Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 index 766fa900d..4aaca568a 100644 --- a/Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 +++ b/source/Modules/xWebAdministration.Common/xWebAdministration.Common.psm1 @@ -775,8 +775,8 @@ function Find-Certificate # Join all the filters together $certFilterScript = '(' + ($certFilters -join ' -and ') + ')' - Write-Verbose -Message ($LocalizedData.SearchingForCertificateUsingFilters ` - -f $store,$certFilterScript) + Write-Verbose -Message ($script:localizedData.SearchingForCertificateUsingFilters ` + -f $store, $certFilterScript) $certs = Get-ChildItem -Path $certPath | Where-Object -FilterScript ([ScriptBlock]::Create($certFilterScript)) @@ -825,20 +825,34 @@ function New-TerminatingError throw $errorRecord } -$script:localizedData = Get-LocalizedData -ResourceName 'xWebAdministration.Common' -ScriptRoot $PSScriptRoot +<# + .SYNOPSIS + Returns the value of a WebConfigurationProperty. -Export-ModuleMember -Function @( - 'New-InvalidArgumentException' - 'New-InvalidOperationException' - 'New-ObjectNotFoundException' - 'New-InvalidResultException' - 'Get-LocalizedData' - 'Start-ProcessWithTimeout' - 'Assert-Module' - 'Compare-ResourcePropertyState' - 'Test-DscPropertyState' - 'New-CimCredentialInstance' - 'Get-CurrentUser' - 'Find-Certificate' - 'New-TerminatingError' -) + .PARAMETER WebConfigurationPropertyObject + Specifies the WebConfigurationProperty to return the value for. + + .NOTES + This is a helper function because the type are not mocked. +#> +function Get-WebConfigurationPropertyValue +{ + [CmdletBinding()] + [OutputType([PSObject])] + param + ( + [Parameter()] + [PSObject] + $WebConfigurationPropertyObject + ) + + if ($WebConfigurationPropertyObject -is [Microsoft.IIS.PowerShell.Framework.ConfigurationAttribute]) + { + return $WebConfigurationPropertyObject.Value + } else + { + return $WebConfigurationPropertyObject + } +} + +$script:localizedData = Get-LocalizedData -ResourceName 'xWebAdministration.Common' -ScriptRoot $PSScriptRoot diff --git a/source/build.psd1 b/source/build.psd1 new file mode 100644 index 000000000..7e48c697e --- /dev/null +++ b/source/build.psd1 @@ -0,0 +1,4 @@ +@{ + Path = 'xWebAdministration.psd1' +} + diff --git a/source/en-US/about_xWebAdministration.help.txt b/source/en-US/about_xWebAdministration.help.txt new file mode 100644 index 000000000..30f98a3de --- /dev/null +++ b/source/en-US/about_xWebAdministration.help.txt @@ -0,0 +1,26 @@ +TOPIC + about_xWebAdministration + +SHORT DESCRIPTION + DSC resources for configuring web servers and related components. + +LONG DESCRIPTION + This module contains DSC resources for deploying and configuring web servers and related components. + +EXAMPLES + PS C:\> Get-DscResource -Module about_xWebAdministration + +NOTE: + Thank you to the DSC Community contributors who contributed to this module by + writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Go to the Github repository for read about issues, submit a new issue, and read + about new releases. https://github.com/dsccommunity/xWebAdministration + +SEE ALSO + - https://github.com/dsccommunity/xWebAdministration + +KEYWORDS + DSC, DscResource, IIS + diff --git a/source/xWebAdministration.psd1 b/source/xWebAdministration.psd1 new file mode 100644 index 000000000..0cf1ccc5c --- /dev/null +++ b/source/xWebAdministration.psd1 @@ -0,0 +1,81 @@ +@{ + # Version number of this module. + moduleVersion = '0.0.1' + + # ID used to uniquely identify this module + GUID = 'b3239f27-d7d3-4ae6-a5d2-d9a1c97d6ae4' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Module with DSC Resources for Web Administration' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '4.0' + + # Minimum version of the common language runtime (CLR) required by this module + CLRVersion = '4.0' + + # Functions to export from this module + FunctionsToExport = @() + + # Cmdlets to export from this module + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module + AliasesToExport = @() + + DscResourcesToExport = @( + 'WebApplicationHandler' + 'xIisFeatureDelegation' + 'xIIsHandler' + 'xIisLogging' + 'xIisMimeTypeMapping' + 'xIisModule' + 'xSslSettings' + 'xWebApplication' + 'xWebAppPool' + 'xWebAppPoolDefaults' + 'xWebConfigKeyValue' + 'xWebConfigProperty' + 'xWebConfigPropertyCollection' + 'xWebSite' + 'xWebSiteDefaults' + 'xWebVirtualDirectory' + ) + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + Prerelease = '' + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/dsccommunity/xWebAdministration/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/dsccommunity/xWebAdministration' + + # A URL to an icon representing this module. + IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png' + + # ReleaseNotes of this module + ReleaseNotes = '' + + } # End of PSData hashtable + + } # End of PrivateData hashtable +} diff --git a/Tests/Integration/MSFT_WebApplicationHandler.Config.ps1 b/tests/Integration/MSFT_WebApplicationHandler.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_WebApplicationHandler.Config.ps1 rename to tests/Integration/MSFT_WebApplicationHandler.Config.ps1 diff --git a/Tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 b/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 similarity index 86% rename from Tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 rename to tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 index f8c5b8d73..27606b7cf 100644 --- a/Tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_WebApplicationHandler.Integration.Tests.ps1 @@ -1,31 +1,33 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_WebApplicationHandler' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_WebApplicationHandler' -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[string]$tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") -# Using try/finally to always cleanup even if something awful happens. try { $null = Backup-WebConfiguration -Name $tempName - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - Describe "$($script:DSCResourceName)_AllParameters" { + Describe "$($script:dscResourceName)_AllParameters" { #region Test Setup @@ -42,7 +44,7 @@ try ConfigurationData = $ConfigurationData } - & "$($script:DSCResourceName)_Addhandler" @configurationParameters + & "$($script:dscResourceName)_Addhandler" @configurationParameters Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should -Not -Throw @@ -85,7 +87,7 @@ try ConfigurationData = $ConfigurationData } - & "$($script:DSCResourceName)_Removehandler" @configurationParameters + & "$($script:dscResourceName)_Removehandler" @configurationParameters Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should -Not -Throw @@ -123,7 +125,7 @@ try } - Describe "$($script:DSCResourceName)_ExcludedOptionalParameters" { + Describe "$($script:dscResourceName)_ExcludedOptionalParameters" { #region Test Setup @@ -139,7 +141,7 @@ try ConfigurationData = $ConfigurationDataExcludedOptionalParameters } - & "$($script:DSCResourceName)_AddHandlerExcludedOptionalParameters" @configurationParameters + & "$($script:dscResourceName)_AddHandlerExcludedOptionalParameters" @configurationParameters Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should -Not -Throw @@ -177,7 +179,7 @@ try ConfigurationData = $ConfigurationDataExcludedOptionalParameters } - & "$($script:DSCResourceName)_RemoveHandlerExcludedOptionalParameters" @configurationParameters + & "$($script:dscResourceName)_RemoveHandlerExcludedOptionalParameters" @configurationParameters Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should -Not -Throw @@ -209,15 +211,11 @@ try } } } - finally { - #region FOOTER + Restore-WebConfigurationWrapper -Name $tempName - Restore-WebConfiguration -Name $tempName Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 b/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 similarity index 71% rename from Tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 rename to tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 index 207298a03..3a94d1ea9 100644 --- a/Tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_XIISLogging.Integration.Tests.ps1 @@ -1,38 +1,37 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISLogging' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISLogging' -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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'))) ) +try { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration - -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[String] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") -try { - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" +try +{ + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile $null = Backup-WebConfiguration -Name $tempName - Describe "$($script:DSCResourceName)_Rollover" { + Describe "$($script:dscResourceName)_Rollover" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Rollover -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Rollover -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -44,7 +43,7 @@ try { It 'Changing Logging Rollover Settings ' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Rollover -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Rollover -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force $currentLogSettings = Get-WebConfiguration -filter '/system.applicationHost/sites/siteDefaults/Logfile' @@ -64,11 +63,11 @@ try { } } - Describe "$($script:DSCResourceName)_Truncate" { + Describe "$($script:dscResourceName)_Truncate" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Truncate -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Truncate -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -79,7 +78,7 @@ try { #endregion It 'Changing Loggging Truncate Settings ' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Truncate -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Truncate -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force $currentLogSettings = Get-WebConfiguration -filter '/system.applicationHost/sites/siteDefaults/Logfile' @@ -101,10 +100,9 @@ try { } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_XIISLogging.config.ps1 b/tests/Integration/MSFT_XIISLogging.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_XIISLogging.config.ps1 rename to tests/Integration/MSFT_XIISLogging.config.ps1 diff --git a/Tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 similarity index 78% rename from Tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 rename to tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 index 0bfd79943..38015e5b3 100644 --- a/Tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISFeatureDelegation.Integration.Tests.ps1 @@ -1,34 +1,34 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISFeatureDelegation' - -#region HEADER -# Integration Test Template Version: 1.2.1 -[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'))) ) +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISFeatureDelegation' + +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -#endregion +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force -[string] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile $null = Backup-WebConfiguration -Name $tempName - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { $startDscConfigurationParameters = @{ Path = $TestDrive ComputerName = 'localhost' @@ -40,7 +40,7 @@ try Context 'Allow Feature Delegation'{ $currentOverrideMode = (Get-WebConfiguration -Filter '/system.web/customErrors' -Pspath iis:\ -Metadata).Metadata.effectiveOverrideMode - $configurationName = "$($script:DSCResourceName)_AllowDelegation" + $configurationName = "$($script:dscResourceName)_AllowDelegation" #For this test we want the target section to start at effectiveOverrideMode 'Deny' If ( $currentOverrideMode -ne 'Deny') { @@ -82,7 +82,7 @@ try Context 'Deny Feature Delegation'{ $currentOverrideMode = (Get-WebConfiguration -Filter 'system.webServer/defaultDocument' -Pspath 'MACHINE/WEBROOT/APPHOST' -Metadata).Metadata.effectiveOverrideMode - $configurationName = "$($script:DSCResourceName)_DenyDelegation" + $configurationName = "$($script:dscResourceName)_DenyDelegation" #For this test we want the target section to start at effectiveOverrideMode 'Allow' If ( $currentOverrideMode -ne 'Allow') { @@ -134,10 +134,9 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xIISFeatureDelegation.config.ps1 b/tests/Integration/MSFT_xIISFeatureDelegation.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xIISFeatureDelegation.config.ps1 rename to tests/Integration/MSFT_xIISFeatureDelegation.config.ps1 diff --git a/Tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 similarity index 56% rename from Tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 rename to tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 index 3168eaae1..528ab8e75 100644 --- a/Tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISHandler.Integration.Tests.ps1 @@ -1,38 +1,38 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISHandler' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISHandler' -#region HEADER -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[string]$tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") -# Using try/finally to always cleanup even if something awful happens. try { - #region Integration Tests - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile $null = Backup-WebConfiguration -Name $tempName - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_RemoveHandler -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_RemoveHandler -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -49,7 +49,7 @@ try { # TRACEVerbHandler is usually there, remove it - Invoke-Expression -Command "$($script:DSCResourceName)_AddHandler -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_AddHandler -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | should not throw @@ -60,7 +60,7 @@ try It 'StaticFile handler' { # StaticFile is usually there, have it present shouldn't change anything. { - Invoke-Expression -Command "$($script:DSCResourceName)_StaticFileHandler -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_StaticFileHandler -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | should not throw @@ -72,10 +72,9 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xIISHandler.config.ps1 b/tests/Integration/MSFT_xIISHandler.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xIISHandler.config.ps1 rename to tests/Integration/MSFT_xIISHandler.config.ps1 diff --git a/Tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 b/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 similarity index 83% rename from Tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 rename to tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 index 289e76e18..01634837e 100644 --- a/Tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xIISMimeTypeMapping.Integration.Tests.ps1 @@ -1,35 +1,34 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISMimeTypeMapping' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISMimeTypeMapping' -#region HEADER -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[string]$tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") -# Using try/finally to always cleanup even if something awful happens. try { - #region Integration Tests - $null = Backup-WebConfiguration -Name $tempName - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - Describe "$($script:DSCResourceName)_Integration Default tests" { + Describe "$($script:dscResourceName)_Integration Default tests" { #region Test Setup $tempVirtualDirectoryName = 'Dir01' @@ -67,7 +66,7 @@ try Context "When Adding a MimeType" { It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_AddMimeType" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_AddMimeType" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -91,7 +90,7 @@ try It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_RemoveMimeType" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_RemoveMimeType" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -114,7 +113,7 @@ try Context "When Adding a MimeType in a Nested Path" { It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_AddMimeTypeNestedPath" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_AddMimeTypeNestedPath" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -138,7 +137,7 @@ try Context "When Removing a MimeType from a Nested Path" { It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_RemoveMimeTypeNestedPath" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_RemoveMimeTypeNestedPath" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -162,7 +161,7 @@ try Context "When Adding a MimeType at the Server Level" { It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_AddMimeTypeAtServer" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_AddMimeTypeAtServer" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -186,7 +185,7 @@ try Context "When Removing MimeType at the Server Level" { It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_RemoveMimeTypeAtServer" -OutputPath $TestDrive -ConfigurationData $configData + & "$($script:dscResourceName)_RemoveMimeTypeAtServer" -OutputPath $TestDrive -ConfigurationData $configData Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } @@ -207,14 +206,12 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xIISMimeTypeMapping.config.ps1 b/tests/Integration/MSFT_xIISMimeTypeMapping.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xIISMimeTypeMapping.config.ps1 rename to tests/Integration/MSFT_xIISMimeTypeMapping.config.ps1 diff --git a/Tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 b/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 similarity index 64% rename from Tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 rename to tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 index bcde46674..10d78503c 100644 --- a/Tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xSslSettings.Integration.Tests.ps1 @@ -1,34 +1,34 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xSslSettings' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xSslSettings' -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[String] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') try { $null = Backup-WebConfiguration -Name $tempName # Now that xWebAdministration should be discoverable load the configuration data - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:DSCResourceName).config.psd1" + $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:dscResourceName).config.psd1" #region HelperFunctions @@ -66,11 +66,11 @@ try -Force ` -ErrorAction Stop - Describe "$($script:DSCResourceName)_Present" { + Describe "$($script:dscResourceName)_Present" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -82,7 +82,7 @@ try It 'Should add SSLBindings to a Website' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" # Test SslFlags Get-SslFlags -Website $DSCConfig.AllNodes.Website | Should Be $DSCConfig.AllNodes.Bindings @@ -91,11 +91,11 @@ try } - Describe "$($script:DSCResourceName)_Absent" { + Describe "$($script:dscResourceName)_Absent" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -107,7 +107,7 @@ try It 'Should remove SSLBindings from a Website' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" # Test SslFlags Get-SslFlags -Website $DSCConfig.AllNodes.Website | Should BeNullOrEmpty @@ -119,10 +119,9 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xSslSettings.config.ps1 b/tests/Integration/MSFT_xSslSettings.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xSslSettings.config.ps1 rename to tests/Integration/MSFT_xSslSettings.config.ps1 diff --git a/Tests/Integration/MSFT_xSslSettings.config.psd1 b/tests/Integration/MSFT_xSslSettings.config.psd1 similarity index 100% rename from Tests/Integration/MSFT_xSslSettings.config.psd1 rename to tests/Integration/MSFT_xSslSettings.config.psd1 diff --git a/Tests/Integration/MSFT_xWebAppPool.Integration.tests.ps1 b/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 similarity index 60% rename from Tests/Integration/MSFT_xWebAppPool.Integration.tests.ps1 rename to tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 index 3a6b58f9b..894c64bd5 100644 --- a/Tests/Integration/MSFT_xWebAppPool.Integration.tests.ps1 +++ b/tests/Integration/MSFT_xWebAppPool.Integration.Tests.ps1 @@ -1,25 +1,22 @@ #requires -Version 4.0 -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebAppPool' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebAppPool' -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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'))) ) +try { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration - -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' # Test Setup if ((Get-Service -Name 'W3SVC').Status -ne 'Running') @@ -27,22 +24,22 @@ if ((Get-Service -Name 'W3SVC').Status -ne 'Running') Start-Service -Name 'W3SVC' } -$tempBackupName = "$($script:DSCResourceName)_$(Get-Date -Format 'yyyyMMdd_HHmmss')" +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force -# Using try/finally to always cleanup even if something awful happens. +$tempName = "$($script:dscResourceName)_$(Get-Date -Format 'yyyyMMdd_HHmmss')" try { # Create configuration backup - - Backup-WebConfiguration -Name $tempBackupName | Out-Null + + Backup-WebConfiguration -Name $tempName | Out-Null #region Integration Tests - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { #region Default Tests @@ -50,7 +47,7 @@ try { Invoke-Expression -Command ( '{0}_Config -OutputPath $TestDrive -ConfigurationData $ConfigData -ErrorAction Stop' -f - $script:DSCResourceName + $script:dscResourceName ) Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Force -Wait -Verbose @@ -103,10 +100,9 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempBackupName - Remove-WebConfigurationBackup -Name $tempBackupName + Restore-WebConfigurationWrapper -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Remove-WebConfigurationBackup -Name $tempName + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebAppPool.config.ps1 b/tests/Integration/MSFT_xWebAppPool.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebAppPool.config.ps1 rename to tests/Integration/MSFT_xWebAppPool.config.ps1 diff --git a/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 new file mode 100644 index 000000000..bbe4fe350 --- /dev/null +++ b/tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 @@ -0,0 +1,227 @@ +#requires -Version 4.0 + +<<<<<<< HEAD:Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 +$script:DSCModuleName = 'xWebAdministration' +$script:DSCResourceName = 'MSFT_xWebAppPoolDefaults' +======= +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebAppPoolDefaults' +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +<<<<<<< HEAD:Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` + -TestType Integration + +#endregion + +# Test Setup +if ((Get-Service -Name 'W3SVC').Status -ne 'Running') +{ + Start-Service -Name 'W3SVC' +} + +$tempBackupName = "$($script:DSCResourceName)_$(Get-Date -Format 'yyyyMMdd_HHmmss')" + +# Using try/finally to always cleanup even if something awful happens. + +======= +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") + +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 +try +{ + # Create configuration backup + + Backup-WebConfiguration -Name $tempBackupName | Out-Null + + #region Integration Tests + + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $ConfigFile + + Describe "$($script:DSCResourceName)_Integration" { + + #region Default Tests + +<<<<<<< HEAD:Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + It 'Should be able to compile and apply without throwing' { + { + Invoke-Expression -Command ( + '{0}_Config -OutputPath $TestDrive -ConfigurationData $ConfigData -ErrorAction Stop' -f + $script:DSCResourceName + ) + + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Force -Wait -Verbose + } | Should Not Throw +======= + Describe "$($script:dscResourceName)_Integration" { + #region DEFAULT TESTS + It 'Should compile without throwing' { + { + Invoke-Expression -Command "$($script:dscResourceName)_Config -OutputPath `$TestDrive" + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force + } | Should not throw +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should Not Throw + } + + #endregion + + It 'Should have set the resource and all the parameters should match' { + + $currentConfiguration = Get-DscConfiguration + + foreach ($parameter in $TestParameters.GetEnumerator()) + { + Write-Verbose -Message "The $($parameter.Name) property should be set." + + if ($parameter.Name -eq 'Credential') + { + $appPoolDefaults = Get-WebConfiguration -Filter '/system.applicationHost/applicationPools/applicationPoolDefaults' + + $appPoolDefaults.processModel.userName | + Should Be $TestParameters['Credential'].UserName + + $appPoolDefaults.processModel.password | + Should Be $TestParameters['Credential'].GetNetworkCredential().Password + } + elseif ($parameter.Name -eq 'ApplyTo') + { + # ignored. + } + else + { + $currentConfiguration."$($parameter.Name)" | + Should Be $TestParameters[$parameter.Name] + } +<<<<<<< HEAD:Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + } + + } + + It 'Actual configuration should match the desired configuration' { + Test-DscConfiguration -Verbose | Should Be $true +======= + + Invoke-Expression -Command "$($script:dscResourceName)_ManagedRuntimeVersion -OutputPath `$TestDrive" + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force + } | should not throw + + # get the configured value again + $changedValue = (Get-WebConfigurationProperty -pspath $constPsPath -filter $constAPDFilter -name managedRuntimeVersion).Value + + # compare it to the one we just tried to set. + $changedValue | should be $env:PesterManagedRuntimeVersion + } + + It 'Changing IdentityType' { + # get the current value + [string] $originalValue = (Get-WebConfigurationProperty ` + -PSPath $constPsPath ` + -Filter $constAPDFilter/processModel ` + -Name identityType) + + if ($originalValue -eq 'ApplicationPoolIdentity') + { + $env:PesterApplicationPoolIdentity = 'LocalService' + } + else + { + $env:PesterApplicationPoolIdentity = 'ApplicationPoolIdentity' + } + + # Compile the MOF File + { + Invoke-Expression -Command "$($script:dscResourceName)_AppPoolIdentityType -OutputPath `$TestDrive" + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force + } | Should not throw + + $changedValue = (Get-WebConfigurationProperty -PSPath $constPsPath -Filter $constAPDFilter/processModel -Name identityType) + + $changedValue | Should Be $env:PesterApplicationPoolIdentity + } + + + It 'Changing LogFormat' { + [string] $originalValue = Get-SiteValue 'logFile' 'logFormat' + + if ($originalValue -eq 'W3C') + { + $env:PesterLogFormat = 'IIS' + } + else + { + $env:PesterLogFormat = 'W3C' + } + + # Compile the MOF File + { + Invoke-Expression -Command "$($script:dscResourceName)_LogFormat -OutputPath `$TestDrive" + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force + } | Should not throw + + $changedValue = Get-SiteValue 'logFile' 'logFormat' + + $changedValue | Should Be $env:PesterALogFormat + } + + It 'Changing Default AppPool' { + # get the current value + + [string] $originalValue = Get-SiteValue 'applicationDefaults' 'applicationPool' + + $env:PesterDefaultPool = 'DefaultAppPool' + # Compile the MOF File + { + Invoke-Expression -Command "$($script:dscResourceName)_DefaultPool -OutputPath `$TestDrive" + Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force + } | Should not throw + + $changedValue = Get-SiteValue 'applicationDefaults' 'applicationPool' + $changedValue | should be $env:PesterDefaultPool +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + } + + } + + #endregion +} +finally +{ +<<<<<<< HEAD:Tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + #region FOOTER + Restore-WebConfiguration -Name $tempBackupName + Remove-WebConfigurationBackup -Name $tempBackupName +======= + Restore-WebConfigurationWrapper -Name $tempName + + Remove-WebConfigurationBackup -Name $tempName +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Integration/MSFT_xWebAppPoolDefaults.Integration.Tests.ps1 + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/MSFT_xWebAppPoolDefaults.config.ps1 b/tests/Integration/MSFT_xWebAppPoolDefaults.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebAppPoolDefaults.config.ps1 rename to tests/Integration/MSFT_xWebAppPoolDefaults.config.ps1 diff --git a/Tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 similarity index 76% rename from Tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 index 9f4534ccd..7b5eb225b 100644 --- a/Tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebApplication.Integration.Tests.ps1 @@ -1,39 +1,39 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebApplication' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebApplication' -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force -[string] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') try { $null = Backup-WebConfiguration -Name $tempName # Now that xWebAdministration should be discoverable load the configuration data - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:DSCResourceName).config.psd1" + $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:dscResourceName).config.psd1" #region HelperFunctions # Function needed to test AuthenticationInfo - Function Get-AuthenticationInfo ($Type, $Website, $WebApplication) + function Get-AuthenticationInfo ($Type, $Website, $WebApplication) { (Get-WebConfigurationProperty ` -Filter /system.WebServer/security/authentication/${Type}Authentication ` @@ -42,7 +42,7 @@ try } # Function needed to test SslFlags - Function Get-SslFlags ($Website, $WebApplication) + function Get-SslFlags ($Website, $WebApplication) { Get-WebConfiguration ` -PSPath IIS:\Sites ` @@ -67,11 +67,11 @@ try -Force ` -ErrorAction Stop - Describe "$($script:DSCResourceName)_Present" { + Describe "$($script:dscResourceName)_Present" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -83,7 +83,7 @@ try It 'Should create a WebApplication with correct settings' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" # Build results to test $Result = Get-WebApplication -Site $DSCConfig.AllNodes.Website -Name $DSCConfig.AllNodes.WebApplication @@ -119,11 +119,11 @@ try } - Describe "$($script:DSCResourceName)_Absent" { + Describe "$($script:dscResourceName)_Absent" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -134,26 +134,22 @@ try #endregion It 'Should remove the WebApplication' -test { - - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" # Build results to test $Result = Get-WebApplication -Site $DSCConfig.AllNodes.Website -Name $DSCConfig.AllNodes.WebApplication # Test WebApplication is removed $Result | Should BeNullOrEmpty - - } + } } - } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebApplication.config.ps1 b/tests/Integration/MSFT_xWebApplication.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebApplication.config.ps1 rename to tests/Integration/MSFT_xWebApplication.config.ps1 diff --git a/Tests/Integration/MSFT_xWebApplication.config.psd1 b/tests/Integration/MSFT_xWebApplication.config.psd1 similarity index 100% rename from Tests/Integration/MSFT_xWebApplication.config.psd1 rename to tests/Integration/MSFT_xWebApplication.config.psd1 diff --git a/Tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 similarity index 65% rename from Tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 index 0e59a8693..a2742b5fb 100644 --- a/Tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigKeyValue.Integration.Tests.ps1 @@ -1,40 +1,43 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebConfigKeyValue' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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'))) ) +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebConfigKeyValue' + +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -#endregion +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") -# Using try/finally to always cleanup. try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile + $null = Backup-WebConfiguration -Name $tempName + # Constants for Tests $env:xWebConfigKeyValuePsPath = 'IIS:\Sites\Default Web Site' $env:xWebConfigKeyValueIntegrationKey = 'xWebAdministration Integration Tests Key' - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + & "$($script:dscResourceName)_Config" -OutputPath $TestDrive Start-DscConfiguration -Path $TestDrive ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw @@ -55,7 +58,7 @@ try $env:xWebConfigKeyValueIntegrationValueUpdated = $originalValue + "-updated" - Invoke-Expression -Command "$($script:DSCResourceName)_AppSetting_Update -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_AppSetting_Update -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should Not throw @@ -69,7 +72,7 @@ try It 'Should remove AppSetting "xWebAdministration Integration Tests Key"' { { - Invoke-Expression -Command "$($script:DSCResourceName)_AppSetting_Absent -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_AppSetting_Absent -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should Not throw @@ -85,10 +88,10 @@ try } finally { - #region FOOTER + Restore-WebConfigurationWrapper -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Remove-WebConfigurationBackup -Name $tempName - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebConfigKeyValue.config.ps1 b/tests/Integration/MSFT_xWebConfigKeyValue.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebConfigKeyValue.config.ps1 rename to tests/Integration/MSFT_xWebConfigKeyValue.config.ps1 diff --git a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 similarity index 83% rename from Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 index 1cc1e28c3..c4883a65c 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 @@ -1,28 +1,25 @@ $script:dscModuleName = 'xWebAdministration' -$script:dscResourceFriendlyName = 'xWebConfigProperty' -$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" - -#region HEADER -# Integration Test Template Version: 1.3.0 -[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'))) ) +$script:dscResourceName = "MSFT_xWebConfigProperty" + +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -# Ensure the WebAdministration module is imported into the current session! -Import-Module WebAdministration -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -[string] $tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') -# Using try/finally to always cleanup. try { $configurationFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -172,6 +169,7 @@ try # Remove the website we created for testing purposes. if (Get-Website -Name $websiteName) { + Write-Verbose -Message ('Removing website that was used for testing' -f $retryCount) -Verbose Remove-Website -Name $websiteName Remove-Item -Path $websitePhysicalPath -Force -Recurse } @@ -180,13 +178,9 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - # Addresses Issue #385: xWebConfigPropertyCollection: Timing issue in integration tests - Start-Sleep -Seconds 4 + Restore-WebConfigurationWrapper -Name $tempName - Restore-WebConfiguration -Name $tempName Remove-WebConfigurationBackup -Name $tempName - #endregion + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 b/tests/Integration/MSFT_xWebConfigProperty.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebConfigProperty.config.ps1 rename to tests/Integration/MSFT_xWebConfigProperty.config.ps1 diff --git a/Tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 similarity index 85% rename from Tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 index 019ab3be5..50c0c2365 100644 --- a/Tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebConfigPropertyCollection.Integration.Tests.ps1 @@ -1,31 +1,26 @@ $script:dscModuleName = 'xWebAdministration' -$script:dscResourceFriendlyName = 'xWebConfigPropertyCollection' -$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" - -#region HEADER -# Integration Test Template Version: 1.3.0 -[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'))) ) +$script:dscResourceName = "MSFT_xWebConfigPropertyCollection" + +try { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -# Ensure the WebAdministration module is imported into the current session! -Import-Module WebAdministration -Force - -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force -[string] $tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') -# Using try/finally to always cleanup. try { #region Integration Tests @@ -199,13 +194,9 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - # Addresses Issue #385: xWebConfigPropertyCollection: Timing issue in integration tests - Start-Sleep -Seconds 4 + Restore-WebConfigurationWrapper -Name $tempName - Restore-WebConfiguration -Name $tempName Remove-WebConfigurationBackup -Name $tempName - #endregion + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebConfigPropertyCollection.config.ps1 b/tests/Integration/MSFT_xWebConfigPropertyCollection.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebConfigPropertyCollection.config.ps1 rename to tests/Integration/MSFT_xWebConfigPropertyCollection.config.ps1 diff --git a/Tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 similarity index 88% rename from Tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 index 1031d4bb3..a8f0b0b0c 100644 --- a/Tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebSite.Integration.Tests.ps1 @@ -1,32 +1,34 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebSite' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebSite' -#region HEADER -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[String] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') try { # Now that xWebAdministration should be discoverable, load the configuration data - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile $null = Backup-WebConfiguration -Name $tempName - $dscConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:DSCResourceName).config.psd1" + $dscConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:dscResourceName).config.psd1" # Create a SelfSigned Cert $selfSignedCert = (New-SelfSignedCertificate -DnsName $dscConfig.AllNodes.HTTPSHostname ` @@ -55,11 +57,11 @@ try #endregion - Describe "$($script:DSCResourceName)_Webconfig_Get_Test_Set" { + Describe "$($script:dscResourceName)_Webconfig_Get_Test_Set" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Webconfig_Get_Test_Set -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" + Invoke-Expression -Command "$($script:dscResourceName)_Webconfig_Get_Test_Set -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -74,11 +76,11 @@ try } } - Describe "$($script:DSCResourceName)_Present_Started" { + Describe "$($script:dscResourceName)_Present_Started" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Present_Started -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" + Invoke-Expression -Command "$($script:dscResourceName)_Present_Started -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -90,7 +92,7 @@ try It 'Should Create a Started Website with correct settings' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Present_Started -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" + Invoke-Expression -Command "$($script:dscResourceName)_Present_Started -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" # Build results to test $result = Get-Website -Name $dscConfig.AllNodes.Website @@ -158,11 +160,11 @@ try } - Describe "$($script:DSCResourceName)_Present_Stopped" { + Describe "$($script:dscResourceName)_Present_Stopped" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Present_Stopped -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" + Invoke-Expression -Command "$($script:dscResourceName)_Present_Stopped -ConfigurationData `$dscConfig -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -174,7 +176,7 @@ try It 'Should Create a Stopped Website with correct settings' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Present_Stopped -ConfigurationData `$dscConfg -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" + Invoke-Expression -Command "$($script:dscResourceName)_Present_Stopped -ConfigurationData `$dscConfg -OutputPath `$TestDrive -CertificateThumbprint `$selfSignedCert.Thumbprint" # Build results to test $result = Get-Website -Name $dscConfig.AllNodes.Website @@ -239,11 +241,11 @@ try } - Describe "$($script:DSCResourceName)_Absent" { + Describe "$($script:dscResourceName)_Absent" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$dscConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$dscConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -255,7 +257,7 @@ try It 'Should remove the Website' -test { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$dscConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$dscConfg -OutputPath `$TestDrive" # Build results to test $result = Get-Website -Name $dscConfig.AllNodes.Website @@ -284,17 +286,17 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Remove-Item -PSPath $selfSignedCert.PSPath - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Remove-Item -PSPath $selfSignedCert.PSPath $webConfigPath = Join-Path -Path $dscConfig.AllNodes.PhysicalPath -ChildPath 'web.config' - if(Test-Path -Path $webConfigPath -PathType Leaf) + if (Test-Path -Path $webConfigPath -PathType Leaf) { Remove-Item -Path $webConfigPath } + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebSite.config.ps1 b/tests/Integration/MSFT_xWebSite.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebSite.config.ps1 rename to tests/Integration/MSFT_xWebSite.config.ps1 diff --git a/Tests/Integration/MSFT_xWebSite.config.psd1 b/tests/Integration/MSFT_xWebSite.config.psd1 similarity index 100% rename from Tests/Integration/MSFT_xWebSite.config.psd1 rename to tests/Integration/MSFT_xWebSite.config.psd1 diff --git a/Tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 similarity index 56% rename from Tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 index 9298b9788..92b5b3446 100644 --- a/Tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebSiteDefaults.Integration.Tests.ps1 @@ -1,36 +1,38 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebSiteDefaults' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebSiteDefaults' -#region HEADER -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[string]$tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString("yyyyMMdd_HHmmss") try { $null = Backup-WebConfiguration -Name $tempName - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Config -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Config -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -53,7 +55,7 @@ try -Filter 'system.applicationHost/sites/virtualDirectoryDefaults' ` -Name 'allowSubDirConfig').Value - Invoke-Expression -Command "$($script:DSCResourceName)_Config -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Config -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force $changedValue = (Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -filter 'system.applicationHost/sites/virtualDirectoryDefaults' -name 'allowSubDirConfig').Value @@ -63,10 +65,9 @@ try } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebSiteDefaults.config.ps1 b/tests/Integration/MSFT_xWebSiteDefaults.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebSiteDefaults.config.ps1 rename to tests/Integration/MSFT_xWebSiteDefaults.config.ps1 diff --git a/Tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 b/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 similarity index 62% rename from Tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 rename to tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 index 843504b50..622c02a35 100644 --- a/Tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_xWebVirtualDirectory.Integration.Tests.ps1 @@ -1,45 +1,45 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebVirtualDirectory' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebVirtualDirectory' -#region HEADER - -# Integration Test Template Version: 1.1.0 -$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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' -[string] $tempName = "$($script:DSCResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force + +$tempName = "$($script:dscResourceName)_" + (Get-Date).ToString('yyyyMMdd_HHmmss') try { $null = Backup-WebConfiguration -Name $tempName - + # Now that xWebAdministration should be discoverable load the configuration data - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile - $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:DSCResourceName).config.psd1" + $DSCConfig = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName "$($script:dscResourceName).config.psd1" - Describe "$($script:DSCResourceName)_Initialize" { - Invoke-Expression -Command "$($script:DSCResourceName)_Initialize -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Describe "$($script:dscResourceName)_Initialize" { + Invoke-Expression -Command "$($script:dscResourceName)_Initialize -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } - Describe "$($script:DSCResourceName)_Present" { + Describe "$($script:dscResourceName)_Present" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -50,7 +50,7 @@ try #endregion It 'Should create a WebVirtualDirectory with correct settings' -Test { - Invoke-Expression -Command "$($script:DSCResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Present -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" # Build results to test $result = Get-WebVirtualDirectory -Site $DSCConfig.AllNodes.Website ` @@ -63,11 +63,11 @@ try } } - Describe "$($script:DSCResourceName)_Absent" { + Describe "$($script:dscResourceName)_Absent" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfig -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force } | Should not throw } @@ -76,9 +76,9 @@ try { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion - + It 'Should remove the WebVirtualDirectory' -Test { - Invoke-Expression -Command "$($script:DSCResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:dscResourceName)_Absent -ConfigurationData `$DSCConfg -OutputPath `$TestDrive" # Build results to test $result = Get-WebVirtualDirectory -Site $DSCConfig.AllNodes.Website ` @@ -86,15 +86,15 @@ try -Name $DSCConfig.AllNodes.WebVirtualDirectory # Test virtual directory is removed - $result | Should BeNullOrEmpty + $result | Should BeNullOrEmpty } } } finally { - #region FOOTER - Restore-WebConfiguration -Name $tempName + Restore-WebConfigurationWrapper -Name $tempName + Remove-WebConfigurationBackup -Name $tempName if ((Test-Path -Path $DSCConfig.AllNodes.PhysicalPath)) { @@ -105,6 +105,5 @@ finally Remove-Item -Path $DSCConfig.AllNodes.WebApplicationPhysicalPath } - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_xWebVirtualDirectory.config.ps1 b/tests/Integration/MSFT_xWebVirtualDirectory.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_xWebVirtualDirectory.config.ps1 rename to tests/Integration/MSFT_xWebVirtualDirectory.config.ps1 diff --git a/Tests/Integration/MSFT_xWebVirtualDirectory.config.psd1 b/tests/Integration/MSFT_xWebVirtualDirectory.config.psd1 similarity index 100% rename from Tests/Integration/MSFT_xWebVirtualDirectory.config.psd1 rename to tests/Integration/MSFT_xWebVirtualDirectory.config.psd1 diff --git a/Tests/MockWebAdministrationWindowsFeature.psm1 b/tests/MockWebAdministrationWindowsFeature.psm1 similarity index 91% rename from Tests/MockWebAdministrationWindowsFeature.psm1 rename to tests/MockWebAdministrationWindowsFeature.psm1 index dda9537fe..e1b86e2cf 100644 --- a/Tests/MockWebAdministrationWindowsFeature.psm1 +++ b/tests/MockWebAdministrationWindowsFeature.psm1 @@ -1,5 +1,5 @@ -# Suppressing these rule because these functions are from an external module +# Suppressing these rule because these functions are from an external module # and are only being used as stubs [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingUserNameAndPassWordParams', '')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '')] @@ -8,7 +8,7 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPlainTextForPassword', '')] param () -function Add-WebConfiguration { +function Add-WebConfiguration { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268763')] param( [psobject] @@ -44,11 +44,11 @@ param( [string[]] ${PSPath}) - - } + } -function Add-WebConfigurationLock { + +function Add-WebConfigurationLock { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268770')] param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] @@ -73,11 +73,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Add-WebConfigurationProperty { +function Add-WebConfigurationProperty { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268814')] param( [Parameter(Mandatory=$true)] @@ -120,11 +120,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Backup-WebConfiguration { +function Backup-WebConfiguration { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268815')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true, HelpMessage='Backup name')] @@ -132,21 +132,21 @@ param( [string] ${Name}) - - } + } -function Clear-WebCentralCertProvider { + +function Clear-WebCentralCertProvider { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269642')] param( [switch] ${PrivateKeyPassword}) - - } + + } -function Clear-WebConfiguration { +function Clear-WebConfiguration { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268817')] param( [string] @@ -167,11 +167,11 @@ param( [string[]] ${PSPath}) - - } + } -function Clear-WebRequestTracingSetting { + +function Clear-WebRequestTracingSetting { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268818')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -179,11 +179,11 @@ param( [string] ${Name}) - - } + + } -function Clear-WebRequestTracingSettings { +function Clear-WebRequestTracingSettings { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268818')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -191,11 +191,11 @@ param( [string] ${Name}) - - } + + } -function ConvertTo-WebApplication { +function ConvertTo-WebApplication { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268819')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -209,19 +209,19 @@ param( [string[]] ${PSPath}) - - } + } -function Disable-WebCentralCertProvider { + +function Disable-WebCentralCertProvider { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269643')] param() - - } + + } -function Disable-WebGlobalModule { +function Disable-WebGlobalModule { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268820')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -237,11 +237,11 @@ param( [string[]] ${PSPath}) - - } + } -function Disable-WebRequestTracing { + +function Disable-WebRequestTracing { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268821')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -249,11 +249,11 @@ param( [string] ${Name}) - - } + + } -function Enable-WebCentralCertProvider { +function Enable-WebCentralCertProvider { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269644')] param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] @@ -272,11 +272,11 @@ param( [string] ${PrivateKeyPassword}) - - } + + } -function Enable-WebGlobalModule { +function Enable-WebGlobalModule { [CmdletBinding(DefaultParameterSetName='InputProperties', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268822')] param( [Parameter(ParameterSetName='InputObject', Mandatory=$true, ValueFromPipeline=$true)] @@ -307,11 +307,11 @@ param( [string[]] ${PSPath}) - - } + } -function Enable-WebRequestTracing { + +function Enable-WebRequestTracing { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268823')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -343,11 +343,11 @@ param( [string] ${StatusCodes}) - - } + + } -function Get-WebAppDomain { +function Get-WebAppDomain { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268825')] param( [Parameter(ParameterSetName='InputObject', ValueFromPipeline=$true)] @@ -365,11 +365,11 @@ param( [uint32] ${ProcessId}) - - } + } -function Get-WebApplication { + +function Get-WebApplication { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268826')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -382,11 +382,11 @@ param( [string] ${Name}) - - } + + } -function Get-WebAppPoolState { +function Get-WebAppPoolState { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268827')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -394,11 +394,11 @@ param( [string] ${Name}) - - } + + } -function Get-WebBinding { +function Get-WebBinding { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268828')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -422,11 +422,11 @@ param( [string] ${HostHeader}) - - } + } -function Get-WebCentralCertProvider { + +function Get-WebCentralCertProvider { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269640')] param( [switch] @@ -441,22 +441,22 @@ param( [switch] ${Enabled}) - - } + + } -function Get-WebConfigFile { +function Get-WebConfigFile { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268829')] param( [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [string[]] ${PSPath}) - - } + } -function Get-WebConfiguration { + +function Get-WebConfiguration { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268830')] param( [switch] @@ -480,11 +480,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Get-WebConfigurationBackup { +function Get-WebConfigurationBackup { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268831')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true, HelpMessage='Backup name')] @@ -492,11 +492,11 @@ param( [string] ${Name}) - - } + + } -function Get-WebConfigurationLocation { +function Get-WebConfigurationLocation { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268832')] param( [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] @@ -510,11 +510,11 @@ param( [string[]] ${PSPath}) - - } + } -function Get-WebConfigurationLock { + +function Get-WebConfigurationLock { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268833')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -529,11 +529,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Get-WebConfigurationProperty { +function Get-WebConfigurationProperty { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268834')] param( [Parameter(Mandatory=$true)] @@ -558,22 +558,22 @@ param( [string[]] ${PSPath}) - - } + } -function Get-WebFilePath { + +function Get-WebFilePath { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268835')] param( [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [string[]] ${PSPath}) - - } + + } -function Get-WebGlobalModule { +function Get-WebGlobalModule { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268836')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -589,11 +589,11 @@ param( [string] ${Precondition}) - - } + + } -function Get-WebHandler { +function Get-WebHandler { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268837')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -608,11 +608,11 @@ param( [string[]] ${PSPath}) - - } + } -function Get-WebItemState { + +function Get-WebItemState { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268838')] param( [string] @@ -635,7 +635,7 @@ dynamicparam { $param = $param.Value - if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) + if (-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) { $dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes) $paramDictionary.Add($param.Name, $dynParam) @@ -648,11 +648,11 @@ dynamicparam } } - - } + + } -function Get-WebManagedModule { +function Get-WebManagedModule { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268839')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -667,11 +667,11 @@ param( [string[]] ${PSPath}) - - } + } -function Get-WebRequest { + +function Get-WebRequest { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268840')] param( [Parameter(ParameterSetName='InputObject', ValueFromPipeline=$true)] @@ -688,22 +688,22 @@ param( [uint32] ${Process}) - - } + + } -function Get-Website { +function Get-Website { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268841')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] [string] ${Name}) - - } + + } -function Get-WebsiteState { +function Get-WebsiteState { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268842')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -711,11 +711,11 @@ param( [string] ${Name}) - - } + } -function Get-WebURL { + +function Get-WebURL { [CmdletBinding(DefaultParameterSetName='InputPSPath', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268843')] param( [Parameter(ParameterSetName='InputURL', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] @@ -735,11 +735,11 @@ param( [switch] ${Content}) - - } + + } -function Get-WebVirtualDirectory { +function Get-WebVirtualDirectory { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268844')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -757,11 +757,11 @@ param( [string] ${Name}) - - } + } -function New-WebApplication { + +function New-WebApplication { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268845')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -785,11 +785,11 @@ param( [switch] ${Force}) - - } + + } -function New-WebAppPool { +function New-WebAppPool { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268846')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true, HelpMessage='Application pool name')] @@ -800,11 +800,11 @@ param( [switch] ${Force}) - - } + } -function New-WebBinding { + +function New-WebBinding { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268847')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -835,11 +835,11 @@ param( [switch] ${Force}) - - } + + } -function New-WebFtpSite { +function New-WebFtpSite { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268848')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -870,11 +870,11 @@ param( [switch] ${Force}) - - } + } -function New-WebGlobalModule { + +function New-WebGlobalModule { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268849')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -894,11 +894,11 @@ param( [switch] ${Force}) - - } + + } -function New-WebHandler { +function New-WebHandler { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268850')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -952,11 +952,11 @@ param( [string[]] ${PSPath}) - - } + + } -function New-WebManagedModule { +function New-WebManagedModule { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268851')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -984,11 +984,11 @@ param( [string[]] ${PSPath}) - - } + } -function New-Website { + +function New-Website { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268852')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1030,11 +1030,11 @@ param( [switch] ${Force}) - - } + + } -function New-WebVirtualDirectory { +function New-WebVirtualDirectory { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268853')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -1058,11 +1058,11 @@ param( [switch] ${Force}) - - } + } -function Remove-WebApplication { + +function Remove-WebApplication { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268854')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -1075,11 +1075,11 @@ param( [string] ${Name}) - - } + + } -function Remove-WebAppPool { +function Remove-WebAppPool { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268855')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1087,11 +1087,11 @@ param( [string] ${Name}) - - } + + } -function Remove-WebBinding { +function Remove-WebBinding { [CmdletBinding(DefaultParameterSetName='InputBindingProperties', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268856')] param( [Parameter(ParameterSetName='InputObject', Mandatory=$true, ValueFromPipeline=$true)] @@ -1125,11 +1125,11 @@ param( [string] ${HostHeader}) - - } + } -function Remove-WebConfigurationBackup { + +function Remove-WebConfigurationBackup { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268857')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true, HelpMessage='Backup name')] @@ -1137,11 +1137,11 @@ param( [string] ${Name}) - - } + + } -function Remove-WebConfigurationLocation { +function Remove-WebConfigurationLocation { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268858')] param( [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] @@ -1155,11 +1155,11 @@ param( [string[]] ${PSPath}) - - } + } -function Remove-WebConfigurationLock { + +function Remove-WebConfigurationLock { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268859')] param( [switch] @@ -1177,11 +1177,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Remove-WebConfigurationProperty { +function Remove-WebConfigurationProperty { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268860')] param( [Parameter(Mandatory=$true)] @@ -1218,11 +1218,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Remove-WebGlobalModule { +function Remove-WebGlobalModule { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268861')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1230,11 +1230,11 @@ param( [string] ${Name}) - - } + } -function Remove-WebHandler { + +function Remove-WebHandler { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268862')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1250,11 +1250,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Remove-WebManagedModule { +function Remove-WebManagedModule { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268863')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1270,11 +1270,11 @@ param( [string[]] ${PSPath}) - - } + } -function Remove-Website { + +function Remove-Website { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268864')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1282,11 +1282,11 @@ param( [string] ${Name}) - - } + + } -function Remove-WebVirtualDirectory { +function Remove-WebVirtualDirectory { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268865')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -1304,11 +1304,11 @@ param( [string] ${Name}) - - } + + } -function Rename-WebConfigurationLocation { +function Rename-WebConfigurationLocation { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268866')] param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] @@ -1326,11 +1326,11 @@ param( [string[]] ${PSPath}) - - } + } -function Restart-WebAppPool { + +function Restart-WebAppPool { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268867')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1338,11 +1338,11 @@ param( [string] ${Name}) - - } + + } -function Restart-WebItem { +function Restart-WebItem { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268868')] param( [string] @@ -1365,7 +1365,7 @@ dynamicparam { $param = $param.Value - if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) + if (-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) { $dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes) $paramDictionary.Add($param.Name, $dynParam) @@ -1378,11 +1378,11 @@ dynamicparam } } - - } + } -function Restore-WebConfiguration { + +function Restore-WebConfiguration { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268869')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true, HelpMessage='Backup name')] @@ -1390,22 +1390,22 @@ param( [string] ${Name}) - - } + + } -function Select-WebConfiguration { +function Select-WebConfiguration { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268870')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] [string[]] ${Filter}) - - } + + } -function Set-WebBinding { +function Set-WebBinding { [CmdletBinding(DefaultParameterSetName='InputBindingProperties', SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268871')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1438,11 +1438,11 @@ param( [string] ${Value}) - - } + } -function Set-WebCentralCertProvider { + +function Set-WebCentralCertProvider { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269641')] param( [Parameter(ValueFromPipelineByPropertyName=$true)] @@ -1461,22 +1461,22 @@ param( [string] ${PrivateKeyPassword}) - - } + + } -function Set-WebCentralCertProviderCredential { +function Set-WebCentralCertProviderCredential { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=269645')] param( [Parameter(Mandatory=$true, Position=0)] [string] ${UserName}) - - } + } -function Set-WebConfiguration { + +function Set-WebConfiguration { [CmdletBinding(DefaultParameterSetName='InputPSObject', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268872')] param( [Parameter(ParameterSetName='InputObject', Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] @@ -1509,11 +1509,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Set-WebConfigurationProperty { +function Set-WebConfigurationProperty { [CmdletBinding(DefaultParameterSetName='InputPSObject', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268873')] param( [Parameter(Mandatory=$true)] @@ -1559,11 +1559,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Set-WebGlobalModule { +function Set-WebGlobalModule { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268874')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1579,11 +1579,11 @@ param( [string] ${Image}) - - } + } -function Set-WebHandler { + +function Set-WebHandler { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268875')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1634,11 +1634,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Set-WebManagedModule { +function Set-WebManagedModule { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low', HelpUri='http://go.microsoft.com/fwlink/?LinkID=268876')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1662,11 +1662,11 @@ param( [string[]] ${PSPath}) - - } + } -function Start-WebAppPool { + +function Start-WebAppPool { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268877')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1677,19 +1677,19 @@ param( [switch] ${Passthru}) - - } + + } -function Start-WebCommitDelay { +function Start-WebCommitDelay { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268816')] param() - - } + + } -function Start-WebItem { +function Start-WebItem { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268878')] param( [switch] @@ -1715,7 +1715,7 @@ dynamicparam { $param = $param.Value - if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) + if (-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) { $dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes) $paramDictionary.Add($param.Name, $dynParam) @@ -1728,11 +1728,11 @@ dynamicparam } } - - } + } -function Start-Website { + +function Start-Website { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268879')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1743,11 +1743,11 @@ param( [switch] ${Passthru}) - - } + + } -function Stop-WebAppPool { +function Stop-WebAppPool { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268880')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1758,11 +1758,11 @@ param( [switch] ${Passthru}) - - } + } -function Stop-WebCommitDelay { + +function Stop-WebCommitDelay { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268824')] param( [Parameter(Position=2)] @@ -1773,11 +1773,11 @@ param( [string[]] ${PSPath}) - - } + + } -function Stop-WebItem { +function Stop-WebItem { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268881')] param( [switch] @@ -1803,7 +1803,7 @@ dynamicparam { $param = $param.Value - if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) + if (-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name)) { $dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes) $paramDictionary.Add($param.Name, $dynParam) @@ -1816,11 +1816,11 @@ dynamicparam } } - - } + } -function Stop-Website { + +function Stop-Website { [CmdletBinding(HelpUri='http://go.microsoft.com/fwlink/?LinkID=268882')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] @@ -1831,8 +1831,8 @@ param( [switch] ${Passthru}) - - } + + } diff --git a/tests/TestHelper/CommonTestHelper.psm1 b/tests/TestHelper/CommonTestHelper.psm1 new file mode 100644 index 000000000..6dbbc5146 --- /dev/null +++ b/tests/TestHelper/CommonTestHelper.psm1 @@ -0,0 +1,121 @@ +<# + .SYNOPSIS + Some tests require a self-signed certificate to be created. However, the + New-SelfSignedCertificate cmdlet built into Windows Server 2012 R2 is too + limited to work for this process. + + Therefore an alternate method of creating self-signed certificates to meet the + reqirements. A script on Microsoft Script Center can be used for this but must + be downloaded: + https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6 + + This cmdlet will install the script if it is not available and dot source it. + + .PARAMETER OutputPath + The path to download the script to. If not provided will default to the current + users temp folder. + + .OUTPUTS + The path to the script that was downloaded. +#> +function Install-NewSelfSignedCertificateExScript +{ + [CmdletBinding()] + [OutputType([String])] + param + ( + [Parameter()] + [String] + $OutputPath = $env:Temp + ) + + $newSelfSignedCertURL = 'https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6/file/101251/2/New-SelfSignedCertificateEx.zip' + $newSelfSignedCertZip = Split-Path -Path $newSelfSignedCertURL -Leaf + $newSelfSignedCertZipPath = Join-Path -Path $OutputPath -ChildPath $newSelfSignedCertZip + $newSelfSignedCertScriptPath = Join-Path -Path $OutputPath -ChildPath 'New-SelfSignedCertificateEx.ps1' + + if (-not (Test-Path -Path $newSelfSignedCertScriptPath)) + { + if (Test-Path -Path $newSelfSignedCertZip) + { + Remove-Item -Path $newSelfSignedCertZipPath -Force + } + + Invoke-WebRequest -Uri $newSelfSignedCertURL -OutFile $newSelfSignedCertZipPath + + Add-Type -AssemblyName System.IO.Compression.FileSystem + + [System.IO.Compression.ZipFile]::ExtractToDirectory($newSelfSignedCertZipPath, $OutputPath) + } # if + return $newSelfSignedCertScriptPath +} # end function Install-NewSelfSignedCertificateExScript + +<# + .SYNOPSIS + Wrapper for Restore-WebConfiguration to be able to retry on errors. + + .PARAMETER Name + The name of the backup to restore. + + .NOTES + - This wrapper is a workaround for the error: + + IOException: The process cannot access the file + 'C:\windows\system32\inetsrv\mbschema.xml' because + it is being used by another process. + + - Addresses Issue #385: xWebConfigPropertyCollection: Timing issue in integration tests + + IOException: The process cannot access the file + 'C:\windows\system32\inetsrv\config\applicationHost.config' + because it is being used by another process. +#> +function Restore-WebConfigurationWrapper +{ + param + ( + [Parameter(Mandatory = $true)] + [System.String] + $Name + ) + + $retryCount = 1 + $backupRestored = $false + + do + { + try + { + Write-Verbose -Message ('Restoring web configuration - attempt {0}' -f $retryCount) -Verbose + + Restore-WebConfiguration -Name $Name + + Write-Verbose -Message ('Successfully restored web configuration' -f $retryCount) -Verbose + + $backupRestored = $true + } + catch [System.IO.IOException] + { + # On the fifth try, throw an error. + if ($retryCount -eq 5) + { + throw $_ + } + + Write-Verbose -Message ('Failed to restore web configuration. Retrying in 5 seconds. For reference the error message was "{0}".' -f $_) -Verbose + + $retryCount += 1 + + Start-Sleep -Seconds 5 + } + catch + { + throw $_ + } + } while (-not $backupRestored) +} + +Export-ModuleMember -Function @( + 'Install-NewSelfSignedCertificateExScript' + 'Restore-WebConfigurationWrapper' +) diff --git a/Tests/Unit/MSFT_WebApplicationHandler.tests.ps1 b/tests/Unit/MSFT_WebApplicationHandler.Tests.ps1 similarity index 93% rename from Tests/Unit/MSFT_WebApplicationHandler.tests.ps1 rename to tests/Unit/MSFT_WebApplicationHandler.Tests.ps1 index 29b178fc6..797f4e281 100644 --- a/Tests/Unit/MSFT_WebApplicationHandler.tests.ps1 +++ b/tests/Unit/MSFT_WebApplicationHandler.Tests.ps1 @@ -1,29 +1,36 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_WebApplicationHandler' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_WebApplicationHandler' -#region Header -#Unit Test Template Version: 1.0.0 +function Invoke-TestSetup +{ + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -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 $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup -# Begin Tests try { - InModuleScope $DSCResourceName { + InModuleScope $script:dscResourceName { $customWebHandlerParameters = @{ Path = 'MACHINE/WEBROOT/APPHOST' @@ -388,7 +395,5 @@ try finally { - #region Footer - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 b/tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 similarity index 82% rename from Tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 rename to tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 index c78334356..683fa4663 100644 --- a/Tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 +++ b/tests/Unit/MSFT_xIISFeatureDelegation.Tests.ps1 @@ -1,30 +1,38 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISFeatureDelegation' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISFeatureDelegation' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup -# Begin Testing try { #region Pester Tests - InModuleScope $DSCResourceName { + InModuleScope $script:dscResourceName { $mockAllowOverrideMode = @{ Metadata = @{ @@ -52,6 +60,10 @@ try #region Function Get-TargetResource Describe 'MSFT_xIISFeatureDelegation\Get-TargetResource' { + BeforeAll { + Mock -CommandName Assert-Module + } + Context 'When OverrideMode is set to Allow' { Mock -CommandName Get-WebConfiguration -MockWith { return $mockAllowOverrideMode } $result = Get-TargetResource @allowTargetResourceParameters @@ -77,6 +89,10 @@ try #region Function Test-TargetResource Describe 'MSFT_xIISFeatureDelegation\Test-TargetResource' { + BeforeAll { + Mock -CommandName Assert-Module + } + Context 'When OverrideMode is set to Allow' { Mock -CommandName Get-WebConfiguration -MockWith { return $mockAllowOverrideMode } It 'Should return True when in desired state' { @@ -139,14 +155,14 @@ try It 'Should throw an error on null' { Mock -CommandName Get-WebConfiguration -MockWith { return $mockWebConfigOutput } - {Get-OverrideMode @getOverrideModeParameters} | Should Throw ($LocalizedData.UnableToGetConfig -f $getOverrideModeParameters.Filter) + {Get-OverrideMode @getOverrideModeParameters} | Should Throw ($script:localizedData.UnableToGetConfig -f $getOverrideModeParameters.Filter) } It 'Should throw an error on the wrong value' { $mockWebConfigOutput.Metadata.effectiveOverrideMode = 'Wrong' Mock -CommandName Get-WebConfiguration -MockWith { return $mockWebConfigOutput } - {Get-OverrideMode @getOverrideModeParameters} | Should Throw ($LocalizedData.UnableToGetConfig -f $getOverrideModeParameters.Filter) + {Get-OverrideMode @getOverrideModeParameters} | Should Throw ($script:localizedData.UnableToGetConfig -f $getOverrideModeParameters.Filter) } } @@ -174,7 +190,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xIISHandler.Tests.ps1 b/tests/Unit/MSFT_xIISHandler.Tests.ps1 similarity index 79% rename from Tests/Unit/MSFT_xIISHandler.Tests.ps1 rename to tests/Unit/MSFT_xIISHandler.Tests.ps1 index 0e7afce42..e87172e5f 100644 --- a/Tests/Unit/MSFT_xIISHandler.Tests.ps1 +++ b/tests/Unit/MSFT_xIISHandler.Tests.ps1 @@ -1,31 +1,39 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIISHandler' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIISHandler' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup -# Begin Testing try { #region Pester Tests - InModuleScope $DSCResourceName { + InModuleScope $script:dscResourceName { #region Function Get-TargetResource Describe 'MSFT_xIISHandler\Get-TargetResource' { @@ -78,7 +86,7 @@ try $result = Test-TargetResource -Name $Name -Ensure 'Present' -Verbose *>&1 It 'Should return the correct verbose message' { - $result[0] | Should Be ($LocalizedData.HandlerExists -f $Name) + $result[0] | Should Be ($script:localizedData.HandlerExists -f $Name) } It 'Should return False' { @@ -107,7 +115,7 @@ try $result = Test-TargetResource -Name $Name -Ensure 'Absent' -Verbose *>&1 It 'Should return the correct verbose message' { - $result[0] | Should Be ($LocalizedData.HandlerNotPresent -f $Name) + $result[0] | Should Be ($script:localizedData.HandlerNotPresent -f $Name) } It 'Should return False' { @@ -133,7 +141,7 @@ try } It 'Should call the right Verbose Message' { - $message | Should Be ($LocalizedData.AddingHandler -f $mockName) + $message | Should Be ($script:localizedData.AddingHandler -f $mockName) } } @@ -150,7 +158,7 @@ try } It 'Should call the right Verbose Message' { - $message | Should Be ($LocalizedData.RemovingHandler -f $mockName) + $message | Should Be ($script:localizedData.RemovingHandler -f $mockName) } } } @@ -172,7 +180,7 @@ try Context 'It should throw when it cannot find the handler' { It 'Should throw an error' { $keyName = 'Non-ExistantKey' - {Add-Handler -Name $keyName} | Should throw ($LocalizedData.HandlerNotSupported -f $KeyName) + {Add-Handler -Name $keyName} | Should throw ($script:localizedData.HandlerNotSupported -f $KeyName) } } } @@ -191,7 +199,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xIISLogging.Tests.ps1 b/tests/Unit/MSFT_xIISLogging.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_xIISLogging.Tests.ps1 rename to tests/Unit/MSFT_xIISLogging.Tests.ps1 index 98289bece..972af9d42 100644 --- a/Tests/Unit/MSFT_xIISLogging.Tests.ps1 +++ b/tests/Unit/MSFT_xIISLogging.Tests.ps1 @@ -1,30 +1,36 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIisLogging' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIisLogging' -# Unit Test Template Version: 1.1.0 -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup -# Begin Testing try { - #region Pester Tests - - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { $MockLogCustomFields = @{ LogFieldName = 'ClientEncoding' @@ -69,7 +75,7 @@ try $MockLogFlagsAfterSplit = [System.String[]] @('Date','Time','ClientIP','UserName','ServerIP','Method','UriStem','UriQuery','HttpStatus','Win32Status','TimeTaken','ServerPort','UserAgent','Referer','HttpSubStatus') - Describe "$script:DSCResourceName\Get-TargetResource" { + Describe "$script:dscResourceName\Get-TargetResource" { Context 'Correct hashtable is returned' { @@ -144,7 +150,7 @@ try } - Describe "$script:DSCResourceName\Test-TargetResource" { + Describe "$script:dscResourceName\Test-TargetResource" { Mock -CommandName Assert-Module -MockWith {} @@ -472,7 +478,7 @@ try } } - Describe "$script:DSCResourceName\Set-TargetResource" { + Describe "$script:dscResourceName\Set-TargetResource" { Mock -CommandName Assert-Module -MockWith {} @@ -770,7 +776,7 @@ try } - Describe "$script:DSCResourceName\ConvertTo-CimLogCustomFields"{ + Describe "$script:dscResourceName\ConvertTo-CimLogCustomFields"{ $MockLogCustomFields = @{ LogFieldName = 'ClientEncoding' SourceName = 'Accept-Encoding' @@ -794,7 +800,7 @@ try } } - Describe "$script:DSCResourceName\Test-LogCustomField" { + Describe "$script:dscResourceName\Test-LogCustomField" { $MockCimLogCustomFields = @( New-CimInstance -ClassName MSFT_xLogCustomField ` -Namespace root/microsoft/Windows/DesiredStateConfiguration ` @@ -843,7 +849,7 @@ try } } - Describe "$script:DSCResourceName\Compare-LogFlags" { + Describe "$script:dscResourceName\Compare-LogFlags" { Context 'Returns false when LogFlags are incorrect' { @@ -891,7 +897,7 @@ try } } - Describe "$script:DSCResourceName\Set-LogCustomField" { + Describe "$script:dscResourceName\Set-LogCustomField" { $MockCimLogCustomFields = @( New-CimInstance -ClassName MSFT_xLogCustomField ` @@ -930,11 +936,9 @@ try } } } - - #endregion } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 b/tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 similarity index 82% rename from Tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 rename to tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 index 86783aa9c..1a3a852b1 100644 --- a/Tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 +++ b/tests/Unit/MSFT_xIisMimeTypeMapping.Tests.ps1 @@ -1,32 +1,39 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xIisMimeTypeMapping' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xIisMimeTypeMapping' -#region HEADER - -$moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) -if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') } -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') +function Invoke-TestCleanup +{ + Remove-Module -Name MockWebAdministrationWindowsFeature -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} +Invoke-TestSetup -# Begin Testing try { - #region Pester Tests - - InModuleScope $DSCResourceName { + InModuleScope $script:dscResourceName { Set-Variable ConstDefaultConfigurationPath -Option Constant -Value 'MACHINE/WEBROOT/APPHOST' $mockMapping = @@ -163,8 +170,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - Remove-Module -Name MockWebAdministrationWindowsFeature - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xSslSettings.Tests.ps1 b/tests/Unit/MSFT_xSslSettings.Tests.ps1 similarity index 74% rename from Tests/Unit/MSFT_xSslSettings.Tests.ps1 rename to tests/Unit/MSFT_xSslSettings.Tests.ps1 index edb26116d..12e79b8f4 100644 --- a/Tests/Unit/MSFT_xSslSettings.Tests.ps1 +++ b/tests/Unit/MSFT_xSslSettings.Tests.ps1 @@ -1,35 +1,40 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xSslSettings' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xSslSettings' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -# Begin Testing +Invoke-TestSetup try { - #region Pester Tests - - InModuleScope $DSCResourceName { - $script:DSCResourceName = 'MSFT_xSslSettings' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_xSslSettings' - Describe "$script:DSCResourceName\Test-TargetResource" { + Describe "$script:dscResourceName\Test-TargetResource" { Context 'Ensure is Present and SSLSettings is Present' { Mock Get-TargetResource -Verifiable {return @{ Name = 'Test' @@ -79,7 +84,7 @@ try } } - Describe "$script:DSCResourceName\Get-TargetResource" { + Describe "$script:dscResourceName\Get-TargetResource" { Context 'Command finds SSL Settings' { Mock Assert-Module -Verifiable {} Mock Get-WebConfigurationProperty -Verifiable { return 'Ssl' } @@ -125,7 +130,7 @@ try } } - Describe "$script:DSCResourceName\Set-TargetResource" { + Describe "$script:dscResourceName\Set-TargetResource" { Context 'SSL Bindings set to none' { Mock Assert-Module -Verifiable { } Mock Set-WebConfigurationProperty -Verifiable {} @@ -133,7 +138,7 @@ try $result = (Set-TargetResource -Name 'Name' -Bindings '' -Ensure 'Present' -Verbose) 4>&1 # Check that the LocalizedData message from the Set-TargetResource is correct - $resultMessage = $LocalizedData.SettingSSLConfig -f 'Name', '' + $resultMessage = $script:localizedData.SettingSSLConfig -f 'Name', '' Assert-VerifiableMock @@ -149,7 +154,7 @@ try $result = (Set-TargetResource -Name 'Name' -Bindings 'Ssl' -Ensure 'Present' -Verbose) 4>&1 # Check that the LocalizedData message from the Set-TargetResource is correct - $resultMessage = $LocalizedData.SettingSSLConfig -f 'Name', 'Ssl' + $resultMessage = $script:localizedData.SettingSSLConfig -f 'Name', 'Ssl' Assert-VerifiableMock @@ -165,7 +170,7 @@ try $result = (Set-TargetResource -Name 'Name' -Bindings @('Ssl','SslNegotiateCert','SslRequireCert') -Ensure 'Present' -Verbose) 4>&1 # Check that the LocalizedData message from the Set-TargetResource is correct - $resultMessage = $LocalizedData.SettingSSLConfig -f 'Name', 'Ssl,SslNegotiateCert,SslRequireCert' + $resultMessage = $script:localizedData.SettingSSLConfig -f 'Name', 'Ssl,SslNegotiateCert,SslRequireCert' Assert-VerifiableMock @@ -178,7 +183,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebAppPool.Tests.ps1 b/tests/Unit/MSFT_xWebAppPool.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xWebAppPool.Tests.ps1 rename to tests/Unit/MSFT_xWebAppPool.Tests.ps1 index bc4088c61..4be3d6565 100644 --- a/Tests/Unit/MSFT_xWebAppPool.Tests.ps1 +++ b/tests/Unit/MSFT_xWebAppPool.Tests.ps1 @@ -4,35 +4,41 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebAppPool' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebAppPool' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup -# Begin Testing try { - #region Pester Tests + InModuleScope $script:dscResourceName { - InModuleScope $script:DSCResourceName { - - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { Mock Assert-Module @@ -352,7 +358,7 @@ try } - Describe "how '$($script:DSCResourceName)\Test-TargetResource' responds to Ensure = 'Absent'" { + Describe "how '$($script:dscResourceName)\Test-TargetResource' responds to Ensure = 'Absent'" { Mock Assert-Module @@ -384,7 +390,7 @@ try } - Describe "how '$($script:DSCResourceName)\Test-TargetResource' responds to Ensure = 'Present'" { + Describe "how '$($script:dscResourceName)\Test-TargetResource' responds to Ensure = 'Present'" { Mock Assert-Module @@ -1707,7 +1713,7 @@ try } - Describe "how '$($script:DSCResourceName)\Set-TargetResource' responds to Ensure = 'Absent'" { + Describe "how '$($script:dscResourceName)\Set-TargetResource' responds to Ensure = 'Absent'" { Mock -CommandName Assert-Module -MockWith {} @@ -1787,7 +1793,7 @@ try } - Describe "how '$($script:DSCResourceName)\Set-TargetResource' responds to Ensure = 'Present'" { + Describe "how '$($script:dscResourceName)\Set-TargetResource' responds to Ensure = 'Present'" { Mock -CommandName Assert-Module -MockWith {} @@ -3308,10 +3314,8 @@ try } } - - #endregion } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 b/tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 rename to tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 index 6a2f9c24b..88702fa1d 100644 --- a/Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 +++ b/tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 @@ -4,9 +4,10 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebAppPoolDefaults' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebAppPoolDefaults' +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 #region HEADER $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` @@ -24,15 +25,49 @@ $TestEnvironment = Initialize-TestEnvironment ` -DSCResourceName $script:DSCResourceName ` -TestType Unit #endregion +======= +function Invoke-TestSetup +{ + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 + +Invoke-TestSetup -# Begin Testing try { +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 #region Pester Tests InModuleScope $script:DSCResourceName { +======= + InModuleScope $script:dscResourceName { +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'xWebAppPoolDefaults\Get-TargetResource' { + BeforeAll { + Mock -CommandName Assert-Module + } Mock Assert-Module @@ -212,6 +247,7 @@ try $result.manualGroupMembership | Should Be $mockAppPoolDefaults.processModel.manualGroupMembership } +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 It 'Should return the maxProcesses property' { $result.maxProcesses | Should Be $mockAppPoolDefaults.processModel.maxProcesses } @@ -300,6 +336,17 @@ try $result.restartRequestsLimit | Should Be $mockAppPoolDefaults.recycling.periodicRestart.requests } ======= +======= + Mock -CommandName Get-WebConfigurationPropertyValue -MockWith { + if ([System.String]::IsNullOrEmpty($path)) { + return $mockAppPoolDefaults[$Name] + } else { + $path = $path.Replace('/', '') + return $mockAppPoolDefaults[$path][$Name] + } + } + +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 $result = Get-TargetResource -IsSingleInstance 'Yes' >>>>>>> BREAKING CHANGE: xWebAppPoolDefaults: Align to best practices for single instance resource (#525) @@ -330,11 +377,30 @@ try } +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 Describe "how '$($script:DSCResourceName)\Test-TargetResource' responds" { Mock Assert-Module Context 'Test target resource with no property specified' { +======= + Describe 'xWebAppPoolDefaults\Test-TargetResource' { + BeforeAll { + Mock -CommandName Assert-Module + + Mock -CommandName Get-Value -ParameterFilter { + $Name -eq 'managedRuntimeVersion' + } -MockWith { + return 'v4.0' + } + + Mock -CommandName Get-Value -ParameterFilter { + $Name -eq 'identityType' + } -MockWith { + return 'NetworkService' + } + } +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 $mockAppPoolDefaults = @{ } @@ -348,6 +414,7 @@ try } +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 <<<<<<< HEAD Context 'All the properties match the desired state' { @@ -479,6 +546,19 @@ try restartSchedule = $mockRestartSchedule } ======= +======= + Mock -CommandName Get-WebConfigurationPropertyValue -MockWith { + $path = $Filter.Replace('system.applicationHost/applicationPools/applicationPoolDefaults', '') + + if ([System.String]::IsNullOrEmpty($path)) { + return $mockAppPoolDefaults[$Name] + } else { + $path = $path.Replace('/', '') + return $mockAppPoolDefaults[$path][$Name] + } + } + +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 Context 'Application pool defaults correct' { $result = Test-TargetResource -IsSingleInstance 'Yes' ` -ManagedRuntimeVersion 'v4.0' ` @@ -632,7 +712,14 @@ try } +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 Context 'Test the managedRuntimeVersion property' { +======= + Describe 'xWebAppPoolDefaults\Set-TargetResource' { + BeforeAll { + Mock -CommandName Assert-Module + } +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 $mockAppPoolDefaults = @{ managedRuntimeVersion = 'v4.0' @@ -692,6 +779,7 @@ try } +<<<<<<< HEAD:Tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 Context 'Test the queueLength property' { $mockAppPoolDefaults = @{ @@ -699,6 +787,18 @@ try } Mock Get-AppPoolDefault -MockWith {$mockAppPoolDefaults} +======= + Mock -CommandName Get-WebConfigurationPropertyValue -MockWith { + if ([System.String]::IsNullOrEmpty($path)) { + return $mockAppPoolDefaults[$Name] + } else { + $path = $path.Replace('/', '') + return $mockAppPoolDefaults[$path][$Name] + } + } + + Mock Set-WebConfigurationProperty -MockWith { } +>>>>>>> Added continuous delivery with a new CI pipeline (#549):tests/Unit/MSFT_xWebAppPoolDefaults.Tests.ps1 <<<<<<< HEAD It 'Should return True when the property matches the desired state' { diff --git a/Tests/Unit/MSFT_xWebApplication.Tests.ps1 b/tests/Unit/MSFT_xWebApplication.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xWebApplication.Tests.ps1 rename to tests/Unit/MSFT_xWebApplication.Tests.ps1 index 84dd85194..be6e36fd1 100644 --- a/Tests/Unit/MSFT_xWebApplication.Tests.ps1 +++ b/tests/Unit/MSFT_xWebApplication.Tests.ps1 @@ -1,28 +1,37 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebApplication' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebApplication' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup try { - InModuleScope -ModuleName $script:DSCResourceName -ScriptBlock { - $script:DSCResourceName = 'MSFT_xWebApplication' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_xWebApplication' $MockAuthenticationInfo = New-CimInstance -ClassName MSFT_xWebApplicationAuthenticationInformation ` -ClientOnly ` @@ -69,7 +78,7 @@ try ) - Describe "$script:DSCResourceName\Get-TargetResource" { + Describe "$script:dscResourceName\Get-TargetResource" { $MockParameters = @{ Website = 'MockSite' @@ -136,7 +145,7 @@ try } - Describe "how $script:DSCResourceName\Test-TargetResource responds to Ensure = 'Absent'" { + Describe "how $script:dscResourceName\Test-TargetResource responds to Ensure = 'Absent'" { Mock -CommandName Get-SslFlags -MockWith { return $GetSslFlags @@ -174,7 +183,7 @@ try } - Describe "how $script:DSCResourceName\Test-TargetResource responds to Ensure = 'Present'" { + Describe "how $script:dscResourceName\Test-TargetResource responds to Ensure = 'Present'" { Mock -CommandName Assert-Module -MockWith {} @@ -498,7 +507,7 @@ try } - Describe "how $script:DSCResourceName\Set-TargetResource responds to Ensure = 'Absent'" { + Describe "how $script:dscResourceName\Set-TargetResource responds to Ensure = 'Absent'" { Mock -CommandName Get-WebConfiguration -ParameterFilter {$filter -eq 'system.webserver/security/access'} -MockWith { return $GetWebConfigurationOutput @@ -522,7 +531,7 @@ try } - Describe "how $script:DSCResourceName\Set-TargetResource responds to Ensure = 'Present'" { + Describe "how $script:dscResourceName\Set-TargetResource responds to Ensure = 'Present'" { Mock -CommandName Assert-Module -MockWith {} @@ -531,7 +540,7 @@ try $script:mockGetWebApplicationCalled = 0 $mockWebApplication = { $script:mockGetWebApplicationCalled++ - if($script:mockGetWebApplicationCalled -eq 1) + if ($script:mockGetWebApplicationCalled -eq 1) { return $null } @@ -1035,7 +1044,7 @@ try } - Describe "$script:DSCResourceName\Confirm-UniqueEnabledProtocols" { + Describe "$script:dscResourceName\Confirm-UniqueEnabledProtocols" { Context 'Tests Confirm-UniqueEnabledProtocols' { @@ -1055,7 +1064,7 @@ try } } - Describe "$script:DSCResourceName\Confirm-UniqueServiceAutoStartProviders" { + Describe "$script:dscResourceName\Confirm-UniqueServiceAutoStartProviders" { $MockParameters = @{ Name = 'MockServiceAutoStartProvider' @@ -1105,7 +1114,7 @@ try $ErrorId = 'ServiceAutoStartProviderFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebApplicationTestAutoStartProviderFailure, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebApplicationTestAutoStartProviderFailure, 'ScriptHalted' $Exception = New-Object -TypeName System.InvalidOperationException -ArgumentList $ErrorMessage $ErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $Exception, $ErrorId, $ErrorCategory, $null @@ -1156,7 +1165,7 @@ try } - Describe "$script:DSCResourceName\Get-AuthenticationInfo" { + Describe "$script:dscResourceName\Get-AuthenticationInfo" { Context 'Expected behavior' { @@ -1224,7 +1233,7 @@ try } - Describe "$script:DSCResourceName\Get-DefaultAuthenticationInfo" { + Describe "$script:dscResourceName\Get-DefaultAuthenticationInfo" { Context 'Expected behavior' { @@ -1249,7 +1258,7 @@ try } - Describe "$script:DSCResourceName\Get-SslFlags" { + Describe "$script:dscResourceName\Get-SslFlags" { Context 'Expected behavior' { @@ -1290,7 +1299,7 @@ try } - Describe "$script:DSCResourceName\Set-Authentication" { + Describe "$script:dscResourceName\Set-Authentication" { Context 'Expected behavior' { @@ -1309,7 +1318,7 @@ try } - Describe "$script:DSCResourceName\Set-AuthenticationInfo" { + Describe "$script:dscResourceName\Set-AuthenticationInfo" { Context 'Expected behavior' { @@ -1332,7 +1341,7 @@ try } - Describe "$script:DSCResourceName\Test-AuthenticationEnabled" { + Describe "$script:dscResourceName\Test-AuthenticationEnabled" { Context 'Expected behavior' { @@ -1398,7 +1407,7 @@ try } - Describe "$script:DSCResourceName\Test-AuthenticationInfo" { + Describe "$script:dscResourceName\Test-AuthenticationInfo" { Mock -CommandName Get-WebConfigurationProperty -MockWith {$GetWebConfigurationOutput} @@ -1467,7 +1476,7 @@ try } - Describe "$script:DSCResourceName\Test-SslFlags" { + Describe "$script:dscResourceName\Test-SslFlags" { Context 'Expected behavior' { @@ -1532,7 +1541,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 b/tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 similarity index 90% rename from Tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 rename to tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 index a10abc84d..70b5edb00 100644 --- a/Tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 +++ b/tests/Unit/MSFT_xWebConfigKeyValue.Tests.ps1 @@ -1,36 +1,44 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebConfigKeyValue' - -#region HEADER -# Unit Test Template Version: 1.1.0 -[String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) -if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebConfigKeyValue' + +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') } -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup -# Begin Testing try { - InModuleScope $script:DSCResourceName { - $script:DSCModuleName = 'xWebAdministration' - $script:DSCResourceName = 'MSFT_xWebConfigKeyValue' + InModuleScope $script:dscResourceName { + $script:dscModuleName = 'xWebAdministration' + $script:dscResourceName = 'MSFT_xWebConfigKeyValue' #region Function Get-TargetResource - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { Context 'Value is absent' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return $null } @@ -54,7 +62,7 @@ try } Context 'Value is present but not an attribute' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $IsAttribute -eq $false } ` -MockWith { return 'Value' } @@ -78,11 +86,11 @@ try } Context 'Value is present but is an attribute' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return $null } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $true } ` -MockWith { return 'Value' } @@ -108,7 +116,7 @@ try #endregion Function Get-TargetResource #region Function Test-TargetResource - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Context 'Ensure is present and is Attribute is False but value is null' { $parameters = @{ WebsitePath = 'C:\SomePath\web.config' @@ -119,7 +127,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return $null } @@ -140,7 +148,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return [System.String]::Empty } @@ -161,7 +169,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return 'WrongValue' } @@ -182,7 +190,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return 'Value' } @@ -203,7 +211,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return 'Value' } @@ -224,7 +232,7 @@ try IsAttribute = $false } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName ` + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName ` -ParameterFilter { $isAttribute -eq $false } ` -MockWith { return $null } @@ -239,7 +247,7 @@ try #region Function Set-TargetResource - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe "$($script:dscResourceName)\Set-TargetResource" { Context 'Ensure is Present and IsAttribute is False and value is not present' { $parameters = @{ WebsitePath = 'C:\SomePath\web.config' @@ -356,7 +364,7 @@ try #endregion Exported Function Unit Tests #region Non-Exported Function Unit Tests - Describe "$($script:DSCResourceName)\Add-Item" { + Describe "$($script:dscResourceName)\Add-Item" { Context 'IsAttribute is false' { Mock -CommandName Add-WebConfigurationProperty -MockWith {} @@ -394,7 +402,7 @@ try } } - Describe "$($script:DSCResourceName)\Edit-Item" { + Describe "$($script:dscResourceName)\Edit-Item" { Context 'IsAttribute is false' { Mock -CommandName Set-WebConfigurationProperty -MockWith { return $filter } @@ -442,7 +450,7 @@ try } } - Describe "$($script:DSCResourceName)\Remove-Item" { + Describe "$($script:dscResourceName)\Remove-Item" { Context 'IsAttribute is false' { Mock -CommandName Clear-WebConfiguration -MockWith { return $filter } @@ -494,7 +502,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 b/tests/Unit/MSFT_xWebConfigProperty.Tests.ps1 similarity index 80% rename from Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 rename to tests/Unit/MSFT_xWebConfigProperty.Tests.ps1 index 324968285..6fec200de 100644 --- a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 +++ b/tests/Unit/MSFT_xWebConfigProperty.Tests.ps1 @@ -1,37 +1,53 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebConfigProperty' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebConfigProperty' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - if (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests.zip')) + try { - Expand-Archive -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests.zip') -DestinationPath (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests') -Force + Import-Module -Name DscResource.Test -Force } - else + catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') -Force -Scope Global } -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') -Force -Scope Global +function Invoke-TestCleanup +{ + if (Get-Module -Name 'MockWebAdministrationWindowsFeature') + { + Write-Information 'Removing MockWebAdministrationWindowsFeature module...' + Remove-Module -Name 'MockWebAdministrationWindowsFeature' + } -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER + $mocks = (Get-ChildItem Function:) | Where-Object { $_.Source -eq 'MockWebAdministrationWindowsFeature' } + + if ($mocks) + { + Write-Information 'Removing MockWebAdministrationWindowsFeature functions...' + $mocks | Remove-Item + } + + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup -# Begin Testing try { - InModuleScope $script:DSCResourceName { - $script:DSCModuleName = 'xWebAdministration' - $script:DSCResourceName = 'MSFT_xWebConfigProperty' + InModuleScope $script:dscResourceName { + $script:dscModuleName = 'xWebAdministration' + $script:dscResourceName = 'MSFT_xWebConfigProperty' $script:presentParameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' @@ -49,7 +65,7 @@ try } #region Function Get-TargetResource - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { Context 'Value is absent' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' @@ -57,7 +73,7 @@ try PropertyName = 'enabled' } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return $null } @@ -81,7 +97,7 @@ try PropertyName = 'enabled' } - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return 'true' } @@ -101,9 +117,9 @@ try #endregion Function Get-TargetResource #region Function Test-TargetResource - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Context 'Ensure is present but value is null' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return $null } @@ -115,7 +131,7 @@ try } Context 'Ensure is present but value is an empty string' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return [System.String]::Empty } @@ -127,7 +143,7 @@ try } Context 'Ensure is present but value is wrong' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return 'false' } @@ -139,7 +155,7 @@ try } Context 'Ensure is present and the value is the same' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return 'true' } @@ -151,7 +167,7 @@ try } Context 'Ensure is absent but value is not null' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return 'true' } @@ -163,7 +179,7 @@ try } Context 'Ensure is absent and value is null' { - Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValue -ModuleName $script:dscResourceName -MockWith { return $null } @@ -177,7 +193,7 @@ try #endregion Function Test-TargetResource #region Function Set-TargetResource - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe "$($script:dscResourceName)\Set-TargetResource" { Context 'Ensure is present - String Value' { Mock -CommandName Get-ItemPropertyType -MockWith { return 'String' } Mock -CommandName Convert-PropertyValue @@ -219,7 +235,7 @@ try #endregion Function Set-TargetResource #region Non-Exported Function Unit Tests - Describe "$($script:DSCResourceName)\Get-ItemPropertyType" { + Describe "$($script:dscResourceName)\Get-ItemPropertyType" { $propertyType = 'UInt32' $parameters = @{ WebsitePath = 'IIS:\' @@ -245,7 +261,7 @@ try } } - Describe "$($script:DSCResourceName)\Convert-PropertyValue" { + Describe "$($script:dscResourceName)\Convert-PropertyValue" { $cases = @( @{DataType = 'Int32'}, @{DataType = 'Int64'}, @@ -264,18 +280,5 @@ try } finally { - if (Get-Module -Name 'MockWebAdministrationWindowsFeature') - { - Write-Information 'Removing MockWebAdministrationWindowsFeature module...' - Remove-Module -Name 'MockWebAdministrationWindowsFeature' - } - $mocks = (Get-ChildItem Function:) | Where-Object { $_.Source -eq 'MockWebAdministrationWindowsFeature' } - if ($mocks) - { - Write-Information 'Removing MockWebAdministrationWindowsFeature functions...' - $mocks | Remove-Item - } - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebConfigPropertyCollection.tests.ps1 b/tests/Unit/MSFT_xWebConfigPropertyCollection.Tests.ps1 similarity index 89% rename from Tests/Unit/MSFT_xWebConfigPropertyCollection.tests.ps1 rename to tests/Unit/MSFT_xWebConfigPropertyCollection.Tests.ps1 index a2610c310..786ba1028 100644 --- a/Tests/Unit/MSFT_xWebConfigPropertyCollection.tests.ps1 +++ b/tests/Unit/MSFT_xWebConfigPropertyCollection.Tests.ps1 @@ -1,32 +1,40 @@ #region HEADER -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebConfigPropertyCollection' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebConfigPropertyCollection' -# Unit Test Template Version: 1.2.2 -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -ResourceType 'Mof' ` - -TestType Unit + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup -# Begin Testing try { - InModuleScope $script:DSCResourceName { - $script:DSCModuleName = 'xWebAdministration' - $script:DSCResourceName = 'MSFT_xWebConfigPropertyCollection' + InModuleScope $script:dscResourceName { + $script:dscModuleName = 'xWebAdministration' + $script:dscResourceName = 'MSFT_xWebConfigPropertyCollection' $script:presentParameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' @@ -52,7 +60,7 @@ try } #region Function Get-TargetResource - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' @@ -63,7 +71,7 @@ try ItemPropertyName = 'allowed' } Context 'Collection item does not exist' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return $null } @@ -87,7 +95,7 @@ try } Context 'Collection item exists but does not contain property' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @(@{ Name = 'Property1' Value = 'Property1Value' @@ -114,7 +122,7 @@ try } Context 'Collection item exists and contains property' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @{ Property1 = 'Property1Value' allowed = 'false' @@ -144,9 +152,9 @@ try #endregion Function Get-TargetResource #region Function Test-TargetResource - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Context 'Ensure is present but collection item does not exist' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return $null } @@ -158,7 +166,7 @@ try } Context 'Ensure is present and collection item exists but does not contain property' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @(@{ Name = 'Property1' Value = 'Property1Value' @@ -173,7 +181,7 @@ try } Context 'Ensure is present and collection item and property exists but value is wrong' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @{ Property1 = 'Property1Value' allowed = 'true' @@ -188,7 +196,7 @@ try } Context 'Ensure is present and collection item and property exists and value is same' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @{ Property1 = 'Property1Value' allowed = 'false' @@ -203,7 +211,7 @@ try } Context 'Ensure is absent but collection item and property exists' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @{ Property1 = 'Property1Value' allowed = 'false' @@ -218,7 +226,7 @@ try } Context 'Ensure is absent and collection item and property do not exist' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return $null } @@ -232,9 +240,9 @@ try #endregion Function Test-TargetResource #region Function Set-TargetResource - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe "$($script:dscResourceName)\Set-TargetResource" { Context 'Ensure is present and collection item and property do not exist - String ItemPropertyValue' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName Mock -CommandName Add-WebConfigurationProperty Mock -CommandName Get-CollectionItemPropertyType -MockWith { return 'String' } Mock -CommandName Convert-PropertyValue @@ -250,7 +258,7 @@ try } Context 'Ensure is present and collection item and property do not exist - Integer ItemPropertyValue' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName Mock -CommandName Add-WebConfigurationProperty Mock -CommandName Get-CollectionItemPropertyType -MockWith { return 'Int64' } Mock -CommandName Convert-PropertyValue @@ -266,7 +274,7 @@ try } Context 'Ensure is present and collection item and property exist' { - Mock -CommandName Get-ItemValues -ModuleName $script:DSCResourceName -MockWith { + Mock -CommandName Get-ItemValues -ModuleName $script:dscResourceName -MockWith { return @{ Property1 = 'Property1Value' allowed = 'false' @@ -302,7 +310,7 @@ try #region Non-Exported Function Unit Tests - Describe "$($script:DSCResourceName)\Get-ItemValues" { + Describe "$($script:dscResourceName)\Get-ItemValues" { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' @@ -364,7 +372,7 @@ try } } - Describe "$($script:DSCResourceName)\Get-CollectionItemPropertyType" { + Describe "$($script:dscResourceName)\Get-CollectionItemPropertyType" { $propertyType = 'UInt32' $parameters = @{ WebsitePath = 'IIS:\' @@ -383,6 +391,12 @@ try } } + <# + This function in the code contains a output type that is not mocked. + Tricking the mock to use this empty function-block instead. + #> + function Get-AddElementSchema {} + Mock -CommandName Get-AddElementSchema -MockWith { @{ Name = $parameters.PropertyName @@ -397,7 +411,7 @@ try } } - Describe "$($script:DSCResourceName)\Convert-PropertyValue" { + Describe "$($script:dscResourceName)\Convert-PropertyValue" { $cases = @( @{DataType = 'Int32'}, @{DataType = 'Int64'}, @@ -429,7 +443,6 @@ finally Write-Information 'Removing MockWebAdministrationWindowsFeature functions...' $mocks | Remove-Item } - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 b/tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 similarity index 86% rename from Tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 rename to tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 index e60064e5a..187b87b37 100644 --- a/Tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 +++ b/tests/Unit/MSFT_xWebVirtualDirectory.Tests.ps1 @@ -1,29 +1,38 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebVirtualDirectory' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebVirtualDirectory' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup try { - InModuleScope $script:DSCResourceName { - Describe "$script:DSCResourceName\Test-TargetResource" { + InModuleScope $script:dscResourceName { + Describe "$script:dscResourceName\Test-TargetResource" { $MockSite = @{ Website = 'contoso.com' WebApplication = 'contosoapp' @@ -93,7 +102,7 @@ try } } - Describe "$script:DSCResourceName\Get-TargetResource" { + Describe "$script:dscResourceName\Get-TargetResource" { Mock -CommandName Assert-Module -MockWith {} Context 'Ensure = Absent and virtual directory does not exist' { @@ -151,7 +160,7 @@ try } } - Describe "$script:DSCResourceName\Set-TargetResource" { + Describe "$script:dscResourceName\Set-TargetResource" { Mock -CommandName Assert-Module -MockWith {} @@ -225,7 +234,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_xWebsite.Tests.ps1 b/tests/Unit/MSFT_xWebsite.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xWebsite.Tests.ps1 rename to tests/Unit/MSFT_xWebsite.Tests.ps1 index 2eb33f024..276d27423 100644 --- a/Tests/Unit/MSFT_xWebsite.Tests.ps1 +++ b/tests/Unit/MSFT_xWebsite.Tests.ps1 @@ -1,38 +1,45 @@ -$script:DSCModuleName = 'xWebAdministration' -$script:DSCResourceName = 'MSFT_xWebSite' +$script:dscModuleName = 'xWebAdministration' +$script:dscResourceName = 'MSFT_xWebSite' -#region HEADER -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion +Invoke-TestSetup -# Begin Testing try { - #region Pester Tests - InModuleScope -ModuleName $script:DSCResourceName -ScriptBlock { - $script:DSCResourceName = 'MSFT_xWebSite' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_xWebSite' # Make sure we don't have the original module in memory. Remove-Module -Name 'WebAdministration' -ErrorAction SilentlyContinue # Load the stubs $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\MockWebAdministrationWindowsFeature.psm1') -Force + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\MockWebAdministrationWindowsFeature.psm1') -Force - Describe "how $script:DSCResourceName\Get-TargetResource responds" { + Describe "how $script:dscResourceName\Get-TargetResource responds" { $MockWebBinding = @( @{ bindingInformation = '*:443:web01.contoso.com' @@ -139,7 +146,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteDiscoveryFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteDiscoveryFailure -f 'MockName' + $ErrorMessage = $script:localizedData.ErrorWebsiteDiscoveryFailure -f 'MockName' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -316,7 +323,7 @@ try } } - Describe "how $script:DSCResourceName\Test-TargetResource responds to Ensure = 'Present'" { + Describe "how $script:dscResourceName\Test-TargetResource responds to Ensure = 'Present'" { $MockBindingInfo = @( New-CimInstance -ClassName MSFT_xWebBindingInformation ` -Namespace root/microsoft/Windows/DesiredStateConfiguration ` @@ -944,7 +951,7 @@ try } } - Describe "how $script:DSCResourceName\Set-TargetResource responds to Ensure = 'Present'" { + Describe "how $script:dscResourceName\Set-TargetResource responds to Ensure = 'Present'" { $MockAuthenticationInfo = New-CimInstance ` -ClassName MSFT_xWebApplicationAuthenticationInformation ` -ClientOnly ` @@ -1287,7 +1294,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteBindingConflictOnStart' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingConflictOnStart -f $MockParameters.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingConflictOnStart -f $MockParameters.Name $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -1313,7 +1320,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteStateFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebsiteStateFailure -f $MockParameters.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteStateFailure -f $MockParameters.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -1670,7 +1677,7 @@ try It 'Should throw the correct error' { $ErrorId = 'WebsiteBindingConflictOnStart' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingConflictOnStart -f $MockParameters.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingConflictOnStart -f $MockParameters.Name $Exception = New-Object -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage $ErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord ` @@ -1696,7 +1703,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteCreationFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebsiteCreationFailure -f $MockParameters.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteCreationFailure -f $MockParameters.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -1742,7 +1749,7 @@ try } } - Describe "how $script:DSCResourceName\Set-TargetResource responds to Ensure = 'Absent'" { + Describe "how $script:dscResourceName\Set-TargetResource responds to Ensure = 'Absent'" { $MockParameters = @{ Ensure = 'Absent' Name = 'MockName' @@ -1767,7 +1774,7 @@ try $ErrorId = 'WebsiteRemovalFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebsiteRemovalFailure -f $MockParameters.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteRemovalFailure -f $MockParameters.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -1779,7 +1786,7 @@ try } } - Describe "$script:DSCResourceName\Confirm-UniqueBinding" { + Describe "$script:dscResourceName\Confirm-UniqueBinding" { Context 'Returns false when LogFlags are incorrect' { $MockLogOutput = @{ @@ -1826,7 +1833,7 @@ try } - Describe "$script:DSCResourceName\Confirm-UniqueBinding" { + Describe "$script:dscResourceName\Confirm-UniqueBinding" { $MockParameters = @{ Name = 'MockSite' } @@ -1836,7 +1843,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteNotFound' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteNotFound -f $MockParameters.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteNotFound -f $MockParameters.Name $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2024,7 +2031,7 @@ try } } - Describe "$script:DSCResourceName\Confirm-UniqueServiceAutoStartProviders" { + Describe "$script:dscResourceName\Confirm-UniqueServiceAutoStartProviders" { $MockParameters = @{ Name = 'MockServiceAutoStartProvider' Type = 'MockApplicationType' @@ -2076,7 +2083,7 @@ try It 'should return Throw' { $ErrorId = 'ServiceAutoStartProviderFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebsiteTestAutoStartProviderFailure, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteTestAutoStartProviderFailure, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2131,7 +2138,7 @@ try } } - Describe "$script:DSCResourceName\ConvertTo-CimBinding" { + Describe "$script:dscResourceName\ConvertTo-CimBinding" { Context 'IPv4 address is passed and the protocol is http' { $MockWebBinding = @{ bindingInformation = '127.0.0.1:80:MockHostName' @@ -2263,7 +2270,7 @@ try } } - Describe "$script:DSCResourceName\ConvertTo-WebBinding" -Tag 'ConvertTo' { + Describe "$script:dscResourceName\ConvertTo-WebBinding" -Tag 'ConvertTo' { Context 'Expected behaviour' { $MockBindingInfo = @( New-CimInstance ` @@ -2318,7 +2325,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebBindingInvalidIPAddress' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingInvalidIPAddress -f $MockBindingInfo.IPAddress, 'Exception calling "Parse" with "1" argument(s): "An invalid IP address was specified."' + $ErrorMessage = $script:localizedData.ErrorWebBindingInvalidIPAddress -f $MockBindingInfo.IPAddress, 'Exception calling "Parse" with "1" argument(s): "An invalid IP address was specified."' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2377,7 +2384,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebBindingInvalidPort' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingInvalidPort -f $MockBindingInfo.Port + $ErrorMessage = $script:localizedData.ErrorWebBindingInvalidPort -f $MockBindingInfo.Port $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2435,7 +2442,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebBindingMissingCertificateThumbprint' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingMissingCertificateThumbprint -f $MockBindingInfo.Protocol + $ErrorMessage = $script:localizedData.ErrorWebBindingMissingCertificateThumbprint -f $MockBindingInfo.Protocol $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2519,7 +2526,7 @@ try $CertificateSubject = "CN=$($MockBindingInfo.CertificateSubject)" $ErrorId = 'WebBindingInvalidCertificateSubject' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingInvalidCertificateSubject -f $CertificateSubject, $MockBindingInfo.CertificateStoreName + $ErrorMessage = $script:localizedData.ErrorWebBindingInvalidCertificateSubject -f $CertificateSubject, $MockBindingInfo.CertificateStoreName $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2565,7 +2572,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebBindingMissingSniHostName' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingMissingSniHostName + $ErrorMessage = $script:localizedData.ErrorWebBindingMissingSniHostName $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2610,7 +2617,7 @@ try $ErrorId = 'WebBindingMissingBindingInformation' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $ErrorMessage = $LocalizedData.ErrorWebBindingMissingBindingInformation -f $MockBindingInfo.Protocol + $ErrorMessage = $script:localizedData.ErrorWebBindingMissingBindingInformation -f $MockBindingInfo.Protocol $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -2640,7 +2647,7 @@ try } } - Describe "$script:DSCResourceName\Format-IPAddressString" { + Describe "$script:dscResourceName\Format-IPAddressString" { Context 'Input value is not valid' { It 'should throw an error' { { Format-IPAddressString -InputString 'Invalid' } | Should Throw @@ -2667,7 +2674,7 @@ try } } - Describe "$script:DSCResourceName\Get-AuthenticationInfo" { + Describe "$script:dscResourceName\Get-AuthenticationInfo" { $MockWebsite = @{ Name = 'MockName' PhysicalPath = 'C:\NonExistent' @@ -2737,7 +2744,7 @@ try } } - Describe "$script:DSCResourceName\Get-DefaultAuthenticationInfo" { + Describe "$script:dscResourceName\Get-DefaultAuthenticationInfo" { Context 'Expected behavior' { It 'should not throw an error' { { Get-DefaultAuthenticationInfo }| @@ -2756,7 +2763,7 @@ try } } - Describe "$script:DSCResourceName\Set-Authentication" { + Describe "$script:dscResourceName\Set-Authentication" { Context 'Expected behavior' { $MockWebsite = @{ Name = 'MockName' @@ -2785,7 +2792,7 @@ try } } - Describe "$script:DSCResourceName\Set-AuthenticationInfo" { + Describe "$script:dscResourceName\Set-AuthenticationInfo" { Context 'Expected behavior' { $MockWebsite = @{ Name = 'MockName' @@ -2818,7 +2825,7 @@ try } } - Describe "$script:DSCResourceName\Test-AuthenticationEnabled" { + Describe "$script:dscResourceName\Test-AuthenticationEnabled" { $MockWebsite = @{ Name = 'MockName' PhysicalPath = 'C:\NonExistent' @@ -2888,7 +2895,7 @@ try } } - Describe "$script:DSCResourceName\Test-AuthenticationInfo" { + Describe "$script:dscResourceName\Test-AuthenticationInfo" { Mock -CommandName Get-WebConfigurationProperty -MockWith {$MockWebConfiguration} $MockWebsite = @{ @@ -2964,7 +2971,7 @@ try } } - Describe "$script:DSCResourceName\Test-BindingInfo" { + Describe "$script:dscResourceName\Test-BindingInfo" { Context 'BindingInfo is valid' { $MockBindingInfo = @( New-CimInstance ` @@ -3100,7 +3107,7 @@ try } } - Describe "$script:DSCResourceName\Test-PortNumber" { + Describe "$script:dscResourceName\Test-PortNumber" { Context 'Input value is not valid' { It 'should not throw an error' { {Test-PortNumber -InputString 'InvalidString'} | Should Not Throw @@ -3130,7 +3137,7 @@ try } } - Describe "$script:DSCResourceName\Test-WebsiteBinding" { + Describe "$script:dscResourceName\Test-WebsiteBinding" { $MockWebBinding = @( @{ bindingInformation = '*:80:' @@ -3167,7 +3174,7 @@ try $ErrorId = 'WebsiteBindingInputInvalidation' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingInputInvalidation -f $MockWebsite.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingInputInvalidation -f $MockWebsite.Name $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3197,7 +3204,7 @@ try $ErrorId = 'WebsiteCompareFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteCompareFailure -f $MockWebsite.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteCompareFailure -f $MockWebsite.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3421,7 +3428,7 @@ try $ErrorId = 'WebsiteBindingInputInvalidation' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingInputInvalidation -f $MockWebsite.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingInputInvalidation -f $MockWebsite.Name $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3664,7 +3671,7 @@ try } } - Describe "$script:DSCResourceName\Update-DefaultPage" { + Describe "$script:dscResourceName\Update-DefaultPage" { $MockWebsite = @{ Ensure = 'Present' Name = 'MockName' @@ -3689,7 +3696,7 @@ try } } - Describe "$script:DSCResourceName\Update-WebsiteBinding" { + Describe "$script:dscResourceName\Update-WebsiteBinding" { $MockWebsite = @{ Name = 'MockSite' ItemXPath = "/system.applicationHost/sites/site[@name='MockSite']" @@ -3748,7 +3755,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteNotFound' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteNotFound -f $MockWebsite.Name + $ErrorMessage = $script:localizedData.ErrorWebsiteNotFound -f $MockWebsite.Name $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3770,7 +3777,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteBindingUpdateFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingUpdateFailure -f $MockWebsite.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingUpdateFailure -f $MockWebsite.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3794,7 +3801,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebsiteBindingUpdateFailure' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidResult - $ErrorMessage = $LocalizedData.ErrorWebsiteBindingUpdateFailure -f $MockWebsite.Name, 'ScriptHalted' + $ErrorMessage = $script:localizedData.ErrorWebsiteBindingUpdateFailure -f $MockWebsite.Name, 'ScriptHalted' $Exception = New-Object ` -TypeName System.InvalidOperationException ` -ArgumentList $ErrorMessage @@ -3824,7 +3831,7 @@ try It 'should throw the correct error' { $ErrorId = 'WebBindingCertificate' $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation - $ErrorMessage = $LocalizedData.ErrorWebBindingCertificate -f $MockBindingInfo.CertificateThumbprint, 'Exception calling "AddSslCertificate" with "2" argument(s): "ScriptHalted"' + $ErrorMessage = $script:localizedData.ErrorWebBindingCertificate -f $MockBindingInfo.CertificateThumbprint, 'Exception calling "AddSslCertificate" with "2" argument(s): "ScriptHalted"' $Exception = New-Object -TypeName System.InvalidOperationException -ArgumentList $ErrorMessage $ErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $Exception, $ErrorId, $ErrorCategory, $null @@ -3835,7 +3842,7 @@ try } } - Describe "$script:DSCResourceName\ConvertTo-CimLogCustomFields"{ + Describe "$script:dscResourceName\ConvertTo-CimLogCustomFields"{ $mockLogCustomFields = @( @{ LogFieldName = 'LogField1' @@ -3869,7 +3876,7 @@ try } } - Describe "$script:DSCResourceName\Test-LogCustomField"{ + Describe "$script:dscResourceName\Test-LogCustomField"{ $MockWebsiteName = 'ContosoSite' $MockCimLogCustomFields = @( @@ -3921,7 +3928,7 @@ try } - Describe "$script:DSCResourceName\Set-LogCustomField"{ + Describe "$script:dscResourceName\Set-LogCustomField"{ $MockWebsiteName = 'ContosoSite' $MockCimLogCustomFields = @( @@ -3964,7 +3971,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/xWebAdministration.Common.Tests.ps1 b/tests/Unit/xWebAdministration.Common.Tests.ps1 similarity index 98% rename from Tests/Unit/xWebAdministration.Common.Tests.ps1 rename to tests/Unit/xWebAdministration.Common.Tests.ps1 index 180525577..d8fcf4755 100644 --- a/Tests/Unit/xWebAdministration.Common.Tests.ps1 +++ b/tests/Unit/xWebAdministration.Common.Tests.ps1 @@ -8,13 +8,24 @@ #> Get-Module -Name 'xWebAdministration.Common' -All | Remove-Module -Force -# Import the xWebAdministration.Common module to test -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules\xWebAdministration.Common' +#region HEADER +$script:projectPath = "$PSScriptRoot\..\.." | Convert-Path +$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and + $(try { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop } catch { $false }) + }).BaseName -Import-Module -Name (Join-Path -Path $script:modulesFolderPath -ChildPath 'xWebAdministration.Common.psm1') -Force +$script:parentModule = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1 +$script:subModulesFolder = Join-Path -Path $script:parentModule.ModuleBase -ChildPath 'Modules' +Remove-Module -Name $script:parentModule -Force -ErrorAction 'SilentlyContinue' -InModuleScope 'xWebAdministration.Common' { +$script:subModuleName = (Split-Path -Path $PSCommandPath -Leaf) -replace '\.Tests.ps1' +$script:subModuleFile = Join-Path -Path $script:subModulesFolder -ChildPath "$($script:subModuleName)" + +Import-Module $script:subModuleFile -Force -ErrorAction Stop +#endregion HEADER + +InModuleScope $script:subModuleName { Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelper\CommonTestHelper.psm1') -Force Describe 'xWebAdministration.Common\Get-LocalizedData' { diff --git a/Tests/xWebAdministration.TestHarness.psm1 b/tests/xWebAdministration.TestHarness.psm1 similarity index 100% rename from Tests/xWebAdministration.TestHarness.psm1 rename to tests/xWebAdministration.TestHarness.psm1 diff --git a/xWebAdministration.psd1 b/xWebAdministration.psd1 deleted file mode 100644 index a1821a4c9..000000000 --- a/xWebAdministration.psd1 +++ /dev/null @@ -1,165 +0,0 @@ -@{ - # Version number of this module. - moduleVersion = '3.0.0.0' - - # ID used to uniquely identify this module - GUID = 'b3239f27-d7d3-4ae6-a5d2-d9a1c97d6ae4' - - # Author of this module - Author = 'Microsoft Corporation' - - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' - - # Copyright statement for this module - Copyright = '(c) 2019 Microsoft Corporation. All rights reserved.' - - # Description of the functionality provided by this module - Description = 'Module with DSC Resources for Web Administration' - - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '4.0' - - # Minimum version of the common language runtime (CLR) required by this module - CLRVersion = '4.0' - - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') - - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/xWebAdministration/blob/master/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/xWebAdministration' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = '- Changes to xWebAdministration - - Changes to PULL\_REQUEST\_TEMPLATE.md - - Improving descriptive text around the CHANGELOG.md entry. - - Adding note that entry in CHANGELOG.md is mandatory for all PRs. - - Resolved custom Script Analyzer rules that was added to the test - framework. - - Moved change log from README.md to a separate CHANGELOG.md ([issue 446](https://github.com/PowerShell/xWebAdministration/issues/446)). - - Remove example "Creating the default website using configuration - data" from README.md ([issue 488](https://github.com/PowerShell/xWebAdministration/issues/488)). - - Removed examples README.md as it was obsolete ([issue 482](https://github.com/PowerShell/xWebAdministration/issues/482)). - - Updated `Ensure` property description for `xIisHandler` resource to - match schema.mof - - Moved examples from Readme.md to respective `/Examples/Resources/` - folders ([issue 486](https://github.com/PowerShell/xWebAdministration/issues/486)). - - Created new folder structure for examples so that examples will be - placed in `/Examples/Resources/$resourceName` ([issue 483](https://github.com/PowerShell/xWebAdministration/issues/483)). - - Added a table of contents for the resource list ([issue 450](https://github.com/PowerShell/xWebAdministration/issues/450)). - - Alphabetized the resource list in the README.md ([issue 449](https://github.com/PowerShell/xWebAdministration/issues/449)). - - Optimized exporting in the module manifest for best performance ([issue 448](https://github.com/PowerShell/xWebAdministration/issues/448)). - - Updated hashtables in the repo to adhere to the style guidelines - described at https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.mdcorrect-format-for-hashtables-or-objects - ([issue 524](https://github.com/PowerShell/xWebAdministration/issues/524)) - - Moved example Sample_EndToEndxWebAdministration from readme.md to a - separate .ps1 in `/examples/` ([issue 491](https://github.com/PowerShell/xWebAdministration/issues/491)) - - Removed example "Create and configure an application pool" from - README.md ([issue 489](https://github.com/PowerShell/xWebAdministration/issues/489)). -- Changes to xIisHandler - - Updated schema.mof to include descriptions for each property ([issue 453](https://github.com/PowerShell/xWebAdministration/issues/453)). - - Moved MSFT_xIisHandler localization strings to strings.psd1 ([issue 463](https://github.com/PowerShell/xWebAdministration/issues/463)). -- Changes to xWebSite - - Fix `Get-TargetResource` so that `LogFlags` are returned as expected - array of strings (one for each flag) rather than an array containing - a single comma-separated string of flags" ([issue 332](https://github.com/PowerShell/xWebAdministration/issues/332)). - - Moved localization strings to strings.psd1 file ([issue 475](https://github.com/PowerShell/xWebAdministration/issues/475)) - - Updated schema.mof so that each property has an appropriate description ([issue 456](https://github.com/PowerShell/xWebAdministration/issues/456)). - - Updated schema.mof and README so that `SourceType` and `SourceName` - properties for `MSFT_xLogCustomFieldInformation` are associated with - the appropriate descriptions and valuemaps/values ([issue 456](https://github.com/PowerShell/xWebAdministration/issues/456)). - - Move examples from README.md to resource examples folder ([issue 487](https://github.com/PowerShell/xWebAdministration/issues/487)). - - Fix case of resource name from `xWebsite` to `xWebSite` ([issue 535](https://github.com/PowerShell/xWebAdministration/issues/535)). -- Changes to xIISLogging - - Fix `Get-TargetResource` so that `LogFlags` are returned as expected - array of strings (one for each flag) rather than an array containing - a single comma-separated string of flags ([issue 332](https://github.com/PowerShell/xWebAdministration/issues/332)). - - Moved MSFT_xIisLogging localization strings to strings.psd1 ([issue 464](https://github.com/PowerShell/xWebAdministration/issues/464)). -- Changes to xSslSettings - - Updated casing of `xSslSettings` in all file names, folder names, - schema, and documentation ([issue 461](https://github.com/PowerShell/xWebAdministration/issues/461)). - - Updated casing of `xSslSettings` in all file names, folder names, - schema, and documentation ([issue 536](https://github.com/PowerShell/xWebAdministration/issues/536)). - - Moved MSFT_xSslSettings localization strings to strings.psd1 ([issue 467](https://github.com/PowerShell/xWebAdministration/issues/467)). -- Changes to xWebConfigKeyValue - - Updated schema.mof to include a description for the Ensure property ([issue 455](https://github.com/PowerShell/xWebAdministration/issues/455)). - - Move localization strings to strings.psd1 file ([issue 472](https://github.com/PowerShell/xWebAdministration/issues/472)). -- Changes to xWebAppPoolDefaults - - Move localization strings to strings.psd1 file ([issue 470](https://github.com/PowerShell/xWebAdministration/issues/470)). - - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` - to bring the resource into compliance with published best practices ([issue 462](https://github.com/PowerShell/xWebAdministration/issues/462)). -- Changes to xWebApplication - - Move localization strings to strings.psd1 file ([issue 468](https://github.com/PowerShell/xWebAdministration/issues/468)) - - Add description on class MSFT_xWebApplicationAuthenticationInformation ([issue 454](https://github.com/PowerShell/xWebAdministration/issues/454)). -- Changes to xIisModule entry - - Moved xIisModule localization strings to strings.psd1 ([issue 466](https://github.com/PowerShell/xWebAdministration/issues/466)). -- Changes to xIisMimeTypeMapping - - Moved MSFT_xIisMimeTypeMapping localization strings to strings.psd1 ([issue 465](https://github.com/PowerShell/xWebAdministration/issues/465)). -- Changes to xWebVirtualDirectory - - Moved MSFT_xWebVirtualDirectory localization strings to strings.psd1 ([issue 477](https://github.com/PowerShell/xWebAdministration/issues/477)). -- Changes to xWebSiteDefaults - - Move localization strings to strings.psd1 file ([issue 475](https://github.com/PowerShell/xWebAdministration/issues/475)). - - BREAKING CHANGE: Changed `ApplyTo` key parameter to `IsSingleInstance` - to bring the resource into compliance with published best practices ([issue 457](https://github.com/PowerShell/xWebAdministration/issues/457)). - - Fix case of resource name from `xWebsiteDefaults` to `xWebSiteDefaults` ([issue 535](https://github.com/PowerShell/xWebAdministration/issues/535)). -- Changes to xWebConfigProperty - - Move localization strings to strings.psd1 file ([issue 473](https://github.com/PowerShell/xWebAdministration/issues/473)). -- Changes to xWebConfigPropertyCollection - - Move localization strings to strings.psd1 file ([issue 474](https://github.com/PowerShell/xWebAdministration/issues/474)). -- Changes to xIisFeatureDelegation - - Moved MSFT_xIisFeatureDelegation localization strings to strings.psd1 ([issue 459](https://github.com/PowerShell/xWebAdministration/issues/459)). -- Changes to xWebAppPool - - Moved MSFT_xWebAppPool localization strings to strings.psd1 ([issue 469](https://github.com/PowerShell/xWebAdministration/issues/469)). - -' - - } # End of PSData hashtable - - } # End of PrivateData hashtable - - # Functions to export from this module - FunctionsToExport = @() - - # Cmdlets to export from this module - CmdletsToExport = @() - - # Variables to export from this module - VariablesToExport = @() - - # Aliases to export from this module - AliasesToExport = @() - -} - - - - - - - - - - - - - - - - - - - - - -