Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

BREAKING CHANGE: OfficeOnlineServerFarm: Added 'IsSingleInstance' parameter #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- OfficeOnlineServerFarm
- Added parameter 'IsSingleInstance'

### Changed

- OfficeOnlineServerDsc
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[ClassVersion("1.0.0.0"), FriendlyName("OfficeOnlineServerFarm")]
class MSFT_OfficeOnlineServerFarm : OMI_BaseResource
{
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"),ValueMap{"Yes"},Values{"Yes"}] String IsSingleInstance;
[Write, Description("Enables Customer Experience Improvement Program (CEIP) reporting on all servers in the Office Web Apps Server farm")] Boolean AllowCEIP;
[Write, Description("Indicates that IIS sites should be provisioned on port 80 for HTTP access. Use AllowHTTP only in environments where all computers require IPSEC (full encryption) or in test environments that do not contain sensitive files.")] Boolean AllowHttp;
[Write, Description("Indicates that secure store connections can be made by using non-SSL connections (such as HTTP). The default is False.")] Boolean AllowHttpSecureStoreConnections;
Expand Down Expand Up @@ -31,7 +32,7 @@ class MSFT_OfficeOnlineServerFarm : OMI_BaseResource
[Write, Description("Specifies the maximum size, in megabytes, of a chart or image that can be opened.")] Sint32 ExcelChartAndImageSizeMax;
[Write, Description("Specifies the URL root that clients use to access the Office Web Apps Server farm from the Internet. In the case of a load-balanced, multiserver Office Web Apps Server farm, the external URL is bound to the IP address of the external-facing load balancer.")] String ExternalURL;
[Write, Description("Specifies the name of the Active Directory organizational unit (OU) that servers must be a member of to join the Office Web Apps Server farm. Use this parameter to prevent unauthorized servers (that is, servers that are not in the OU) from joining an Office Web Apps Server farm.")] String FarmOU;
[Key, Description("Specifies the URL root that clients use to access the Office Web Apps Server farm from the intranet.")] String InternalURL;
[Write, Description("Specifies the URL root that clients use to access the Office Web Apps Server farm from the intranet.")] String InternalURL;
[Write, Description("Specifies the location on the local computer where activity logs are stored.")] String LogLocation;
[Write, Description("Specifies the number of days that log entries are stored. Log entries older than the configured date are trimmed.")] Sint32 LogRetentionInDays;
[Write, Description("Specifies how much information is stored in the trace log files.")] String LogVerbosity;
Expand Down
7 changes: 4 additions & 3 deletions src/Examples/FullExamples/NewFarm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ Configuration Example

OfficeOnlineServerFarm 'LocalFarm'
{
InternalURL = "https://officeonline.contoso.com"
EditingEnabled = $true
DependsOn = "[OfficeOnlineServerInstall]InstallBinaries"
IsSingleInstance = 'Yes'
InternalURL = "https://officeonline.contoso.com"
EditingEnabled = $true
DependsOn = "[OfficeOnlineServerInstall]InstallBinaries"
}
}
5 changes: 3 additions & 2 deletions src/Examples/Resources/OfficeOnlineServerFarm/1-NewFarm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Configuration Example

