Skip to content

Commit

Permalink
xExchange: Fix style according to style guideline (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju authored Oct 24, 2021
1 parent 01f95e2 commit 09e0bda
Show file tree
Hide file tree
Showing 20 changed files with 281 additions and 252 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update repository to use the latest pipeline ([issue #466](https://github.com/dsccommunity/xExchange/issues/466)).
- Updated CONTRIBUTING.md file with basic information on how
to run integration tests.
- Update repository to use the latest pipeline.
- Update the pipeline to use the build worker Ubuntu 18.04 instead of
Ubuntu 16.04.
- xExchOwaVirtualDirectoryInternal
- Added additional parameter SetPhotoEnabled
- RequiredModules
Expand All @@ -28,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- xExchange
- Fixed casing on folder in repository.
- Fixed unit tests so they can run using PowerShell 7.
- Fix style according to style guideline.

## [1.32.0] - 2020-05-13

Expand Down
110 changes: 63 additions & 47 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,86 @@ If want to know how to run this module's tests you can look at the [Testing Guid

## How to Run Integration Tests

This section describes the necessary information to be able to run the integration tests successfully.
This section describes the necessary information to be able to run the integration
tests successfully.

### Prerequisites
- Read the contributing guidelines document
- Make sure you have an Exchange Server **LAB** environment that is fully functioning with at least the following servers:
- 1 Domain Controller
- 2 Mailbox Servers
- Configured with one Database availability group (DAG)

- Read the contributing guidelines document
- Make sure you have an Exchange Server **LAB** environment that is fully
functioning with at least the following servers:
- 1 Domain Controller
- 2 Mailbox Servers
- Configured with one Database availability group (DAG)

> **Warning:** Please do not run the integration tests in a production environment.
### Domain Controller Server

1. Go to Active Directory Users and Computers - OU Builtin - Double-click Administrators - Members tab and add "Exchange Trusted Subsystem"
2. Create new and computer: Name DAG, on security tab chose "Exchange Trusted Subsystem" and give full control
1. Go to Active Directory Users and Computers - OU Builtin -
Double-click Administrators - Members tab and add "Exchange Trusted Subsystem"
1. Create new and computer: Name DAG, on security tab chose "Exchange
Trusted Subsystem" and give full control

### File Server

We need to make sure that we have a file server so it can act as File Witness for the Database availability group. This could be a Domain Controller in a testing environment, but this is not recommended in a production environment.
We need to make sure that we have a file server so it can act as File Witness
for the Database availability group. This could be a Domain Controller in a
testing environment, but this is not recommended in a production environment.

1. Install Failover Clustering:
```powershell
Install-WindowsFeature Failover-Clustering
```
2. Add "Exchange Trusted Subsystem" account into "Administrator group"
3. Create the file witness directory "C:\Witness" and shared for everyone with full access.
4. Reboot the server
```powershell
Install-WindowsFeature Failover-Clustering
```
1. Add "Exchange Trusted Subsystem" account into "Administrator group"
1. Create the file witness directory "C:\Witness" and shared for everyone with full access.
1. Reboot the server

### Mailbox Servers
We need to make sure that we are able to register the default repository for the PowerShell modules and add needed tools for testing:

We need to make sure that we are able to register the default repository for
the PowerShell modules and add needed tools for testing:

1. Add default repository:
```powershell
Register-PSRepository -Default -InstallationPolicy Trusted
```
2. Install Chocolatey
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
```
3. Once chocolatey has been installed, please install git and vscode:
```powershell
choco install git
choco install vscode
```
4. Log in to the Exchange Control Panel (ECP), the Web-based management interface, and create the DAG. In the Windows Server, follow this steps:
* Start Icon - Find the Exchange Administrative Center - logon - Click on Servers - Click on Database Availability Groups tab - " + " :
* Add Database availability group name: DAG (the same on the point 2 for DC)
* Add Witness server: fileserver
* Add path of the Witness directory: C:\Witness
* Go to MailFlow -> RecieveConnector and remove the default FrontEnd, if you don't remove the test fails.
5. Now, you are ready to adjust the code. Please do the following in one of your mailbox servers:
```powershell
# Create source folder
mkdir src
# Clone your forked xExchange repository
git clone https://github.com/yourusername/PULLREQUEST
# Go into the correct the cloned repository
cd .\xExchange\
# Checkout a branch
git checkout [branch_name]
```powershell
Register-PSRepository -Default -InstallationPolicy Trusted
```
1. Install Chocolatey
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
```
1. Once chocolatey has been installed, please install git and vscode:
```powershell
choco install git
choco install vscode
```
1. Log in to the Exchange Control Panel (ECP), the Web-based management interface,
and create the DAG. In the Windows Server, follow this steps:
- Start Icon - Find the Exchange Administrative Center - logon -
Click on Servers - Click on Database Availability Groups tab - " + " :
- Add Database availability group name: DAG (the same on the point 2 for DC)
- Add Witness server: fileserver
- Add path of the Witness directory: C:\Witness
- Go to MailFlow -> RecieveConnector and remove the default FrontEnd,
if you don't remove the test fails.

1. Now, you are ready to adjust the code. Please do the following in one of
your mailbox servers:
```powershell
# Create source folder
mkdir src
# Clone your forked xExchange repository
git clone https://github.com/yourusername/PULLREQUEST
# Go into the correct the cloned repository
cd .\xExchange\
# Checkout a branch
git checkout [branch_name]
```

### Run Integration Tests

Once you have made the necessary changes to the branch please run the following commands
Once you have made the necessary changes to the branch please run the following
commands

> **NOTE:** You might need to run this command to allow traffic to https:
Expand All @@ -90,7 +105,8 @@ Compiles the code with the changes you have made:
.\build.ps1 -Tasks build
```

Run the integration tests located in the `tests/Integration`. Write tests that will ensure that the issue in the code is fixed. See [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/).
Run the integration tests located in the `tests/Integration`. Write tests that
will ensure that the issue in the code is fixed. See [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/).

```powershell
.\build.ps1 -Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0
Expand Down
4 changes: 2 additions & 2 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
AddToPath = $true
Target = 'output\RequiredModules'
Parameters = @{
Repository = 'PSGallery'
Repository = 'PSGallery'
}
}

Expand All @@ -21,7 +21,7 @@
xDscResourceDesigner = 'latest'
'DscResource.DocGenerator' = 'latest'

# Prerequisites modules needed for examples or integration tests
# Prerequisites modules needed for examples or integration tests
'xPendingReboot' = '0.4.0'
'xWebAdministration' = '3.1.1'
}
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stages:
- job: Package_Module
displayName: 'Package Module'
pool:
vmImage: 'ubuntu 16.04'
vmImage: 'ubuntu 18.04'
steps:
- task: GitVersion@5
name: gitVersion
Expand Down Expand Up @@ -120,7 +120,7 @@ stages:
displayName: 'Publish Code Coverage'
dependsOn: Test_Unit
pool:
vmImage: 'ubuntu 16.04'
vmImage: 'ubuntu 18.04'
timeoutInMinutes: 0
steps:
- pwsh: |
Expand Down Expand Up @@ -168,7 +168,7 @@ stages:
- job: Deploy_Module
displayName: 'Deploy Module'
pool:
vmImage: 'ubuntu 16.04'
vmImage: 'ubuntu 18.04'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function Get-TargetResource
if ($property -eq 'Default')
{
$returnValue['MakeDefault'] = $acceptedDomain.$property
} else {
}
else
{
$returnValue[$property] = $acceptedDomain.$property
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function Set-TargetResource
-value @{
name = 'Exchange ActiveSync ISAPI Filter'
path = "$env:ExchangeInstallPath\FrontEnd\HttpProxy\bin\AirFilter.dll"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function Set-TargetResource

if ($PSBoundParameters.ContainsKey('RecipientFilter') -and
($PSBoundParameters.ContainsKey('IncludedRecipients') -or
$PSBoundParameters.Keys -contains 'Condit'))
$PSBoundParameters.Keys -contains 'Condit'))
{
throw 'You can''t use customized filters and precanned filters at the same time!'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1144,12 +1144,15 @@ function Get-FirstAvailableVolumeNumber
return 1
}

$currentFolders = Get-ChildItem -LiteralPath "$($AutoDagVolumesRootFolderPath)" | Where-Object {$_.GetType().Name -eq 'DirectoryInfo'} | Sort-Object
$currentFolders = Get-ChildItem -LiteralPath "$($AutoDagVolumesRootFolderPath)" |
Where-Object { $_.GetType().Name -eq 'DirectoryInfo' } |
Sort-Object

for ($i = 1; $i -lt 999; $i++)
{
$existing = $null
$existing = $currentFolders | Where-Object {$_.Name -eq "$($VolumePrefix)$($i)"}
$existing = $currentFolders |
Where-Object { $_.Name -eq "$($VolumePrefix)$($i)" }

if ($null -eq $existing)
{
Expand Down Expand Up @@ -1472,7 +1475,7 @@ function Initialize-ExchangeVolume

Start-Sleep -Seconds 15

Get-Partition -DiskNumber $DiskNumber -PartitionNumber 2| Format-Volume -AllocationUnitSize $UnitSizeBytes -FileSystem REFS -NewFileSystemLabel $Label -SetIntegrityStreams:$false -Confirm:$false
Get-Partition -DiskNumber $DiskNumber -PartitionNumber 2 | Format-Volume -AllocationUnitSize $UnitSizeBytes -FileSystem REFS -NewFileSystemLabel $Label -SetIntegrityStreams:$false -Confirm:$false
Add-PartitionAccessPath -DiskNumber $DiskNumber -PartitionNumber 2 -AccessPath $Folder -PassThru | Set-Partition -NoDefaultDriveLetter $true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function Set-TargetResource
if ($null -ne $AlternateServiceAccountCredential)
{
$asaParams = @{
Identity = $Identity
Identity = $Identity
AlternateServiceAccountCredential = $AlternateServiceAccountCredential
}

Expand All @@ -266,7 +266,7 @@ function Set-TargetResource
if ($RemoveAlternateServiceAccountCredentials)
{
$asaParams = @{
Identity = $Identity
Identity = $Identity
RemoveAlternateServiceAccountCredentials = $true
}

Expand Down Expand Up @@ -513,7 +513,7 @@ function Get-ClientAccessServerInternal
$serverVersion = Get-ExchangeVersionYear -ThrowIfUnknownVersion $true
if (($null -ne $AlternateServiceAccountCredential) -or ($RemoveAlternateServiceAccountCredentials))
{
$PSBoundParameters.Add('IncludeAlternateServiceAccountCredentialPassword',$true)
$PSBoundParameters.Add('IncludeAlternateServiceAccountCredentialPassword', $true)
}

if ($serverVersion -in '2016', '2019')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Set-TargetResource

Write-FunctionEntry -Parameters @{
'MailboxServer' = $MailboxServer
'DAGName' = $DAGName
'DAGName' = $DAGName
} -Verbose:$VerbosePreference

# Establish remote PowerShell session
Expand Down Expand Up @@ -152,7 +152,7 @@ function Test-TargetResource

Write-FunctionEntry -Parameters @{
'MailboxServer' = $MailboxServer
'DAGName' = $DAGName
'DAGName' = $DAGName
} -Verbose:$VerbosePreference

# Establish remote PowerShell session
Expand Down
22 changes: 11 additions & 11 deletions source/DSCResources/MSFT_xExchInstall/MSFT_xExchInstall.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ function Get-TargetResource
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Path,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Arguments,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential
)

Write-FunctionEntry -Parameters @{
'Path' = $Path
'Path' = $Path
'Arguments' = $Arguments
} -Verbose:$VerbosePreference

Expand All @@ -37,22 +37,22 @@ function Set-TargetResource
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Path,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Arguments,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential
)

Write-FunctionEntry -Parameters @{
'Path' = $Path
'Path' = $Path
'Arguments' = $Arguments
} -Verbose:$VerbosePreference

Expand Down Expand Up @@ -111,15 +111,15 @@ function Test-TargetResource
[OutputType([System.Boolean])]
param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Path,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.String]
$Arguments,

[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function Test-TargetResource
)

Write-FunctionEntry -Parameters @{
'JetstressPath' = $JetstressPath
'JetstressPath' = $JetstressPath
'JetstressParams' = $JetstressParams
} -Verbose:$VerbosePreference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ function Add-MailboxDatabaseCopyInternal
$copyCount++

# Create a copy of the original parameters
$originalPSBoundParameters =@{} + $PSBoundParameters
$originalPSBoundParameters = @{} + $PSBoundParameters

Remove-FromPSBoundParametersUsingHashtable -PSBoundParametersIn $PSBoundParameters `
-ParamsToRemove 'Credential', 'AllowServiceRestart', 'AdServerSettingsPreferredServer'
Expand Down
Loading

0 comments on commit 09e0bda

Please sign in to comment.