OfficeOnlineServerFarm LocalFarm
{
InternalURL = "https://officeonline.contoso.com"
EditingEnabled = $true
IsSingleInstance = 'YES'
InternalURL = "https://officeonline.contoso.com"
EditingEnabled = $true
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
$Script:DSCModuleName = 'OfficeOnlineServerDsc'
$Script:DSCResourceName = 'MSFT_OfficeOnlineServerFarm'
$Script:DSCModuleName = 'OfficeOnlineServerDsc'
$Script:DSCResourceName = 'MSFT_OfficeOnlineServerFarm'

[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'))) )
(-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
{
& git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\'))
& git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\'))
}
else
{
& git @('-C',(Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\'),'pull')
& git @('-C', (Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\'), 'pull')
}
Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force
$TestEnvironment = Initialize-TestEnvironment `
-DSCModuleName $Script:DSCModuleName `
-DSCResourceName $Script:DSCResourceName `
-TestType Integration
-DscResourceName $Script:DSCResourceName `
-TestType Integration

try
{
Expand All @@ -37,9 +37,10 @@ try

It 'Should have set the resource and all the parameters should match' {

$webAppsFarm.Remove('IsSingleInstance') | Out-Null
$result = Get-OfficeWebAppsFarm

foreach($key in $webAppsFarm.keys)
foreach ($key in $webAppsFarm.keys)
{
$result.$key | Should Be $webAppsFarm[$key]
}
Expand Down
26 changes: 14 additions & 12 deletions tests/Integration/MSFT_OfficeOnlineServerWebAppsFarm.config.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
$webAppsFarm = @{
InternalURL = 'http://webfarm.contoso.com/'
ExternalURL = 'http://externalfarm.contoso.com/'
AllowHttp = $true
EditingEnabled = $true
SSLOffloaded = $false
LogLocation = 'C:\Logs'
IsSingleInstance = 'Yes'
InternalURL = 'http://webfarm.contoso.com/'
ExternalURL = 'http://externalfarm.contoso.com/'
AllowHttp = $true
EditingEnabled = $true
SSLOffloaded = $false
LogLocation = 'C:\Logs'
LogRetentionInDays = 7
LogVerbosity = 'Verbose'
Proxy = 'http://proxy.contoso.com/'
AllowCEIP = $true
LogVerbosity = 'Verbose'
Proxy = 'http://proxy.contoso.com/'
AllowCEIP = $true
}

configuration MSFT_OfficeOnlineServerFarm_config {

Import-DscResource -ModuleName OfficeOnlineServerDsc
node localhost {

OfficeOnlineServerFarm Integration_Test
{
IsSingleInstance = 'Yes'
InternalURL = $webAppsFarm.InternalURL
ExternalURL = $webAppsFarm.ExternalURL
AllowHttp = $webAppsFarm.AllowHttp
Expand All @@ -27,7 +29,7 @@ configuration MSFT_OfficeOnlineServerFarm_config {
LogRetentionInDays = $webAppsFarm.LogRetentionInDays
LogVerbosity = $webAppsFarm.LogVerbosity
Proxy = $webAppsFarm.Proxy
AllowCEIP = $webAppsFarm.AllowCEIP
AllowCEIP = $webAppsFarm.AllowCEIP
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Invoke-TestSetup

$script:testEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:dscModuleName `
-DSCResourceName $script:dscResourceName `
-DscResourceName $script:dscResourceName `
-ResourceType 'Mof' `
-TestType 'Unit'
}
Expand All @@ -40,6 +40,7 @@ try
$proxy = 'http://proxy.contoso.com'

$mockWebFarm = @{
IsSingleInstance = 'Yes'
FarmOU = 'ldap://OU=Farm1'
InternalURL = [System.Uri]::new($internalURL.TrimEnd('/') + "/")
ExternalURL = [System.Uri]::new($externalURL.TrimEnd('/') + "/")
Expand Down Expand Up @@ -87,6 +88,7 @@ try
}

$mockWebFarmFalse = @{
IsSingleInstance = 'Yes'
FarmOU = 'Computers'
InternalURL = 'http://webfarm1.contoso.com/'
ExternalURL = 'http://webfarm1.contoso.com/'
Expand Down Expand Up @@ -135,20 +137,23 @@ try
}

$v16onlyParams = @("AllowOutboundHttp", "S2SCertificateName", "OnlinePictureEnabled", `
"OnlineVideoEnabled", "OfficeAddinEnabled", `
"ExcelUseEffectiveUserName", "ExcelUdfsAllowed", `
"ExcelMemoryCacheThreshold", "ExcelUnusedObjectAgeMax", `
"ExcelCachingUnusedFiles", "ExcelAbortOnRefreshOnOpenFail", `
"ExcelAutomaticVolatileFunctionCacheLifeTime", `
"ExcelConcurrentDataRequestsPerSessionMax", `
"ExcelDefaultWorkbookCalcMode", "ExcelRestExternalDataEnabled", `
"ExcelChartAndImageSizeMax")

foreach ($param in $v16onlyParams) {
if ($mockWebFarm.ContainsKey($param) -eq $true) {
"OnlineVideoEnabled", "OfficeAddinEnabled", `
"ExcelUseEffectiveUserName", "ExcelUdfsAllowed", `
"ExcelMemoryCacheThreshold", "ExcelUnusedObjectAgeMax", `
"ExcelCachingUnusedFiles", "ExcelAbortOnRefreshOnOpenFail", `
"ExcelAutomaticVolatileFunctionCacheLifeTime", `
"ExcelConcurrentDataRequestsPerSessionMax", `
"ExcelDefaultWorkbookCalcMode", "ExcelRestExternalDataEnabled", `
"ExcelChartAndImageSizeMax")

foreach ($param in $v16onlyParams)
{
if ($mockWebFarm.ContainsKey($param) -eq $true)
{
$mockWebFarm.Remove($param)
}
if ($mockWebFarmFalse.ContainsKey($param) -eq $true) {
if ($mockWebFarmFalse.ContainsKey($param) -eq $true)
{
$mockWebFarmFalse.Remove($param)
}
}
Expand Down Expand Up @@ -181,7 +186,8 @@ try

Context "A farm does not exist on the local machine, but should" {
$testParams = @{
InternalUrl = $internalURL
IsSingleInstance = 'Yes'
InternalUrl = $internalURL
}

Mock -CommandName Get-OfficeWebAppsFarm -MockWith {
Expand Down Expand Up @@ -209,9 +215,9 @@ try
}

It "Returns the current values from the get method" {
$getResult = Get-TargetResource -InternalURL $mockWebFarm.InternalUrl
$getResult = Get-TargetResource -InternalURL $mockWebFarm.InternalUrl -IsSingleInstance $mockWebFarm.IsSingleInstance

foreach($key in $mockWebFarm.Keys)
foreach ($key in $mockWebFarm.Keys)
{
$getResult[$key] | Should Be $mockWebFarm[$key]
}
Expand All @@ -222,14 +228,24 @@ try
}
}

Context "Try to create farm without passing URL Parameter" {
$thisContextMockWebFarm = $mockWebFarm.Clone()
$thisContextMockWebFarm.Remove('ExternalURL')
$thisContextMockWebFarm.Remove('InternalURL')

It "test method should throw" {
{ Test-TargetResource @thisContextMockWebFarm } | Should throw
}
}

Context "An incorrectly configured farm is found locally" {

Mock -CommandName Get-OfficeWebAppsFarm -MockWith {
return $mockWebFarmFalse
}

It "Returns the current values from the get method" {
(Get-TargetResource -InternalURL $mockWebFarm.InternalUrl).InternalUrl | Should Not BeNullOrEmpty
(Get-TargetResource -InternalURL $mockWebFarm.InternalUrl -IsSingleInstance $mockWebFarm.IsSingleInstance).InternalUrl | Should Not BeNullOrEmpty
}

It "Returns false from the test method" {
Expand All @@ -254,7 +270,7 @@ try
Mock Test-OosDscFarmOu { return $false }

It "Returns the current values from the get method" {
(Get-TargetResource -InternalURL $mockWebFarm.InternalUrl).InternalUrl | Should Not BeNullOrEmpty
(Get-TargetResource -InternalURL $mockWebFarm.InternalUrl -IsSingleInstance 'Yes' ).InternalUrl | Should Not BeNullOrEmpty
}

It "Returns false from the test method" {
Expand All @@ -270,23 +286,31 @@ try
if ($Global:CurrentWACCmdletModule.Contains("15") -eq $true)
{
Context "Errors are thrown when incorrect parameters are used for Office Web Apps 2013" {

$badParams = @{
IsSingleInstance = 'Yes'
InternalUrl = $internalURL
AllowOutboundHttp = $true
}

It "Throws in the get method" {
{ Get-TargetResource -InternalUrl $internalURL -AllowOutboundHttp:$true } | Should Throw
{ Get-TargetResource @badParams } | Should Throw
}

It "Throws in the test method" {
{ Test-TargetResource -InternalUrl $internalURL -AllowOutboundHttp:$true } | Should Throw
{ Test-TargetResource @badParams } | Should Throw
}

It "Throws in the set method" {
{ Set-TargetResource -InternalUrl $internalURL -AllowOutboundHttp:$true } | Should Throw
{ Set-TargetResource @badParams } | Should Throw
}
}
}

Context "Server is returning after a reboot after patching, do nothing" {
$testParams = @{
InternalUrl = $internalURL
InternalUrl = $internalURL
IsSingleInstance = 'Yes'
}

Mock -CommandName Test-Path -MockWith {
Expand All @@ -298,15 +322,15 @@ try
$returnval = $returnval | Add-Member -MemberType ScriptMethod `
-Name GetValue `
-Value {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[System.String]
$Input
)

return "Patching"
} -PassThru -Force
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[System.String]
$Input
)

return "Patching"
} -PassThru -Force

return $returnval
} -ParameterFilter { $Path -eq 'HKLM:\SOFTWARE\OOSDsc' }
Expand Down